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.,8.2.0.0.
http://www.aspose.com/docs/display/pdfnet/How+to+convert+HTML+to+PDF+using+InLineHTML+approach
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();
//license2.SetLicense(@“C:\Jetstream\500\Resources\Aspose.Pdf.Kit.lic”);
license.SetLicense(@“C:\Aspose\Aspose.Pdf.lic”);
// 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
section.Paragraphs.Add(text2);
// Specify the URL which serves as images database
//pdf.HtmlInfo.ImgUrl = “http://en.wikipedia.org/”;
//Save the pdf document
pdf.Save(“C:\pdftest\DirectHTML2pdf.pdf”);
localWebResponse.Close();
localResponseStream.Close();

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.
Thanks,
Siddi.

Hi Aspose Team,

Is there any update on this?

Thanks,
Siddi.

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.
(4)

Hi,
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.


(1)

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.
(2)