Resize many PDFs

限于喜欢 提交于 2019-12-22 09:35:13

问题


I have many (around 1000) multiple-page PDFs for a program I am writing.

The problem is that many of them are inconsistent about page size, even within the same document at times. Does anyone know of a way I could programmatically go through the files and resize the pages to what I want? This can be in any language.

I can accomplish this in Adobe Acrobat Pro, but there are so many that would end up taking a long, long time. The only way I can get it to resize there is to add a background from a file, and then choosing the file i want to resize.


回答1:


Generally, PDFtk is a good fit for this kind of problems. It will let you pull everything apart, and reorder/resize/modify pages on the command line.




回答2:


I had a similar problem and could easily solve it with PDF split and merge, a Java based toolkit for editing PDF files.




回答3:


You can resize a PDF with a command line tool, Ghostscript.

Assuming you want to resize a PDF to 306x396 points (which would give you a quarter of a letter sized pages), do it like this:

gs                     \
 -o 306x396-points.pdf \
 -sDEVICE=pdfwrite     \
 -g3060x3960           \
 -dPDFFitPage          \
 -dUseCropBox          \
  input.pdf

Note that the -g.... dimensions are in pixels. Because Ghostscript internally computes with 720 PPI by default, these are increased by a factor of 10 as compared to the sizes in points.

For Windows, use gswin32c.exe or gswin64c.exe instead of gs.



来源:https://stackoverflow.com/questions/17306509/resize-many-pdfs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!