0

why there is need of font [FontName.afm] files to parse PDF file and itextsharp can parse all the PDF ?

i.e.

for example PDF file contain text whose fontface is new, so my question is that it can parse that text from PDF file without providing [FontName].afm file

AJ0
  • 13
  • 7
  • *why there is need of font [FontName.afm] files to parse PDF file* - afm files contain font metrics, and at least font glyph widths are needed during extraction to get the glyphs in the right order. But PDF files contain the font widths for fonts with the exception of the standard 14 fonts, and the metrics for those fonts are included in the iText(Sharp) library. Thus, I Text(Sharp) does not need additional afm files for text extraction. – mkl Jan 06 '15 at 05:09

1 Answers1

1

This question was cross-posted on SO and the iText mailing-list. I'm copying my answer to the mailing-list on SO:

why there is need of font files [FontName.afm] in itextsharp library

Those files contain font metrics (AFM = Adobe Font Metrics). They are needed to calculate the dimensions of snippets of text (height, width). The 14 AFM files shipped with iTextSharp correspond with the 14 Standard Type 1 fonts. These are fonts that any PDF viewer should be able to render, hence there is no need to embed these fonts (unless font embedding is a requirement, e.g. in the context of PDF/A).

Please download the free ebook "The Best iText Questions on StackOverflow" and read the answers to the questions in the section about fonts for more info.

See also:

and without those font files can we extract text from PDF files and for newly introduced fontface itextsharp is useful to extract text from PDF or Not?

You don't need AFM files to extract text, as most the information you need (such as the width of each glyph that is used in the document) is stored inside the document. iTextSharp is useful to extract text from a PDF, but sometimes it is impossible to extract text in general (no matter which tool you're using). For a more elaborate explanation, please watch this video: https://www.youtube.com/watch?v=wxGEEv7ibHE

See also:

Community
  • 1
  • 1
Bruno Lowagie
  • 75,994
  • 9
  • 109
  • 165