问题描述
我不是程序员,但想学习如何使用Ghostscript裁剪PDF.
I am not a programmer, but would like to learn how to crop a PDF using Ghostscript.
我已经在计算机上安装了Ghostscript 9.01.
I have installed Ghostscript 9.01 in my machine.
请逐步指导我(从调用Ghostscript开始)以裁剪具有特定坐标的PDF.
Please guide me step by step process (starting from invoking Ghostscript) to crop a PDF with the specific coordinates.
我什至不熟悉Ghostscript.
I am even new to Ghostscript.
推荐答案
首先,请注意,PDF的度量单位与PostScript相同:称为 point [pt].
First, take note that the measurement unit for PDF is the same as for PostScript: it's called a point [pt].
72 points == 1 inch == 25.4 millimeters
假设页面大小为A4.然后,媒体尺寸为:
Assuming you have a page size of A4. Then the media dimensions are:
595 points width == 210 millimeters
842 points height == 297 millimeters
假设您要裁剪:
left edge: 24 points == 1/3 inch ~= 8.5 millimeters
right edge: 36 points == 1/2 inch ~= 12.7 millimeters
top edge: 48 points == 2/3 inch ~= 17.0 millimeters
bottom edge: 72 points == 1 inch ~= 25.4 millimeters
然后您的Ghostscript命令行是这样的(在Windows上):
Then your Ghostscript commandline is this (on Windows):
gswin32c.exe ^
-o cropped.pdf ^
-sDEVICE=pdfwrite ^
-c "[/CropBox [24 72 559 794]" ^
-c " /PAGES pdfmark" ^
-f uncropped-input.pdf
或在Linux上:
gs \
-o cropped.pdf \
-sDEVICE=pdfwrite \
-c "[/CropBox [24 72 559 794]" \
-c " /PAGES pdfmark" \
-f uncropped-input.pdf
但是,这可能不适用于所有类型的PDF .在这种情况下,您还可以尝试以下命令:
However, this may not work reliably for all types of PDFs . In those cases you should alternatively try these commands:
gswin32c.exe ^
-o cropped.pdf ^
-sDEVICE=pdfwrite ^
-dDEVICEWIDTHPOINTS=595 ^
-dDEVICEHEIGHTPOINTS=842 ^
-dFIXEDMEDIA ^
-c "24 72 translate" ^
-c " 0 0 535 722 rectclip" ^
-f uncropped-input.pdf
或
gs \
-o cropped.pdf \
-sDEVICE=pdfwrite \
-dDEVICEWIDTHPOINTS=595 \
-dDEVICEHEIGHTPOINTS=842 \
-dFIXEDMEDIA \
-c "24 72 translate" \
-c " 0 0 535 722 rectclip" \
-f uncropped-input.pdf
[^] :
[^] :
这篇关于使用Ghostscript 9.01裁剪PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!