I'm trying to convert the HtmlBody of the e-mails I get from a mailserver using Mailkit and looks like iTextSharp doesn't really like the html I'm passing it. My method works well with a "sample" html code but I get a The document has no pages error message which looks like it's thrown when the html is no html anymore. Here is a link to pastebin for checking the HtmlBody of the MimeMessage because I hit the character limit here. It worked with one e-mail but not with others.

Author:Kaziramar Kanos
Language:English (Spanish)
Published (Last):13 March 2010
PDF File Size:1.2 Mb
ePub File Size:3.75 Mb
Price:Free* [*Free Regsitration Required]

Search everywhere only in this topic. Advanced Search. Classic List Threaded. Mark Ramos. Hi, Thanks for the links Balder.

I tried to render the enclosed html file to pdf and I did not get a good result. Please check the attachments. Many thanks! Splunk takes this data and makes sense of it. Business sense. IT sense. Common sense. Balder VC. Couple tips: It's better to write measures in points pt. Then no conversion is done by the XMLWorker.

It's a good idea to check the supported tags in the documentation or inside com. Tags there are the defaults listed. You can easily write a TagProcessor that does support the font tag as you see fit. If I'm correct it is better to define a width for your tables, then the XMLWorker does not have to try and fit text in it. Nesting tables is possible, but it makes it harder for XMLWorker to fit tables on the page.

Thanks again Balder, The only challenge we had is that the input of all these html is from a CKEditor to make contents in liferay. Then when the content is rendered in html we have to export it in PDF. We also tried using flying-saucer which also uses iText 2. I appreciate giving your time to us. Maybe word can be configured to output pt instead of px and in, and to produce fixed width tables, or not to nest tables.

But I fear for it. I think your best option is to implement a TagProcessor for font, or add it to the TagFactory so that it maps to something existing. You can't use the default settings for that. TagProcessor this way the text in the font tag will be in the PDF and handled as the span tag. Bear in mind, the attributes from the font tag won't be taken into account, the same counts for some of the attributes from the table tag. Perhaps you can arrange some of the things by adding your own CSS file where you set certain css values yourself if they are not overridden by css properties added later.

I most certainly agree with that. It was not our expected scenario before. I'll check on them and see what I can come up with. Will keep in touch once I have update on it. Your help is very much appreciated! I hope I gave you some helpful directions and ideas Kind Regards Balder. In reply to this post by Mark Ramos. Thanks in adavance. Thank you very much! Hi Balder, I most certainly agree with that.

Free forum by Nabble. Edit this page.


HTML to PDF with XMLWorker

Home Categories. Net MVC. Need Help? Our Support Team is here to help. Ask Question. Net MVC Razor.


Generate a PDF from an ASP.NET Web Page using the iTextSharp XMLWorker Namespace

Search everywhere only in this topic. Advanced Search. Classic List Threaded. Mark Ramos. Hi, Thanks for the links Balder. I tried to render the enclosed html file to pdf and I did not get a good result.


Mailkit: Converting HtmlBody to pdf using iTextSharp XMLWorker throws "The document has no pages"

Wow thx your code was a great help i was looking how to convert html to pdf with my database and found your blog. You a time saver. Hi Matt, Can this code easily be changed to create the pdf "in memory", and email it off as an email attatchment. Hi Melvyn, Thanks for stopping by and reading the article and leaving a comment. To answer your question, yes, you could easily create the PDF file in memory instead of saving it to file. Once you have it in a Byte array the rest is just a matter of adding it as an attachment using the built in System. Good luck, Matt.

Related Articles