Stratos Gerakakis

Convert an A4 sized .pdf file to A5 size

Tagged as: linux  cli  pdf 

Jan 5 2011

I was working on a LyX document based on the Tufte layout and unfortunately the page layout was available at A4 page sizes only (ok, US letter, too, but that doesn’t count :)

I could try and learn Latex and create my own page size but the task looked monumental. I am sure the solution might be easy enough, but I just couldn’t do it myself. Googling for A5 sized tufte layouts didn’t help either.

So to the command line it is.

From LyX export you final document to postscript format, let’s say


  psresize -Pa4 -pa5

This will convert the original .ps to another sized at A5. Unfortunately it will need further tweaking.

Open the postscript file and delete the % %DocumentMedia line (if one exists).

Also change the existing % %BoundingBox: line to:

% % BoundingBox: 0 0 421 595
% % DocumentPaperSizes: a5
% % BeginPaperSize: a5

Note: On a couple of documents I could not locate the % %BoundingBox: line and the structure of the .ps file was a little weird. As a workaround try to edit the:

% % BeginPaperSize: a5
/setpagedevice where
{ pop << /PageSize [420 595] >> setpagedevice }
{ /a5 where { pop a5 } if }
% % EndPaperSize

section. In it’s original format it will contain A4 references and the dimensions would be [595 842].

Finally create your PDF file:

gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 -dMaxSubsetPct=100 \
-dSubsetFonts=true -dEmbedAllFonts=true \

Open myBook.pdf and marvel at your handiwork… :)