我试图解决的一般问题是确定大量PDF中有多少文本与不同的字体相关联。我知道我可以使用pdftotext从PDF中提取文本,使用pdffonts提取字体信息,但我不知道如何将它们链接在一起。我有100,000+的PDF文件要处理,所以需要一些我可以针对程序(我不介意一个商业解决方案)。
发布于 2018-08-24 07:47:59
PDFTron PDFNet SDK可以提取所有的图形操作,包括文本对象,包括正在使用的字体的链接。
从ElementReader示例开始,您可以获得每个文本元素的字体。https://www.pdftron.com/documentation/samples?platforms=windows#elementreader https://www.pdftron.com/api/PDFNet/?topic=html/T_pdftron_PDF_Font.htm
发布于 2018-08-31 00:43:20
我的公司销售的产品Adobe PDF Library可以做到这一点。
这是示例代码的一部分:
// This callback function is called fpr each PDWord object.
ACCB1 ASBool ACCB2 WordEnumProc(PDWordFinder wfObj, PDWord pdWord, ASInt32 pgNum, void* clientData)
{
char str[128];
char fontname[100];
// get word text
PDWordGetString(pdWord, str, sizeof(str));
// get the font name
PDStyle style = PDWordGetNthCharStyle(wfObj, pdWord, 0);
PDFont wordFont = PDStyleGetFont(style);
PDFontGetName(wordFont, fontname, sizeof(fontname));
printf("%s [%s]\n", str, fontname);
return true;
}以下是输出示例:
...
Chapter [Arial,Bold]
2: [Arial,Bold]
Overview [Arial,Bold]
27 [Arial]
...
This [TimesNewRoman]
book [TimesNewRoman]
describes [TimesNewRoman]
the [TimesNewRoman]
Portable [TimesNewRoman]
Document [TimesNewRoman]
Format [TimesNewRoman]
...https://stackoverflow.com/questions/51994734
复制相似问题