我知道表格文本提取并不是每个人都喜欢的。但是,在阅读有关表的 PDF Stream 数据时,有些事情我不明白。
表格的PDF代码流是:
q % Graphic State Starting Point
0 292.5 595.3 442.8 re % Rectangle x y Width Height
W* % Clipping Even Odd Rule
n % End without Filling
0 0 0 rg % Color of Stroke
161 735 m % Move to New Path
160.8 734.7 l 89.3 734.7 l 89 735 l 88.8 735.3 l 161.3 735.3 l
161 735 l % straight line
h % Close the Current Path
f* % Fill Path with Even Odd Rule
Q
下划线是:
q % Graphic State Starting Point
1 0 0 1 451.5 759.5 cm % Current matrix
0.5 w % Width of Stroke
0 0 0 RG % color
0 -0.8 m % Move to New Path
72 -0.8 l % Straight Line
S % Stroke Line
Q % End of Graphic State
在下划线中,m
修改 cm
并将其设置为 451.5 759.5,并从当前点(即 451.5)绘制直线到 72 点(即 493.5),小于 0.8到 cm
,即 759.5
我现在不明白,表格线是如何从哪一点绘制到哪一点的。
最佳答案
考虑线条绘制部分,其中 m
是移动到运算符,l
是行到:
% command coordinates
% =====================
161 735 m % Move-to a(161, 735)
160.8 734.7 l % line-to b(161, 735 -.3)
89.3 734.7 l % line-to c(90, 735 -.3)
89 735 l % line-to d(90, 735)
88.8 735.3 l % line-to e(90, 735 +.3)
161.3 735.3 l % line to f(161, 735 +.3)
161 735 l % line to g(161, 735)
h % close-path
f % fill
(x
在 160 和 89 左右有一些奇怪的微小变化,这些变化太小而无法在视觉上记录 - 渲染怪癖?)。
[在非常高分辨率的情况下,线条末尾会有箭头
<============ ... =======>
]
除此之外,它还绘制了一个非常薄的带角长框 (89, 734,7)
、(161, 734.7)
、(161, 735.3 )
和 (89, 735.3)
。 y 轴上 +/- ).3 点的影响最有可能给出稍微加粗的线条而不是矩形的效果。
关于PDF表格文本提取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32444186/