Reputation: 1691
I am using ITextRenderer to generate PDF from html. However I am getting following exception:
Error Can't load the XML resource (using TRaX transformer). org.xml.sax.SAXParseException: Content is not allowed in prolog.
Could you please help me?
Any help will be appreciated.
Thanks in advance.
Upvotes: 1
Views: 2247
Reputation: 25
You haven't mentioned that in which programming language you are working. I am assuming that you are doing this in Java. writeNextDocument() lets you render multiple X/HTML documents onto the same PDF. It doesn't let you paste PDFs together. The error comes from the XML parser trying to parse the PDF document as an XML document. The easiest way to do what you want is to render the X/HTML to a PDF with FS and then use iText directly to paste them together (Google will turn up examples of this).
Upvotes: 0
Reputation: 5471
It is probably caused by lack of encoding declaration in your xml file
XML file header: <?xml version='1.0' encoding='utf-8'?>
You should have something like this ( or other encoding type ) at the very top of your xml file.
OR
You do not escape special characters
Upvotes: 2