我目前正在编写一个小工具(Python+pyPdf)来测试pdf的打印机一致性。在
唉,我在第一个任务中已经感到困惑:检测PDF是否至少有3mm的“出血”(页面周围没有打印内容的边框)。我已经知道我无法检测到完整文档的出血,因为似乎没有全局性的出血。但在页面上,我可以发现总共五个不同的框:
mediaBox
bleedBox
trimBox
cropBox
artBox
我读了关于这些方框的pyPdf documentation,但我唯一理解的是mediaBox
,它似乎代表了整个页面的大小(即论文)。在
很明显,bleedBox
应该来定义出血,但事实并非总是如此。在
我注意到的另一件事是,例如使用PDF,所有这些框在每一页上都有完全相同的大小(意味着根本没有出血),但是当我打开它时,会出现大量出血;这使我认为单个文本元素有其自己的偏移量。在
所以,显然,仅仅计算mediaBox
和{
如果有人能解释一下这些盒子到底是什么,以及我能从中得出什么结论(例如,一个盒子总是比另一个盒子小),我会非常高兴的。
另外一个问题是:有人能告诉我在documentation中到底提到了什么“默认用户空间单元”?我很确定这是在我的机器上引用mm
,但我想在任何地方都强制执行mm
。在
引用Adobe发布的PDF规范ISO 32000-1:2008:
下面是一个很好的图形,显示了这些框之间的关系:
{1美元^
在许多情况下,只设置媒体盒的原因是
对于用于电子消费(即在计算机上阅读)的PDF,其他框几乎不重要;并且
即使在印前环境中,它们也不再像以前那样必要了,参见佩德罗在评论中提到的article。
关于你的“额外问题”:默认情况下,用户空间单位是1/72英寸;但是,由于PDF 1.6,可以使用页面字典中的UserUnit条目将其更改为该大小的任意(不需要整数)倍数。在现有PDF中更改它本质上会缩放它,因为用户空间单位是页面中与设备无关的坐标系中的基本单位。因此,除非您想更新页面描述中引用坐标的每个命令以保持页面尺寸,否则您不会希望强制使用毫米用户空间单位。。。;)
相关问题 更多 >
编程相关推荐