Get fonts used in a PDF document with Adobe Acrobat

Does anyone know if it is possible to return a list of fonts being used in a PDF document using Acrobat?

As shown in the results of the ‘File’ > ‘Properties…’ under the Fonts tab.

There is very little information in the Adobe Acrobat Professional Dictionary when searching for ‘fonts’ or ‘properties’.

Thanks in advance…

I’ve never scripted Acrobat before, but as you say the reference is a bit sketchy.

A clunky workaround might be to open the PDF in TextEdit and search for this kind of thing:
/FontName /GIFTLG+ZapfChancery-Italic /

Fonts are preceeded by/FontName / so it shouldn’t be too difficult to extract that info using applescript

Thanks for that.

It got me thinking… A (probably) less ‘clunky’ solution could be:-

set myDoc to (choose file with prompt "Choose a pdf")
set pathToDoc to POSIX path of myDoc

set allFonts to do shell script "grep -a 'FontName' ../../" & pathToDoc

giving the following:-

But even this is hardly a list of just the Fonts used in a document.

Does anyone know of a quick way to strip this down?

Many Thanks.

I now have:-

set myDoc to (choose file with prompt "Choose a pdf")
set pathToDoc to POSIX path of myDoc

set allFonts to do shell script "tr '\\r' '\\n' < ../../" & pathToDoc & " | grep -a 'FontName'"

Resulting in:-

I have it :lol: (if anyone is interested):-

set myDoc to (choose file with prompt "Choose a pdf")
set pathToDoc to POSIX path of myDoc

set allFonts to do shell script "tr '\\r' '\\n' < ../../" & pathToDoc & " | grep -a 'FontName' | cut -d '/' -f 4 | cut -d '+' -f 2"

A big thanks to divster for your suggestion. I now don’t even have to open Acrobat!!

Nicely done.
Just a few more kinks: Files with spaces in their filenames return nothing. And exotic characters in the filename makes the script fail. Any ideas?

I too found that paths with spaces in them fail, and also that the font name is not always in the same place within the resuls.
The following addresses this

set myDoc to (choose file with prompt "Choose a pdf")
set pathToDoc to POSIX path of myDoc

set allFonts to do shell script "tr '\\r' '\\n' < ../../" & quoted form of pathToDoc & " | grep -a 'FontName' | cut -d '+' -f 2 | cut -d '/' -f 1"

Still not sure on the ‘exotic’ characters…

Now it’s working on most pdfs I’ve tried, but it still returns empty on some of them. I’m not sure it’s about the characters in the file name, maybe they’re just structured differently. I could imagine that pdf standards have changed quite a few times.

I have found that some fonts (but not the majority) do not have the 6 characters and ‘+’ in the string returned. As I am using the ‘+’ as a delimiter in the Unix ‘cut’ command, this is giving some odd results.

Fonts in one document are:-

Which when cut using the ‘+’ delimiter gives:-

Problem is, as the FontName is not always in the same position, I cannot use the ‘/’ as a delimiter.

would repeating through each line (paragraphs of allFonts) and using the offset of “FontName/” +1 to “/” work??

Hi intoto

Glad you’re having some success. I don’t use grep in a shell script but do use it in InDesign for styles. Hopefully the syntax is similar enough to be useful. If I use the following:


This is positive look behind for /FontName/ followed by any character repeated one or more times shortest match followed by positive look ahead for /

I can highlight the font names in your example as follows:

Then it would be easy to chop off the other rubbish with:

This is any upper case character (5 times) followed by + (escaped with a )

Hope this helps

Thanks again divster!

I’m not familiar with that ‘kind’ of grep in Unix, but again based on your suggestion and working with the Unix grep and regex I now have the following that returns everything after the FileName/ and then repeats through every line and if it contains the “+” character, it ‘cuts’ it out.

set myDoc to (choose file with prompt "Choose a pdf" without invisibles)
set pathToDoc to POSIX path of myDoc

set allFonts to paragraphs of (do shell script "tr '\\r' '\\n' < ../../" & quoted form of pathToDoc & " | egrep -ao \"FontName.*/\" | cut -d '/' -f 2") -- | cut -d '/' -f 1")

set fontList to {}
repeat with i from 1 to number of items in allFonts
	set thisItem to item i of allFonts
	if thisItem contains "+" then
		set thisItem to do shell script "echo " & thisItem & " | cut -d'+' -f2 "
		set fontList to fontList & thisItem
	else
		set fontList to fontList & thisItem
	end if
end repeat
fontList

I’ve not tested loads of PDFs, but so far so good. Thanks for everyones input.

Good work intoto

I’ve saved your script for later, just in case!

Do you know any good resources for learning shell script?

Model: 2 x 2.8 GHz Quad-Core Intel Xeon
AppleScript: 2.1.2
Browser: Firefox 3.6.14
Operating System: Mac OS X (10.6)

Hi divster

http://ss64.com/osx/

is a good site for Mac specific Unix commands. For everything else google search “Mac OS X Unix commands” (Some Linux/Solaris commands are not available in Mac OS X!)

I also refer to the book “Mac OS X UNIX Toolbox - 1000+ Commands for Mac OS X Unix”

Does anyone else have any resources to add?