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

Free Support Forum - aspose.com

Bind HTML - what are the invalid characters?

Hi,

I am trying to use Aspose.Pdf to dynamically create a PDF file with my company's logo at the top, email subject with a blue background/white text after the logo, and the senders name and email. I was wondering how to layout these elements, since this is based on a webpage, I tried to use HTML to create this header section, but I am getting an Invalid Character exception with no indication as to what these invalid characters are. Code is below

Pdf pdf = new Pdf();

pdf.IsTruetypeFontMapCached = false;

pdf.PageSetup.PageHeight = PageSize.A2Height;

Section secHeader = pdf.Sections.Add();

// This works

pdf.BindHTML("

Test

Test paragraph

");

// This does not - what characters are invalid?

pdf.BindHTML(@"

Morning Glory 18th November 2011
FirstName LastName first.last@mycompany.com
");

pdf.Save("C:\\temp\\test.pdf");

I also will need to insert contents of the HTML based emails into the PDF file, so I assume BindHTML is the best way to do this. Can someone guide me as to what is and what is not allowed when using BindHTML?

Thanks,

Hi Herman,


Thanks for your interest in our products. As per your requirement of adding log and text information in Header section of the document, I would recommend you to simply try creating a table object, add image and text into table cells and then add table to paragraphs collection of Header section. For further information, please visit Table in Header/Footer section

Besides this, in case you need to insert HTML contents into PDF document, you may try consider using the approach to read the HTML contents into Text object and then add it to paragraphs collection of Section. Please visit the following link for related information on HTML Tags in Text

BindHTML method is used to convert HTML contents into PDF format, but as per your requirements, you may try using this method but for that reason, you need to first create the HTML document or create an HTML string with all the formatting and then you can use this method to convert it into PDF format. In case you have any further query, please feel free to contact. We apologize for your inconvenience.