Ghostscript to merge PDFs compresses the result

后端 未结 3 1657
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 10:42

I found this neat command to merge multiple PDF into one, using Ghostscript:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf
<         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 11:07

    I used the following code with success on iOS terminal to compress multiple PDFs recursively. I posted it because I couldn't find something that worked for me with a simple copy and paste.

    find . -name '*.pdf' | while read pdf; do gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile="${pdf}_new.pdf" "$pdf"; done
    

    Note you may want a different output quality, sou you can change the -dPDFSETTINGS parameter as follows:

    -dPDFSETTINGS=/screen: lower quality, smaller size.
    -dPDFSETTINGS=/ebook: for better quality, but slightly larger pdfs.
    -dPDFSETTINGS=/prepress: output similar to Acrobat Distiller "Prepress Optimized" setting.
    -dPDFSETTINGS=/printer: selects output similar to the Acrobat Distiller "Print Optimized" setting.
    -dPDFSETTINGS=/default: selects output intended to be useful across a wide variety of uses, possibly at the expense of a larger output file.

提交回复
热议问题