The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

alessandroferrucci (1) [Avatar] Offline
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 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: : Courier.afm not found as file or resource.

Thanks for your help


Alessandro Ferrucci
blowagie (284) [Avatar] Offline
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.