Reputation: 8404
I can embed fonts, add (reference) fonts, set a current font, but that seems to be it.
How can I get a list of embedded and referenced fonts in a pdf file via abcpdf?
Upvotes: 2
Views: 616
Reputation: 31
You could use the FontObject class. For example:
List<string> embeddedFonts = new List<string>();
List<string> referencedFonts = new List<string>();
FontObject[] fonts = doc.ObjectSoup.Catalog.GetFonts();
foreach (FontObject font in fonts) {
if (font.EmbeddedFont == null) {
referencedFonts.Add(font.BaseFont);
} else {
embeddedFonts.Add(font.BaseFont);
}
}
Upvotes: 1
Reputation: 5739
Depends on your scenario but I've had luck using this with ABCPdf 10.
public IEnumerable<string> EmbeddedFonts
{
get
{
return doc.ObjectSoup.Catalog.GetFonts()
.Select(x => x.BaseFont).Where(x =>
!x.StartsWith("Helvetica") &&
!x.StartsWith("Times") &&
!x.StartsWith("Zapf")).Distinct().OrderBy(x => x);
}
}
Upvotes: 1
Reputation: 6259
I do not think ABCpdf provides a way to get a list of the fonts that are in an already existing PDF. There just isn't any implementation of that. You'd need to dig through the ObjectSoup
with knowledge of PDF internals.
There are other tools that can list the fonts in a PDF, for example pdffonts from the xpdf
package.
Upvotes: 1