HTML to PDF character exception

Hello,

I am attempting to generate a PDF from HTML which throws an exception in the scenario below. It is essential to include the < character in the text, and other characters which I assume are being interpreted as HTML. How can I ensure that this character, and others, is processed and rendered correctly?

I am using Aspose.PDF v.6.3.0.0

Best regards
Iain

The following HTML:








COMMENT < COMMENT COMMENT < COMMENT COMMENT < COMMENT COMMENT < COMMENT COMMENT < COMMENT COMMENT < COMMENT COMMENT < COMMENT



Generates:

Exception Message: Value cannot be null. Parameter name: name
Exception Source: Aspose.Pdf
Exception Target Site: .? (System.String, System.String, .?)
Exception Stacktrace:
at .?.(String , String , ? )
at .?.( , ? )
at ..( , ? )
at ..( , ? )
at ..( , ? )
at ..( , ? )
at ..( , ? )
at ..( , ? )
at ..( , ? )
at ..( , ? )
at .?.(String )
at ..(String )
at ?.?.(Pdf , Section , Cell , Text , HeaderFooter , ? , )
at ?.?.(Pdf , Section , Table , Cell , Text , HeaderFooter , ? , )
at ?.?.(Pdf , Section , HeaderFooter , Table , Row , Cell , Text , ? , , Boolean )
at ?..(Pdf , Section , ? )
at ?.?.(Pdf )
at ?.?.( , Pdf )
at Aspose.Pdf.Generator.Pdf.Save(Stream stream)

Hi Lain,


Thanks
for using our products.<o:p></o:p>

I have tested the scenario where I have used the following code snippet to convert HTML file to PDF format and as per my observations, I am unable to notice any exception. However the resultant PDF being generated is 0KB. For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-35495. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

[C#]

// 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("c:/pdftest/sample.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);

pdf.Save(“c:/pdftest/Aspose_Test.pdf”);


PS, can you please share the code snippet which you are using.

The issues you have found earlier (filed as PDFNET-35495) have been fixed in Aspose.PDF for .NET 18.11.