Pdf.js: 使用 ctrl+f 搜索不适用于两个词

创建于 2018-05-17  ·  4评论  ·  资料来源: mozilla/pdf.js

在此处附加(推荐)或链接到 PDF 文件:
dee752ed0f726d8785abf360ca783d91f96f9a2e.pdf

配置:

  • 网络浏览器及其版本:Firefox 60/Chromium 66
  • 操作系统及其版本:Linux/Windows 7
  • PDF.js 版本:v1.10.88 或 v1.9.426 或 Firefox 60 内置版本

重现问题的步骤:

  1. 按 ctrl+f 并搜索“先锋”
  2. Pioneer 将突出显示,但只要您输入空格,就找不到任何结果

pdftotext 显示正确的文本:

in nit ris hington 1D C
boerge W lacan a pioneer of butali
and an influential man aw at richfield last walk

它适用于 chrome 的内置 PDF 查看器,因此它不是 pdf 的问题。

链接到查看器(如果托管在 mozilla.github.io/pdf.js 或作为 Firefox/Chrome 扩展程序以外的站点上):
https://newspapers.lib.utah.edu/pdfjs1.9/web/viewer.html?file=/udn_files/de/e7/dee752ed0f726d8785abf360ca783d91f96f9a2e.pdf

4-text-selection

最有用的评论

我很想从事这方面的工作,
@timvandermeij请帮助我,在处理这个问题时从哪里开始

所有4条评论

我很想从事这方面的工作,
@timvandermeij请帮助我,在处理这个问题时从哪里开始

我建议首先检查我们在文本层中的内容,因为这可以解释为什么搜索不起作用。 我的猜测是空间因素不正确; 见: https :

这很可能也是许多其他开放文本选择问题的原因。 但是,更改其他 PDF 文件的值可能容易出错,并且需要进行良好的测试。 我们可能需要检查其他开源 PDF 查看器(例如 Poppler)是如何做到这一点的,因为问题在于 PDF 规范没有指明何时必须使用空格进行文本选择。 它只定义了字符之间的间距宽度。

不幸的是, https: //github.com/mozilla/pdf.js/issues/9736#issuecomment -390629834 在这里无济于事,因为这是一个扫描文件,其中每个单词都以不同的字体大小和 x/y 坐标单独定位; 参见例如/Contents流的开头:

1 G
1 g
1 0 0 1 52 1145.37 Tm
/F1 11 Tf
(UTAH)Tj
1 0 0 1 90 1146.36 Tm
/F1 11 Tf
(NEWS)Tj
1 0 0 1 29 1124.14 Tm
/F1 10 Tf
(the)Tj
1 0 0 1 44 1126.03 Tm
/F1 8 Tf
(oregon)Tj
1 0 0 1 71 1124.47 Tm
/F1 9 Tf
(short)Tj
1 0 0 1 92 1125.47 Tm
/F1 9 Tf
(line)Tj

...

大家好,我确定您知道其他 PDF 渲染项目也受到此影响。 我目前正在使用一个 web 应用程序 (Nextcloud),它使用 pdf.js 作为其浏览器应用程序的 PDF 渲染器。

这是我在其他实用程序上使用过的文件示例。 这是飞机自动驾驶仪服务手册的扫描摘录,最初是在 1970 年代印在未知设备上的。

CenturyIIB-origscan.pdf
CenturyIIB-tesseract_hocr-uncleaned.pdf
CenturyIIB-tesseract_hocr-cleaned.pdf

第一个文件是没有文本层的原始扫描件。 第二个(hocr-uncleaned)是已经用Tesseract (v4.0) 处理以创建隐藏文本层的 PDF/A。 第三个(hocr-uncleaned)已经用unpaper (v6.1)去歪斜,然后用相同版本的 Tesseract 进行 OCR 处理,并输出为 PDF/A。 在这两种 PDF/A 情况下,原始扫描已被转码为 300 dpi jpeg 以用于最终输出。

在第二种和第三种情况下,带有 Tesseract 的 'hocr' 渲染选项用于 OCR 渲染阶段(Tesseract 有多个内部渲染器)。 如果您查看 github 上 Tesseract 的问题论坛,您会发现他们对最近的渲染器进行了一些更改,以尝试解决此问题。

以下是从各种实用程序中复制/粘贴的一些摘录...

Safari 11.1 (13605.1.33.1.4) 上的 hocr-unlceaned

The Century IIB Autopilot is an "Open Loop" system which responds only to the dynamics of the aircraft in flight, thus the only ground checks that can be accomplished are functional checks as described in this bulletin.

Chrome 66.0.3359.181 上的 hocr-uncleaned

The Century IIB Autopilot is an "Open Loop" system which responds only to the dynamics of the aircraft in flight, thus the only ground checks that can be accomplished are functional checks as described in this bulletin.

Adobe Acrobat Pro X 上的 hocr-uncleaned

The Century IIB Autopilot is an "Open Loop" system which responds only to the
dynamics of the aircraft in flight, thus the only ground checks that can be
accomplished are functional checks as described in this bulletin.

pdf.js 上的 hocr-uncleaned (Firefox 60.0.1)

Century
IIB
Autopilot
is
an
"Open Loop"
system
which
responds
only
to
the
dynamics
of
the
aircraft
in
flight,
thus
the
only
ground
checks
that
can
be
accomplished
are
functional
checks
as
described
in
this
bulletin.

在上面相同版本的 Safari 上进行 hocr-cleaned

The Century IIB Autopilot is an "Open Loop’ system which responds only to the dynamics of the aircraft in flight, thus the only ground checks that can be accomplished are functional checks as described in this bulletin.

在上面相同版本的 Chrome 上进行 hocr-cleaned

The Century IIB Autopilot is an "Open Loop’ system which responds only to the
dynamics of the aircraft in flight, thus the only ground checks that can be
accomplished are functional checks as described in this bulletin. 

在上面相同版本的 Adob​​e Acrobat Pro 上进行 hocr-cleaned

The Century IIB Autopilot is an "Open Loop’ system which responds only to the
dynamics of the aircraft in flight, thus the only ground checks that can be
accomplished are functional checks as described in this bulletin.

在上面相同版本的 pdf.js (Firefox) 上进行 hocr-cleaned

Century 
IIB 
Autopilot 
is 
an 
"Open 
Loop’ 
system 
which 
responds 
only 
to 
the 
dynamics 
of 
the 
aircraft 
in 
flight, 
thus 
the 
only 
ground 
checks 
that 
can 
be 
accomplished 
are 
functional 
checks 
as 
described 
in 
this 
bulletin. 

对于可能想要为其他示例文件(主要/_depedency_)重现我的工具链的任何人...

tesseract 4.00.00alpha (用于OCR)
_leptonica 1.76.0
libjpeg-turbo 1.5.3
libpng 1.6.34+apng
libtiff 4.0.9_

unpaper 6.1 (用于去歪斜、去噪等)
_libav 12.1
opencv 2.4.13.1
freetype2 2.8_

qpdf 8.0.1 (用于检查/修改/创建pdf)
_ghostscript 9.16_

OCRmyPDF 6.2.0 (上述实用程序的python v3包装器)

以上所有内容几乎都在任何常见的 Linux 包存储库中,OCRmyPDF 在 pip 中,并且所有这些的现代版本都在 OSX 的 Homebrew 中(tesseract 必须标记到它们的 git HEAD,因为 v4.0 仍然标记为测试版) . 我还在 FreeBSD 上运行了它们(必须从源代码构建 Tesseract、Leptonica 和 unpaper)。 在我看来,Tesseract/Leptonica 是用于制作此类测试文件的很好的基线。 他们使开源 OCR 突飞猛进。 是一个来自 18 世纪文档扫描的示例,尽管不知道“长 S”是什么并将它们转录成小写的“f”,但它甚至做了令人钦佩的工作。

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

sujit-baniya picture sujit-baniya  ·  3评论

dmisdm picture dmisdm  ·  3评论

xingxiaoyiyio picture xingxiaoyiyio  ·  3评论

aaronshaf picture aaronshaf  ·  3评论

timvandermeij picture timvandermeij  ·  4评论