Simple & Solid Reporting in .NET using ABCpdf.NET

last week I was involved in developing an internal windows application for my company and we wanted to print simple report and keep the application simple to deploy ( xcopy way ) and as we use Windows 7 in all our company computers which already have .NET framework but nothing else ( not crystal reports or MS reporting tools ) , I decided to use ABCpdf.NET to create our simple report via creating html page and converting it to PDF for printing & archiving .

hint : if you don’t have ABCpdf.NET already installed you can download it from this link ( the 32bit version is about 43MB )

here I am going to explain the first steps to get started with ABCpdf.NET library ..

* after downloading and installing ABCpdf.NET library go to Visual Studio and create new windows forms application

* add webBrowser control to show the report and a button to save it in PDF file format like this image

* add HTML page to your project and put the following HTML in it :

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
        Fayecom Company 
        <br /> 
        Simple Report 
    <br /> 
    <br /> 
    <table width="100%"> 
        <tr style="font-weight: bold; background-color: #E0E0E0"> 
                Client Name 
                Client Mobile Phone 
                Client Address 

* change [copy to output Directory] property of this HTML file to ( copy if newer ) or ( always copy )

* write the following code to form load event

string mFileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath) ,"HTMLPage1.htm");
string mHTML = File.ReadAllText(mFileName); 

mHTML = mHTML.Replace("[name]","Mohammed Samir Fayed"); 
mHTML = mHTML.Replace("[mobile]","1234567890"); 
mHTML = mHTML.Replace("[address]","My Address :)");

webBrowser1.DocumentText = mHTML;

* now run your application , it should be like this

* now add reference to ABCpdf.NET library

* add this code to button click event

string mPdfFileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath) ,"tempFile.pdf");

Doc myPDF = new Doc();




this will export your report to PDF and run it the default PDF viewer like this