Skip to content

Instantly share code, notes, and snippets.

@xixilive
Created June 21, 2024 05:01
Show Gist options
  • Save xixilive/f16207f5dddd1f77bcdf24a5aff81b22 to your computer and use it in GitHub Desktop.
Save xixilive/f16207f5dddd1f77bcdf24a5aff81b22 to your computer and use it in GitHub Desktop.
PDF process

PDFCPU steps for Horizontal-to-Vertical layout:

1. split Horizontal pages;

pdfcpu split horizontal_input.pdf ./out

2. crop splitted pages;

for i in {1..N}; do pdfcpu crop -- 'pos:tl,dim:50% 100%' out/splitted_${i}.pdf out/splitted_${i}_a.pdf;done
for i in {1..N}; do pdfcpu crop -- 'pos:tr,dim:50% 100%' out/splitted_${i}.pdf out/splitted_${i}_b.pdf;done

3. merge cropped pages;

pdfcpu merge ./out/merged.pdf ./out/splitted*.pdf

Compress PDF

docker run --rm -v pwd:/app -w /app minidocks/ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -dColorImageResolution=150 -sOutputFile=output.pdf input.pdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment