【问题标题】:How do i decode text of a pdf file using python我如何使用python解码pdf文件的文本
【发布时间】:2023-02-04 08:00:21
【问题描述】:

我一直在尝试使用 python 解码 pdf 文件,数据如下: 英国电信 /F2 8.8 Tf 1 0 0 1 36.85 738.3 吨米 0克 0克 [(A)31(c)-44(c)-44(o)-79(u)11(n)-79(t)5( )] TJ 外星人

我怎么理解这个???

[(A)31(c)-44(c)-44(o)-79(u)11(n)-79(t)5( )]是什么类型的???

【问题讨论】:

  • “我怎么理解这个???”- 阅读 pdf 规范怎么样?那将是 ISO 32000。旧的第 1 部分的副本,ISO 32000-1,可以在 Adobe.com/go/pdfreference 下载
  • (A)31(c)-44(c)-44(o)-79(u)11(n)-79(t)5( ) 是什么类型???
  • 它是包含字符串和数字的数组的内容。
  • 是编码的吗??
  • “那是编码的??”- 你是什么意思?它是 PDF 对象的完全正常语法。这实际上是一个相当简单的示例,因为字符串的编码看起来类似于 ASCII。

标签: string pdf text encoding decoding


【解决方案1】:

BT /F2 8.8 Tf 1 0 0 1 36.85 738.3 Tm 0 g 0 G [(A)31(c)-44(c)-44(o)-79(u)11(n)-79(t)5( )] TJ ET

是普通的纯 ASCII 文本,因此每天都会将二进制解码为文本。

你的问题是
问)我怎么理解这个??? [(A)31(c)-44(c)-44(o)-79(u)11(n)-79(t)5( )]

一种)始终查看上下文

BT  = B(egin) T(ext)
/F2 = use F(ont) 2 for encoding (whatever that is)
8.8 = units of height (if un-modified those could be 8.8 full unscaled DTP points, 
      but beware, point size does not necessarily correspond to any measurement
      of the size of the letters on the printed page.)
... Mainly T(ransform )m(atrix) e.g. placement
[   = start a string group
(A) = literal(y) "A"
31  = Kern next character (+ is usually) left wise by 31 units where units (is usually) 1/1440 inch or 17.639 µm
(c) = the next glyph literal that needs to be etched on screen or paper
-44 is push the two x (c) apart by 44 units
(c)
...
] Tj ET  = Close Group, T(exte)j(ect) E(nd) T(ext)

所以我们在页面上的某个地方(第一个或最后一个单词或两者之间的任何时间)都有它,但在那个时候的某个地方,很可能是左上角,有一个连续的可选纯文本字符串,在视觉和听觉上听起来/看起来像一个单词一种人类语言=“帐户”,带有额外的空格键文字(这实际上对于PDF来说是不必要的,它会打印那个和任何其他“单词”就足够了没有一个。)

【讨论】:

    猜你喜欢
    • 2016-12-14
    • 2020-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-04
    • 2020-08-23
    相关资源
    最近更新 更多