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.

maro158 (2) [Avatar] Offline
I am a newbie to iText, but I'm quite surprised by the quality of your code and of iText in Action. Thank you for doing this great job!

I try to extend your sample EmbedFontPostFacto in a way that would permit to embed fonts not already embedded in a pdf file. Since I do not know the exact location of the font file programs at compile time, I will let the user choose a font directory to search in. Then the application would get the aFont.BaseFont.FullFontName field that specifies the font name and starting from that information it would try to locate the font file. Now how could I do this? I suppose the font location isn't saved with the pdf file?

Thank you for helping
blowagie (284) [Avatar] Offline
Re: Getting the font file associated with a full font name
The location of the font file is not saved in the PDF file for obvious reasons. That's an answer to the final question. I don't understand the other questions. Even if you had the location of the font on the machine that was used to create the PDF, this information would be worthless for people manipulating the PDF on another system.
maro158 (2) [Avatar] Offline
Re: Getting the font file associated with a full font name
Let me try to explain it: I have a database with a large number of files, where the fonts are not embedded within the PDF files although all fonts are present on the users systems.

Now I have to ensure that the files are PDF/A compatible. So I must write a small application that embedds the fonts post facto. Since there is information about the font used in the PDF files, but no information regarding the font file name, how can I do this?
blowagie (284) [Avatar] Offline
Re: Getting the font file associated with a full font name
It depends on the way the PDFs are created. You can create a PDF with font Helvetica and tell the PDF the font that was used was 'myPersonalFont'. If that is the case, you're out of luck.
My approach would be to register the main font directories in the FontFactory. Then get the font dictionaries from the page resources and get the font name. Now compare the names retrieved from the font dictionaries with the names of the fonts available in the FontFactory.
It won't be a waterproof solution, but you'll be able to find the most common fonts. Note that the standard type 1 fonts (see chapter 7) can only be embedded if you provide the pfb file.