使用PDFTK或类似格式合并时,向PDF文件添加边距 [英] Add margin to PDF file when merging using PDFTK or similar

查看:105
本文介绍了使用PDFTK或类似格式合并时,向PDF文件添加边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多半页大小的PDF剪切纸,它们都存放在Linux服务器上的文件夹中.该网站的用户希望从其中的子集创建一本小册子.小册子将被装订,因此,集合的偶数页将在右侧需要更多页边距,奇数页将在左侧需要更多页边距.在500页的整个范围中,一个集合中最多可以包含200页,因此我不想重新生成每一页来设置页边距.通过DOMPDF运行内容将花费太多服务器时间.只需使用PDFTK构建文档即可.

I have a large collection of half-page sized PDF cut-sheets that are held in a folder on my Linux server. A user to the site will want to create a booklet from a subset of these. The booklet will be bound therefore the even pages of the collection will want more margin on the right side and the odd pages will want more margin on the left side. There can be up to 200 pages in a collection out of a universe of 500 pages so I don't want to regenerate each page to set the margin of it. It would take too much of the servers time to run the content through the DOMPDF. Just building the document using PDFTK is fast.

我想从一个居中的PDF文件中将文档与PDFTK合并,并为奇数页或偶数页添加适当的页边距.

I'd like to merge the document with PDFTK from a centered PDF file and add the appropriate margin for the odd or even page.

如果不是PDFTK,那么还有另一种工具可以完成这项工作吗?

If not PDFTK then is there another tool that might do the job?

推荐答案

如果使用ubuntu,则可以安装pdfcrop:

If you use ubuntu, you can install pdfcrop:

sudo apt-get install -y pdfcrop

尽管其名称,pdfcrop仍可以选择添加边距:

Despite its name, pdfcrop has the option to add margins:

pdfcrop --margin '29 0 29 0' input.pdf output.pdf

(注意:单位为bp.72bp = 1英寸.29bp约为1厘米.)

(Note: the unit is bp. 72 bp = 1 inch. 29 bp is approximately 1 cm.)

然后,使用pdfjam进行左右页面的偏移技巧.

Then, use pdfjam to do the offset trick for the right and left pages.

pdfjam --twoside --offset '1cm 0cm' file.pdf

注意:pdfcrop的某些pdf文件确实存在问题. (!!!错误:Ghostscript退出,错误代码为139!).

Note: pdfcrop does have problems with some pdf files. (!!! Error: Ghostscript exited with error code 139!).

这篇关于使用PDFTK或类似格式合并时,向PDF文件添加边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆