imagemagick - Add white border to PDF (change paper format) -


i have change given pdf a4 (210mm*297mm) 216mm*303mm.

the additional 6 mm each dimension should set white border of 3mm on each side. original content of pdf pages should centered on output pages.

i tried convert:

convert in.pdf -bordercolor "#ffffff" -border 9 out.pdf 

this gives me needed result but loose sharpness of original images in pdf. kind of blurry.

i checked with

convert in.pdf out.pdf 

which no changes @ screws images.

so tried ghostcript did not result. best approach found far german side is:

gs -soutputfile=out.pdf -sdevice=pdfwrite -g6120x8590 \ -c "<</install{1 1 scale 8.5 8.5}>> setpagedevice" \ -dnopause -dbatch in.pdf 

but error: /typecheck in --.postinstall--.

shifting content on media not hard, mean altering content stream of pdf file, pdf manipulation packages avoid, reason.

the code quote above won't work, leaves garbage on operand stack, , plrm explicitly states followed implicit initgraphics reset standard parameters anyway.

you try instead setting /beginpage procedure translate origin, work:

<</beginpage {8.5 8.5 translate} >> setpagedevice 

note aren't manipulating original pdf file; ghostscript takes original pdf file, interprets graphics primitives, reassembles primitives new pdf file, has implications... example, if image dct encoded (a jpeg) in original, decompressed before being passed output file. don't want reapply dct encoding introduce visible artefacts.

a simpler alternative, involving multiple processing steps , therefore more potential problems, first convert pdf postscript ps2write device, specifying media size, , -dcenterpages switch, use pdfwrite device turn resulting postscript new pdf file.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -