We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

While converting Web page to PDF ..unable to open the generated pdf

Hi ,
I am trying to follow the example code mentioned in the below url with the lateset Aspose.pdf for .NET dll i.e.,
The code I am using is as follows:

// The address of the web URL which you need to convert into PDF format
string WebUrl = “http://en.wikipedia.org/wiki/Main_Page”;
// create a Web Request object to connect to remote URL
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(WebUrl);
// set the Web Request timeout
request.Timeout = 10000; // 10 secs
// Retrieve request info headers
HttpWebResponse localWebResponse = (HttpWebResponse)request.GetResponse();
// Windows default Code Page (Include System.Text namespace in project)
Encoding encoding = Encoding.GetEncoding(1252);
// Read the contents of into StreamReader object
StreamReader localResponseStream = new StreamReader(localWebResponse.GetResponseStream(), encoding);
Aspose.Pdf.License license = new Aspose.Pdf.License();
// Instantiate an object PDF class
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
// add the section to PDF document sections collection
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
//Create text paragraphs containing HTML text
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, localResponseStream.ReadToEnd());
// enable the property to display HTML contents within their own formatting
text2.IsHtmlTagSupported = true;
// Add the text object containing HTML contents to PD Sections
// Specify the URL which serves as images database
//pdf.HtmlInfo.ImgUrl = “http://en.wikipedia.org/”;
//Save the pdf document

But I am getting the error message “Adobe Reader Could not open ‘DirectHTML2pdf.pdf’” because it is either not a supported file type or because the file has been damaged(for example, it was sent as an email attachment and wasn’t correctly decoded.)
Please see the attached file for the error message that is getting displayed.
Additional Information:

I have tried in Windows 7 and Windows server 2003.
In both the machine I am getting the error message as shown in the attachment.
Please let me know if any more details are needed.

Hi Aspose Team,

Is there any update on this?


Hi Siddi,

Thanks for your inquiry. I’m afraid we have already found issue with the specific link and logged it in our issue tracking system as PDFNEWNET-34700 for investigation and resolution. We will update you via this forum thread as soon as it is resolved.

Meanwhile, can you please try some other link for the conversion? Hopefully it will work.

Sorry for the inconvenience faced.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-36235) have been fixed in Aspose.Pdf for .NET 9.8.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Thanks for your patience.
We are pleased to share that we have made significant improvements in our HTML to PDF conversion feature in new Document Object Model of Aspose.Pdf namespace and the issue you have reported earlier (filed as PDFNEWNET-34700) has been fixed in Aspose.Pdf for .NET 11.0.0. Please try using the new approach and new release version and in case you still face any issue or you have any further query, please feel free to contact.


The issues you have found earlier (filed as PDFNEWNET-34700) have been fixed in Aspose.Pdf for .NET 11.5.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.