alessandroferrucci (1) [Avatar] Offline
#1
hello, i'm having issues in generating a buffered image from a PDF in linux. when I write out the PDF to disk and then display it using acroread it looks fine. When I use iText to generate an image out of the pdf in memory, the fonts don't look quite right...the glyphs are not 100% correct and the spacing between the characters is not correct. This works FINE in windows. Here is how I create the font to write to the pdf:

BaseFont bf = BaseFont.createFont(BaseFont.COURIER_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);

I saw in the iText book that iText uses a list of default locations where to find font files...I don't have any of those directories in my linux distribution (CentOS). However I also noted that iText does ship with some afm font files in the jar...and Courier is one of them...is there a special way to specify that I want to use the included afm file? I tried

BaseBont bf = BaseFont.createFont("Courier.afm", BaseFont.WINANSI, BaseFont.EMBEDDED);

but I got the following error:

java.io.IOException : Courier.afm not found as file or resource.

Thanks for your help

regards,

Alessandro Ferrucci
blowagie (284) [Avatar] Offline
#2
Re: font problem in linux
If you only use an AFM file, the font can never be embedded.
If you don't have the AFM files in the iText.jar, you are not using an official iText version.