为什么 PDF 文本提取对于单个 PDF 会挂起但通过 RDP 工作

Why would PDF Text extraction hang for a single PDF but work via RDP

我有一个程序可以从 PDF 中提取文本。它作为计划任务在 Windows Server 2008 上运行。

我使用的库是 ByteScout 的 PDF Extractor SDK,它在底层基于 Tesseract。

自去年 11 月上线以来,该程序已成功从来自许多不同来源的 50,000 多个 PDF 中提取文本。

它最近挂在一个 PDF 上,随后挂在第二个 PDF 上,来自相同的来源,采用相同的视觉格式。

我能够使用一个简单的 12 行程序重现问题。我将此程序发送给供应商,但 运行 该程序在他们的环境中有效(不会挂起)。

所以我做了一些实验,这就是奇怪的地方。

如果我通过 RDP 访问该程序,该程序可在我的 PC (Windows 7) 上运行,但如果我直接登录则不能。此行为在我们环境中的其他 Windows 7 台 PC 上重复.

如果我使用 RDP,它可以在 Server 2008 上运行,但不能作为计划任务。

它适用于 Windows 10,无论我是 RDP 还是直接登录。

卡住的时候在Process Monitor里看程序,可以看到它在打开C:\Windows\Fonts\times.ttf一遍又一遍的读取。

如果它只使用 RDP 工作,我想知道原因是否与图形加速或类似的失败使用有关,但考虑到它不能作为计划任务工作 none 也会出现,我认为那是一条死胡同。

有没有人对下一步去哪里有任何建议?

所以 ByteScout 已经解决了这个问题。引用尤金的话...

The problem is in System.Drawing and GDI+. Sometimes it crashes on text drawing operations that are normal in PDF but causing some internal exceptions in System.Drawing. Moreover, it's behavior varies depending on display device capabilities. That is why it works in RDP session and crashes on a desktop. We are trying various workarounds on these crashes, attempting to fall back to alternate text drawing ways. The hanging is related to these fallbacks.