![有沒有一個Linux工具可以自動裁切PDF檔案中的白邊距](https://rvso.com/image/1605174/%E6%9C%89%E6%B2%92%E6%9C%89%E4%B8%80%E5%80%8BLinux%E5%B7%A5%E5%85%B7%E5%8F%AF%E4%BB%A5%E8%87%AA%E5%8B%95%E8%A3%81%E5%88%87PDF%E6%AA%94%E6%A1%88%E4%B8%AD%E7%9A%84%E7%99%BD%E9%82%8A%E8%B7%9D.png)
我有一個 PDF 文件,我想盡可能地修剪周圍的所有空白。它必須自動檢測並執行此操作。
我使用福昕閱讀器,它可以選擇在查看時自動裁剪頁面。
但我正在尋找 Linux 中的命令列解決方案。
我試過PDF裁剪但它會統一裁剪所有頁面。我希望它使用以下命令根據每個單獨頁面周圍的空白進行裁剪:
pdfcrop input.pdf output.pdf
但它只能部分工作,有些頁面被裁剪,有些則沒有。
答案1
消除邊距的最佳方法是使用pdfCropMargins
安裝:
pip install pdfCropMargins --upgrade
現在我們可以使用指令pdf-crop-margins
按照我們想要的方式裁剪pdf
我想裁剪所有頁面,然後在周圍添加 6bp 的邊距。我可以這樣做
pdf-crop-margins -v -p 0 -a -6 input.pdf
-v : Verbose
-p : how much percentage of margin to be retained. We want the bounding box triming all the white margins on all sides. So say 0%
-a : Note: first -p is applied to create a bounding box.
IN this option it applies further on the bounding box after -p is applied. we can remove or add margin. Negative means add margin to the bounding box. So it will add 10bp all around after cliping
輸出文件附有_cropped
我還檢查了裁剪後的文件,所有內容和連結都完好無損。