Thank you for the information. As I am newbie to iText world, I am finding it
hard to put these things together. I found out that I have a font that
supports Ballot box unicode from this site
http://www.fileformat.info/info/unicode/char/2611/fontsupport.htm. According
that website, the font I picked is /Library/Fonts/Microsoft/Abadi MT
Condensed Light.  

ls /Library/Fonts/Microsoft/Abadi\ MT\ Condensed\ Light 
/Library/Fonts/Microsoft/Abadi MT Condensed Light

After looking at the XMLWorker documentation, I changed my method as shown
below to register the directory in which this font is located. I think the
Abadi font fails to register. I was trying to print all the registered fonts
and didn't find this in the list. 

public ByteArrayOutputStream htmlToPdfFile(String pathToTemplate,
                        Map<String, String> dataMap) throws 
FileNotFoundException,
                        IOException, TemplateException, DocumentException {

                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);

//              int count = FontFactory.registerDirectories();
                int msCount = 
FontFactory.registerDirectory("/Library/Fonts/Microsoft/");
                System.out.println("Fonts registered******** , Microsoft 
fonts:"+msCount);
                Document document = new Document();
                PdfWriter writer = PdfWriter.getInstance(document, baos);
                document.open();
                Font font = FontFactory.getFont("Abadi MT Condensed Light");
                for (Iterator iterator = 
FontFactory.getRegisteredFamilies().iterator();
iterator.hasNext();) {
                        String type = (String) iterator.next();
                        System.out.println("Family:"+type);
                }
                
                byte[] barray = sWriter.toString().getBytes();
                ByteArrayInputStream bais = new ByteArrayInputStream(barray);

                HtmlPipelineContext htmlContext = new HtmlPipelineContext(null);
                htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());
                htmlContext.setImageProvider(new AbstractImageProvider() {
                        public String getImageRootPath() {
                                return "js/";
                        }
                });
                htmlContext.setLinkProvider(new LinkProvider() {
                        public String getLinkRoot() {
                                return 
"http://tutorial.itextpdf.com/src/main/resources/html/";;
                        }
                });
                CSSResolver cssResolver = XMLWorkerHelper.getInstance()
                                .getDefaultCssResolver(true);
                Pipeline<?> pipeline = new CssResolverPipeline(cssResolver,
                                new HtmlPipeline(htmlContext, new 
PdfWriterPipeline(document,
                                                writer)));

                XMLWorker worker = new XMLWorker(pipeline, true);
                XMLParser p = new XMLParser(worker);
                p.parse(bais);

                document.close();

                return baos;
        }

Also updated the css for body as below

body {
        background-color: white;
        color: black;
        width: 100%;
        height: 100%;
        font-size: 8pt;
        font-family: Abadi MT Condensed Light
}

Am I missing something here? Thanks again for prompt reply.



--
View this message in context: 
http://itext-general.2136553.n4.nabble.com/Unable-to-parse-unicode-characters-in-Xmlworker-tp4659151p4659155.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/20/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&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

Reply via email to