iOS PDF parsing Type 1 Fonts metrics

2019-05-26 18:20发布

问题:

I'm (trying) to write a "PDF to plain text parser" and I'm using pdfKitten as an example.

My PDF includes a type1 font included into the "standard 14 fonts". Subsequently the PDF font dictionary does not include keys for "Widths" "FirstChar" "LastChar".

I assume, since it is one of the "standard 14 fonts" (actually 2, Courier and Courier-bold), that the iOS framework contains these metrics somewhere.

How can I access these metrics?

回答1:

The metrics for the standard PDF fonts are usually built in each PDF viewer application. These metrics were made public through the corresponding .afm files, one for each font. They were available for download from Adobe website but now I cannot find the link.
You can get these files from any iText / iTextSharp distribution and I'm sure there are other products that include these files.