了解PDF运算符 - 适用于iOS应用 [英] Understanding PDF operators - for iOS app

查看:154
本文介绍了了解PDF运算符 - 适用于iOS应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是为我们公司创建一个pdf阅读器应用程序。经过一些研究后,我对PDF中的不同操作符感到困惑。以下是我想澄清的一些事项:

I am tasked to create a pdf reader app for our company. After a few research, I became confused with the different operators inside the PDF. Here are a few things that I would like to clarify:


  • Tm 运算符用作每一行的起点。 (我的理解是否正确?)

  • 如果 Tm 运算符是每一行的起点,我该如何解析在指定的 Tm 中显示的文字?例如:

  • The Tm operator is used as the starting point of each line. (Is my understanding correct?)
  • If the Tm operator is the starting point of every line, how can I parse the text shown only within the specified Tm? e.g.:

 BT
    0 0 1 rg
    /Ti 12 Tf
    1 0 0 1 100 100 Tm
    0 0 Td
    (The quick brown fox ) Tj 0 −13 Td
    (ate the lazy mouse.) Tj
 ET
 //I only want to get the Tj and TJ string being positioned by the Tm


  • 我明白每一个1000个单位的字形高度和宽度相当于1个单位的文本空间。因此,如果字形宽度为2000且高度为1060,那是否意味着它的实际宽度和高度分别为2和1.06?

  • I understand that every 1000 units of a glyph's height and width is equivalent to 1 unit of text space. So if the glyph width is 2000 and it's height is 1060, does that mean that the "real" width and height of it is 2 and 1.06 respectively?

    现在我知道其中一些问题完全是愚蠢的,但我真的没有太多时间去研究。因此,如果有人可以帮助我理解这一点,那将非常感激。

    Now I know that some of these questions sound outright stupid, but I really don't have much time to research. So if anyone can help me understand this, it will be definitely appreciated.

    注意:pdf阅读器应用程序必须包含搜索和突出显示功能,文本选择,笔记,书签等。几乎每个读者都可以找到几乎所有基本的东西。我可能会使用第三方库来使我的生活更轻松,但我最大的问题是文本选择功能。所以我真的需要理解这一点。

    NOTE: The pdf reader app must contain search and highlight function, text selection, notes, bookmark, etc. Practically all the basic stuff you can find in almost every reader available nowadays. I will probably use a third-party library for this to make my life easier, but my biggest problem will be the Text selection function. So I really need to understand this.

    推荐答案

    你需要熟悉 PDF规范,附件A包含所有运营商的摘要链接到有关参数的更详细文档,这可能是一个很好的起点。

    You'll need to familiarize yourself with the PDF specification, the annex A contains a summary of all the operators with links to more detailed documentation about the parameters, so that may be a good starting point.

    Tm 运算符不不一定要设置每一行的起点,它通常设置文本矩阵,基本上相当于Quartz2D的 CGAffineTransform 。要移至下一行,文档还可以使用 Td TD T * 运算符.PDF文档不一定按照屏幕上显示的顺序绘制文本,它们可以在页面上自由移动并按照他们认为合适的任何顺序定位字形.PDF实际上没有线的概念,你必须自己从字形的位置推断出这些(这对于像下标/上标这样的事情来说可能很棘手) )。

    The Tm operator doesn't necessarily set the starting point of each line, it generally sets the text matrix, which is basically equivalent to a CGAffineTransform in terms of Quartz2D. To move to the next line, a document could also use the Td, TD, " or T* operators. PDF documents don't necessarily draw their text in the order that appears on screen, they may move around on the page freely and position the glyphs in any order they see fit. PDF doesn't really have the concept of a "line", you'll have to infer those from the position of the glyphs yourself (which can be tricky for things like subscript/superscript).

    这篇关于了解PDF运算符 - 适用于iOS应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆