有沒有一個Linux工具可以自動裁切PDF檔案中的白邊距

有沒有一個Linux工具可以自動裁切PDF檔案中的白邊距

我有一個 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

我還檢查了裁剪後的文件,所有內容和連結都完好無損。

相關內容