Skip to content

Instantly share code, notes, and snippets.

@kenotron
Last active March 9, 2025 07:52
Show Gist options
  • Save kenotron/16daa06c948943649b85be518e7ae221 to your computer and use it in GitHub Desktop.
Save kenotron/16daa06c948943649b85be518e7ae221 to your computer and use it in GitHub Desktop.
ghostscript to deal with 3 hole punch margins
#!/bin/sh
gs \
-o output_duplex_ch6.pdf \
-dFirstPage=643 \
-dLastPage=726 \
-sDEVICE=pdfwrite \
-dBATCH \
-dNOPAUSE \
-dDEVICEWIDTHPOINTS=612 \
-dDEVICEHEIGHTPOINTS=792 \
-dFIXEDMEDIA \
-c "<<
/CurrPageNum 1 def
/BeginPage {
/CurrPageNum CurrPageNum 1 add def
CurrPageNum 2 mod 1 eq {
0.88235 0.88235 scale
72 36 translate
}
{
0.88235 0.88235 scale
0 36 translate
} ifelse
} bind >> setpagedevice" \
-f input.pdf
#!/bin/sh
gs \
-o output_single.pdf \
-sDEVICE=pdfwrite \
-dFIXEDMEDIA \
-dDEVICEWIDTHPOINTS=612 \
-dDEVICEHEIGHTPOINTS=792 \
-c "<< /BeginPage{
0.88235 0.88235 scale
72 36 translate
} >> setpagedevice" \
-f input.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment