Based on Kurt-Pfeifl's answer to the code using a unix-like shell (I also saved the line for libreoffice):
FileBaseName="ExampleDoc_A5_Landscape" # required packages: gs, pdftk, coreutils:mktemp libreoffice --headless --nodefault --convert-to pdf "${FileBaseName}.odt" temp_pdf_dir=$(mktemp -d) a4_page1="${temp_pdf_dir}/1.pdf" a4_page2="${temp_pdf_dir}/2.pdf" pdftk "${FileBaseName}.pdf" cat 1south output - | gs -o "${a4_page1}" -sDEVICE=pdfwrite -sPAPERSIZE=a4 -dFIXEDMEDIA -dPDFFitPage - pdftk "${a4_page1}" cat 1north output "${a4_page2}" pdftk "${a4_page1}" background "${a4_page2}" output "${FileBaseName}-A4.pdf" rm -rf "${temp_pdf_dir}"
Note that fonts embedded in the source document will be doubled in the final PDF.
This procedure creates a mirror alignment, so A4 printed paper can be cut in the middle, and both A5 pages will have this cut edge at the bottom.
Geck0
source share