【发布时间】:2020-05-13 13:17:40
【问题描述】:
我尝试在 pdf 文件中添加裁剪标记。但裁剪标记未设置在右侧或右侧角落的顶部。我尝试通过 postscript 获取页面大小并设置标记,但我的 postscript 获取新的页面宽度和高度并设置标记但标记位置不正确。 我的幽灵命令是:- gswin64c.exe -o E:\output.pdf -dBATCH -dNOPAUSE -dDOPDFMARKS -sDEVICE=pdfwrite -dFIXEDMEDIA -dPDFFitPage -dDEVICEWIDTHPOINTS=396 -dDEVICEHEIGHTPOINTS=612 test.ps -f E:\comic.pdf
inout 或输出文件链接 Input PDF Output PDF
我的裁剪标记后记是
<<
/BeginPage {
/count exch def % of previous showpage calls for this device
} bind
/EndPage {
/pagewidth currentpagedevice /PageSize get 0 get def
/pageheight currentpagedevice /PageSize get 1 get def
/y pageheight 9 sub def
/x pagewidth 9 sub def
newpath
-1 -1 moveto
0 9 rlineto
10 0 rlineto
0 -10 rlineto
-10 0 rlineto
closepath
gsave
grestore
1 setlinewidth
stroke
newpath
x -1 moveto
0 9 rlineto
10 0 rlineto
0 -10 rlineto
-10 0 rlineto
closepath
gsave
1 setlinewidth
grestore
stroke
newpath
x y moveto
0 10 rlineto
10 0 rlineto
0 -10 rlineto
-10 0 rlineto
closepath
gsave
grestore
1 setlinewidth
stroke
newpath
-1 y moveto
0 10 rlineto
10 0 rlineto
0 -10 rlineto
-10 0 rlineto
closepath
gsave
grestore
1 setlinewidth
stroke
% return (output=) true only for showpage.
code 0 eq
}
>> setpagedevice
【问题讨论】:
-
您有什么要求?有很多pdf文件可以转换吗?初始大小是否总是相同的 496x756?最终尺寸是否始终为 396x612?您的命令行始终将解释器设置为创建 396x612 输出,因此不关心输入大小,因此忽略信息。这些示例在将原始页面实际调整为新的 PageSize 之前将裁剪标记放在页面上,这显然必须在 EndPage 完成之后。我发现一个两步蒸馏过程首先放置裁剪标记,然后调整页面大小。这对您的目的有用吗?
标签: shell pdf ghostscript postscript