简体   繁体   English

如何通过abcpdf获取嵌入字体和参考字体的列表?

[英]How can I get list of embedded and referenced fonts via abcpdf?

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? 如何通过abcpdf获取pdf文件中嵌入字体和参考字体的列表?

I do not think ABCpdf provides a way to get a list of the fonts that are in an already existing PDF. 我不认为ABCpdf提供了一种获取现有PDF字体列表的方法。 There just isn't any implementation of that. 只是没有任何实现。 You'd need to dig through the ObjectSoup with knowledge of PDF internals. 您需要使用PDF内部知识来深入研究ObjectSoup

There are other tools that can list the fonts in a PDF, for example pdffonts from the xpdf package. 还有其他工具可以列出PDF中的字体,例如xpdf软件包中的pdffonts

Depends on your scenario but I've had luck using this with ABCPdf 10. 取决于您的情况,但是我很幸运在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);
    }
}

You could use the FontObject class. 您可以使用FontObject类。 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);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM