计算pdf中(Td,TD,Tm,cm,T*)内容流的确切位置?

2024-02-12

获取或计算 pdf 中(Td、TD、Tm、cm、T*)内容流的确切位置?

作为一个人,我能够通过比较字形在pdf和内容流位置值中的位置来计算(无论是替换最后一个Td还是添加到最后一个Td或与fontsize相乘)pdf内容流中标签的位置。但我无法以编程方式计算字形的完美位置。请看屏幕短。

在上图中,左侧框是 pdf ui 字形,右侧框包含相关内容流。在内容流中,我突出显示了两个 Td 位置。

在第一个圈子里

3.321 -6.475999832 TD

Td 头寸应添加到最后的 Td 头寸中。假设x1,y1。

Current_x_pos = x1+3.321

当前_y_位置 = y1-6.475999832

然后我们就可以得到字形“t”的确切位置。

在第二个突出显示的圆圈中,新的 Td 位置 (231.544 366.377990 Td) 被完全替换,如下所示

当前_x_位置 = 231.544

当前_y_位置 = 366.377990

除此之外,有时父标签是 Tm 在这种情况下,公式可能是这样的

Current_x_pos = x1+(tdx1*font_size)

Current_y_pos = y1+(tdy1*font_size)

当我们需要像上面那样进行乘法时,有时还需要加法。以编程方式我怎么能知道这一点。解析准确的位置?(为乘法添加了新的屏幕简短内容)

Any help ? Thanks. enter image description here enter image description here


当我们需要像上面那样进行乘法时,有时还需要加法。以编程方式我怎么能知道这一点。解析准确的位置?

这很简单,对于一个Td操作你always相乘,请参阅 ISO 32000-1 规范(ISO 32000-2 中类似):

For a freshly initialized (i.e. identity) text line matrix Tlm this matrix multiplication looks like replacing its bottom row with tx ty 1.

For a text line matrix Tlm with only changes in the bottom row against an identity this matrix multiplication looks like an addition to the bottom row, e.g. x y 1 becomes x+tx y+ty 1.

For a text line matrix Tlm like in your second example

a 0 0
0 a 0
x y 1

this matrix multiplication looks like a multiplication with a followed by an addition to the bottom row, i.e. x y 1 becomes x+a·tx y+a·ty 1. If the font size parameter of the preceding Tf operation was 1, then a would effectively be the resultant font size giving rise to your assumption the font size is part of the formula.

In general, for an arbitrary, non-degenerate text line matrix Tlm

a b 0
c d 0
x y 1

this matrix multiplication looks even more complex, x y 1 becomes x+a·tx+c·ty y+b·tx+d·ty 1.

因此,关于你的问题

以编程方式我怎么能知道这一点。解析准确的位置?

你的程序应该只是总是使用矩阵乘法并忽略它在单独坐标层面上的样子。


使第二个圆圈指令看起来只是替换的原因是先前的文本行矩阵是单位矩阵。但这并不是由于 François 假设的恢复状态操作,而是更简单地由于文本对象操作的开始BT:

由于文本矩阵和文本行矩阵在文本对象开始时被重置,并且图形状态无法在文本对象中保存或恢复,因此在这种情况下不能归咎于保存和恢复图形状态操作。

(屏幕截图来自 Adob​​e 共享的 ISO 32000-1 副本。)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

计算pdf中(Td,TD,Tm,cm,T*)内容流的确切位置? 的相关文章