Friday, January 8, 2010

Creating PDF using ASPpdf service

Here I will be discussing about creating pdf document using asppdf service. Here are some steps to be followed:
1. downloading and installing asppdf
2. Integration with application
3. coding for creation the pdf document

Mainly I prefer asppdf for creating PDF directly from a web URL. When I tried to use iTextSharp for converting a html or aspx page to PDF then it got stuck and my project exposed to risk of failing to satisfying some basic needs. However, here I am going to describe them in details

1. downloading and installing asppdf
one can download a 30-days free trial from the following URL:
http://asppdf.com/download.html
and then will provide a key which should be used during installation. After installing you will get a .dll in Bin folder of the installation directory.This dll is the object to work with.

2. Integration with application
You can get the dll from such a path:E:\Program Files\Persits Software\AspPDF\Bin\
Now you have to create a reference to that dll suing VS-200x

3. coding for creation the pdf document

using ASPPDFLib; //this is the required namespace of the dll

public string createAspPDF(string sourceURL, string destdirectory, string filename)
{
string created_pdf_url = string.Empty;
try {
HttpContext.Current.Session["access"] = "yes";
IPdfManager mymanager = new PdfManager();
IPdfDocument mydocument = mymanager.CreateDocument(System.Reflection.Missing.Value);
mydocument.ImportFromUrl(sourceURL, Missing.Value, Missing.Value, Missing.Value);
String myfilename = mydocument.Save(HttpContext.Current.Server.MapPath(destdirectory) + filename, true);
created_pdf_url = destdirectory + myfilename;
}
catch (Exception exc) {
return exc.Message;
}
return created_pdf_url;

}

where, sourceURL="http://www.nochallenge.net/biznesmakler"
destdirectory=destination directory in biznesmakler,
filename=file name for the pdf file,
created_pdf_url=the url of pdf file just created.

So that is the way to deal with pdf directly from a web url.

thx
Masud (1-9-2009)







No comments:

Post a Comment