I was trying to convert a HTML file to PDF using XMLWorker of iText API. The HTML content is obtained during runtime from freemarker template (attached here) by passing a datamap. The obtained HTML content is converted to string and finally to inputstream as shown in below method.
private ByteArrayOutputStream convertToPDF(Document document, String pathToTemplate, Map<String, String> dataMap) throws FileNotFoundException, IOException, DocumentException, TemplateException { ClassTemplateLoader ctl = new ClassTemplateLoader(getClass(), "/"); StringWriter sWriter = new StringWriter(); Configuration cfg = new Configuration(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); cfg.setTemplateLoader(ctl); Template templateToProcess = cfg.getTemplate(pathToTemplate); templateToProcess.process(dataMap, sWriter); PdfWriter writer = PdfWriter.getInstance(document, baos); document.open(); System.out.println("sWriter.toString()"+sWriter.toString()); byte[] barray = sWriter.toString().getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(barray); // convert the HTML with the built-in convenience method XMLWorkerHelper.getInstance().parseXHtml(writer, document, bais); document.close(); return baos; } The outputstream that was returned from above method is then used to display the PDF document in browser. I am able to generate the PDF successfully.But then I will have to show few checkboxes, realizing that XMLWorker doesn't support input fields I switched to Unicode ballot box character(☐). However, the XML Worker parser ignores these characters. I have tried to copy the character itself as well as few other codes in template. Please refer to the attached template and PDF files. Any quick help is appreciated! test.ftl <http://itext-general.2136553.n4.nabble.com/file/n4659151/test.ftl> output.pdf <http://itext-general.2136553.n4.nabble.com/file/n4659151/output.pdf> Ballot box reference:http://www.fileformat.info/info/unicode/char/2610/index.htm -- View this message in context: http://itext-general.2136553.n4.nabble.com/Unable-to-parse-unicode-characters-in-Xmlworker-tp4659151.html Sent from the iText - General mailing list archive at Nabble.com. ------------------------------------------------------------------------------ LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99! 1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint 2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/22/13. http://pubads.g.doubleclick.net/gampad/clk?id=64545871&iu=/4140/ostg.clktrk _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php