diff options
author | Jonas Smedegaard <dr@jones.dk> | 2024-04-09 15:37:57 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2024-04-09 15:37:57 +0200 |
commit | e3350a7c5d31967d15ee8ad5cecb9a9029337836 (patch) | |
tree | c649a60ad54b6ac16a15ced47fe53e40d854af1c | |
parent | ef11876fc740809926e72b352855c7ea2ccb46af (diff) |
modernize: use fenced code blocks
-rw-r--r-- | USE.md | 40 |
1 files changed, 29 insertions, 11 deletions
@@ -9,7 +9,9 @@ e.g. using "direct print" from a USB dongle on a Brother HL-4040CN Laser printer. A workaround is to [downgrade](#Downgrade) to PDF 1.2 like this: - ps2pdf12 infile outfile +```shell +ps2pdf12 infile outfile +``` ## Unsupported PDF data @@ -21,11 +23,15 @@ e.g. using "direct print" from a USB dongle on a Brother HL-4040CN Laser printer. A workaround is to [refry](#Refry) like this: - pdf2ps infile - | ps2pdf12 - outfile +```shell +pdf2ps infile - | ps2pdf12 - outfile +``` or using this custom wrapper, where available: - localpdf2ps2pdf infile +```shell +localpdf2ps2pdf infile +``` If the above fails to work, then try replace `pdf2ps` @@ -80,12 +86,16 @@ is technically a page with a /MediaBox of approx. [595 x 842 pt][page_dimensions Resolve all boxes (computing from defaults any omitted ones): - pdfinfo -box -l -1 input.pdf +```shell +pdfinfo -box -l -1 input.pdf +``` Extract MediaBox: - gs -dQUIET -dNODISPLAY -dNOSAFER -sFileName=input.pdf \ - -c "FileName (r) file runpdfbegin 1 1 pdfpagecount {pdfgetpage /MediaBox get {=print ( ) print} forall (\n) print} for quit" +```shell +gs -dQUIET -dNODISPLAY -dNOSAFER -sFileName=input.pdf \ +-c "FileName (r) file runpdfbegin 1 1 pdfpagecount {pdfgetpage /MediaBox get {=print ( ) print} forall (\n) print} for quit" +``` To check if other boxes exist, replace `/MediaBox` with e.g. `/CropBox` in above command, @@ -100,7 +110,9 @@ TODO: Add section on cropping, based on <https://stackoverflow.com/a/10418720/18 Compute BoundingBox for each page individually (*not* across them all): - gs -q -dBATCH -dNOPAUSE -sDEVICE=bbox -dLastPage=1 input.pdf 2>&1 | grep %%BoundingBox +```shell +gs -q -dBATCH -dNOPAUSE -sDEVICE=bbox -dLastPage=1 input.pdf 2>&1 | grep %%BoundingBox +``` Source: <https://stackoverflow.com/a/52644056> @@ -137,7 +149,9 @@ While the main purpose of plakativ is to not only resize but also slice onto multiple smaller tiles, one of its features is easy scaling by area. - plakativ --factor=0.5 --size=250mmx337mm --output=output.pdf input.pdf +```shell +plakativ --factor=0.5 --size=250mmx337mm --output=output.pdf input.pdf +``` ### using Ghostscript with fitPage @@ -154,7 +168,9 @@ Example command, resizing from A3+ to A4 (source width 910.24 and height 1258.9 as reported by `pdfinfo`): - gs -o output.pdf -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=643.60333 -dDEVICEHEIGHTPOINTS=890.131 -dFIXEDMEDIA -dFitPage -dCompatibilityLevel=1.4 input.pdf +```shell +gs -o output.pdf -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=643.60333 -dDEVICEHEIGHTPOINTS=890.131 -dFIXEDMEDIA -dFitPage -dCompatibilityLevel=1.4 input.pdf +``` TODO: maybe options `-dDEVICEWIDTHPOINTS` and `-dDEVICEHEIGHTPOINTS` can be shortened as `-dDEVICEWIDTH` and `-dDEVICEHEIGHT` @@ -169,8 +185,10 @@ Example command, resizing from A4 to printable-area-A4 (i.e. a dumb printer always auto-resizing to fit): - gs -o output.pdf -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=595 -dDEVICEHEIGHTPOINTS=842 -dFIXEDMEDIA -dCompatibilityLevel=1.4 \ - -f input.pdf -c "<</EndPage {0 eq {[/CropBox [0 0 567 802] /PAGE pdfmark true}{false}ifelse}>> setpagedevice" +```shell +gs -o output.pdf -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=595 -dDEVICEHEIGHTPOINTS=842 -dFIXEDMEDIA -dCompatibilityLevel=1.4 \ +-f input.pdf -c "<</EndPage {0 eq {[/CropBox [0 0 567 802] /PAGE pdfmark true}{false}ifelse}>> setpagedevice" +``` NB! It is important to list option `-f` before `-c`, to ensure that any `CropBox` marks in file is [overridden] by the command. |