I have a plugin that's reading the fonts within a pdf document
I have written code to use PDDocEnumLoadedFonts to read all the fonts loaded by the doc
This code will be run after the AVDocDidOpen fired by the runtime
I am expecting to be able to read fonts
But no fonts are read
It seems that the whole of doc is not loaded when AVDocDidOpen is fired
If I run the same code say on a pointer move, the fonts are found
Copy link to clipboard
"I am expecting to be able to read fonts" You should not expect this. You should expect no fonts to be loaded, this should be clear from the documentation "PDDocEnumLoadedFonts... Enumerates all the fonts that have been encountered so far. A font is loaded when a page that uses it is processed. This typically happens when a page is drawn or its thumbnail image is created."
It is a fundamental part of Acrobat that pages are not even read from disk until they are needed. This is very important. A file might be 20GB in size and have 500,000 pages. The user would not want to wait 20 minutes when opening, while all the fonts were scanned for your convenience. By coincidence, I recently posted a reply giving two methods of enumerating a PDF to get a full list of fonts - check the forum. These are a lot more work than just calling one method!
Hey, many thanks!
I tried searching your posts on forum and its a long list!
Do you happen to remember the title of the posts?
1. Enumerate pages, enumerate all text runs, check PDEFont for embedding flags.
2. Enumerate all font dictionaries in all Resources dictionaries (recursively into Form XObjects etc.), checking the FontFileXXX values in font attribute dictionaries.