如何找到” pdf页来源对于现有页面...?
嗨,我正在尝试找到页面的原点IE x和y坐标。是否有任何代码示例“使用PDFBox”,并且理论将有助于在PDF中找到页面的来源。
通过说我的意思是,我们需要找到起源是 左下? 右下方? 右上角? 左上角?或中间页面?
Hi I am trying to find the origin i.e x and y coordinates of a page is there any code examples "Using PDFBOX" and also theory that will help to find the origin of the page in the PDF.
By saying that i mean , we need to find wether the origin is
left bottom? right bottom? right top? left top ? or from the middle of the page ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我认为我们是在谈论用户空间坐标,而不是设备空间坐标。当渲染PDF时,坐标最终被转换为渲染目标的设备空间。但是设备空间坐标是设备依赖性的,因此,并不真正适合通用PDF处理任务。
页面的默认用户空间坐标系统
默认用户空间坐标系统特别用于定位注释,是初始的用户空间坐标系统开始处理页面内容流的指令。
该坐标系由页面的有效裁剪框指定(默认为媒体框):
(ISO 32000-2,第8.3.2.3节“用户空间”)
因此,即使在不考虑页面旋转的情况下,该原点也可以在内部,边缘或可见页面外部的任何地方,例如对于以下 cropbox 值:
[0 0 612 792]
- 左下中的原点[0 -792 612 0]
- 原始左上[-306 -396 306 396]
- 页面中心[-1612 1000 -1000 1792]
- 右页面的原点>如果您还考虑了页面旋转,其来源随页面旋转:
(ISO 32000-2,表31“页面对象中的条目”),
例如,对于裁剪框
[0 0 612 792]
for以下 rotate /strong>值:0
- 左下90
- 左上方180
- 原点 - 右下方和裁切盒
270
- 右侧和更高页当然,坐标轴更改的指示匹配旋转:
0
- x 坐标会增加右侧, y 向上坐标90
- x 坐标向下增加, y 坐标到右180
- x 坐标增加到左, y 向下坐标270
- x 坐标向上增加, y 坐标在左侧,当前用户空间 在处理页面内容流的指令时,页面的坐标系
可能会随着用户空间的转换,尤其是 cm 指令:
(ISO 32000-2,表56“图形状态运算符”)
一个用例是在旋转后将当前的坐标系“右侧向上”。
例如,对于裁切框
[0 0 612 792]
和页面旋转90
,坐标系统起源于左上方, x 坐标向下增加, y 坐标向右增加。要弄清此问题,您通常会在页面内容流的开头时找到这样的 cm 指令:在此说明之后,我们示例中旋转页面上的来源再次在左下方, x 坐标增加到右侧, y 向上坐标。
First of all, I assume we are talking about user space coordinates, not device space coordinates. When rendering a PDF, coordinates eventually are translated to the device space of the rendering target. But device space coordinates are device dependent and, therefore, not really appropriate for generic PDF processing tasks.
The default user space coordinate system of a page
The default user space coordinate system is in particular used for positioning annotations and is the initial user space coordinate system when starting to process the instructions of the page content stream.
This coordinate system is specified by the effective crop box of the page (which defaults to its media box):
(ISO 32000-2, section 8.3.2.3 "User space")
Thus, even without considering the page rotation, the origin may be anywhere inside, on the edge, or outside the visible page area, e.g. for the following CropBox values:
[ 0 0 612 792 ]
- origin in the lower left[ 0 -792 612 0 ]
- origin in the upper left[ -306 -396 306 396 ]
- origin in the center of the page[ -1612 1000 -1000 1792 ]
- origin off page to the right and belowIf you also take page rotation into account, the origin rotates with the page:
(ISO 32000-2, Table 31 "Entries in a page object")
So e.g. for the crop box
[ 0 0 612 792 ]
for the following Rotate values:0
- origin in the lower left90
- origin in the upper left180
- origin in the upper right270
- origin in the lower rightand for the crop box
[ -1612 1000 -1000 1792 ]
:0
- origin off page to the right and below90
- origin off page to the left and below180
- origin off page to the left and above270
- origin off page to the right and aboveOf course also the directions of the coordinate axis change matching the rotation:
0
- x coordinates increase to the right, y coordinates upwards90
- x coordinates increase downwards, y coordinates to the right180
- x coordinates increase to the left, y coordinates downwards270
- x coordinates increase upwards, y coordinates to the leftThe current user space coordinate system of a page
While processing the instructions of a page content stream, the user space may be transformed along, in particular by the cm instruction:
(ISO 32000-2, Table 56 "Graphics state operators")
One use case for this is to have the current coordinate system "the right side up" after rotation.
For example for the crop box
[ 0 0 612 792 ]
and the page rotation90
, the coordinate system has its origin in the upper left, x coordinates increase downwards, and y coordinates increase to the right. To straighten this out, you'll often find a cm instruction like this at the start of the page content stream:After this instruction the origin on the rotated page in our example is again in the lower left, and x coordinates increase to the right and y coordinates upwards.