views:

2935

answers:

2

Hi,

I defined a tag map, and got a xml data file. I want to convert the xml data file to PDF by using iText. The question is how to embed fonts (e.g. polish font, chinese font) into target PDF when converting xml to PDF?

Thanks.

+1  A: 

If you are doing more work with iText, you may want to invest into the iText book - it has examples for all the features of iText.

There is a parameter that you specify when you create your font that defines font embedding:

BaseFont helvetica = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.EMBEDDED);
Font font = new Font(helvetica, 12, Font.NORMAL);

You can find more iText font related examples here: http://1t3xt.info/examples/browse/?page=toc&id=14

khkremer
I have studied some examples in iText book, seems none gave a hint for my problem. In your example, there is a flag "BaseFont.EMBEDDED" that can be used to indicate embedding of font file. But what I have to do is converting XML file to PDF directory with defined tagmap, the whole process is only one call. There is no place where I can put some code to embed font. In your example, we can set the font to some paragraph so that font is embedded into that paragraph. But for automated PDF generation with tagmap, how can we set the font, which class/interface can we use to embed the font? Thanks.
moonli
Problem solved. We can embed font with configuration in TagMap. Setting "embedded" attribute to "true" indicates font embedding.Thanks anyway.
moonli
A: 

I'm having a problem with embedding in PDF documents Please find the description here

http://www.thejavacode.com/itext-embeded-font-problem-t9792.html

Java Developer