Merge Multiple Pdfs Into One

PHOTO EMBED

Tue Jan 10 2023 07:12:49 GMT+0000 (Coordinated Universal Time)

Saved by @HristoT

======================================= Ghost Script =======================================

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dAutoRotatePages=/None -sOutputFile=gs.pdf  1.pdf 2.pdf

#gs         starts the Ghostscript program.

#-dBATCH    once Ghostscript processes the PDF files, it should exit.
#           If you don't include this option, Ghostscript will just keep running.

#-dNOPAUSE  forces Ghostscript to process each page without pausing for user interaction.

#-q         stops Ghostscript from displaying messages while it works

#-sDEVICE=pdfwrite 
#           tells Ghostscript to use its built-in PDF writer to process the files.

#-sOutputFile=finished.pdf
#           tells Ghostscript to save the combined PDF file with the specified name.

#-dAutoRotatePages=/None
#           Acrobat Distiller parameter AutoRotatePages controls the automatic orientation selection algorithm: For instance: -dAutoRotatePages=/None or /All or /PageByPage.

======================================= Ghost Script =======================================




======================================= Библиотека =======================================

# Проверяваме дали имаме инсталирана библиотеката:
convert -version

# Инсталиране на библиотеката
apt-get update
apt install imagemagick

# Събиране на pdf-и
	#Размери:
	#1.pdf -> 104KB
	#2.pdf -> 212KB

# Команди:
#convert -density 200 1.pdf 2.pdf MergedFile.pdf                                    # -> 6 134KB (най-високо качество)
convert -compress Zip -density 150x150 1.pdf 2.pdf MergedFile_zip.pdf               # -> 1 113KB
#convert -density 150 -quality 60 -compress jpeg 1.pdf 2.pdf MergedFile_d150.pdf    # -> 3 724KB

===================================================================================================
# Ако се появи следната грешка:
convert-im6.q16: not authorized `1.pdf' @ error/constitute.c/ReadImage/412.
convert-im6.q16: not authorized `2.pdf' @ error/constitute.c/ReadImage/412.
convert-im6.q16: no images defined `MergedFile.pdf' @ error/convert.c/ConvertImageCommand/3258.

# Трябва да променим конфигурационния файл
nano /etc/ImageMagick-6/policy.xml

# Намираме реда някъде най-отдолу:
	<policy domain="coder" rights="none" pattern="PDF" />
# Променяме правата на "read|write":
	<policy domain="coder" rights="read|write" pattern="PDF" />

======================================= Библиотека =======================================
content_copyCOPY