The code on your example page doesn't work

this one
*
// 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();

// Read the contents of HTML file into StreamReader object

StreamReader r = File.OpenText(@“D:/pdftest/HTML2pdf.html”);

//Create text paragraphs containing HTML text

Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());

// enable the property to display HTML contents within their own formatting

text2.IsHtmlTagSupported = true;

//Add the text paragraphs containing HTML text to the section

section.Paragraphs.Add(text2);

// Specify the URL which serves as images database

pdf.HtmlInfo.ImgUrl = “D:/pdftest/MemoryStream/”;

//Save the pdf document

pdf.Save(“D:/pdftest/MemoryStream/HTML2pdf.pdf”);

and that one :slight_smile:

// 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);
// 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(“D:/pdftest/DirectHTML2pdf.pdf”);
localWebResponse.Close();
localResponseStream.Close()
*
generate an empty PDF file …

why ?

Hi there,


Thanks for your inquiry. While using Aspose.Pdf for .NET 7.7.0, I’m unable to reproduce the issue. Can you please share the error message? We will appreciate if your share the sample project here. So we will investigate the issue and provide you more information accordingly.

Best Regards,

can i send you the project by email ?

Hi,


You can either attach your archived sample project here using add/update button, available at bottom of reply page, or email using contact tab on thread.

Please don’t forget to remove the license file and Aspose product dll from your project.

Best Regards,