## Thursday, November 28, 2013

### I hope you find this blog enjoyable and helpful. Support it with a small donation.

I spent the weekend getting my tax documents in order (yeah I know, I live a pretty extreme life).  I like to assemble them into a single PDF file of about 100 pages and keep a digital copy and a produce a bound printed copy.  The bound version is easy to make notes on and show to others.  That's all well and good, but sometimes when binding the printed version, the holes are punched through important information on the side of the pages.  Adding a binding offset solves this problem.

A binding offset is an area on the side of the page that's kept clear for the holes to be punched through.  Offsetting the pages isn't enough though, they also need to be scaled to fit into the smaller area available.  In my case I print on both sides of the paper, this complicates things further as well.  It means the binding offset needs to alternate between the left and right sides of the page on consecutive pages.

I thought that this was pretty much impossible unless you used professional tools, but I soon found out it's ridiculously easy in LaTeX.  While I was at it, I decided to add page numbering to the output file as well.

Below I'll go though a quick exaggerated demonstration of what I mean.  I've started by looking at the 2nd and 3rd pages of a 3 page document.  The page on the left covers the extents of the page.

 Example document
After being processed the output file now contains an area in the middle of the page to allow binding.  The page numbers are also added to the bottom of the page opposite the binding area.
 Binding offset and page numbers added
The LaTeX file I used to generate the output is below.  It by no means covers all possible situations, PDF files can get complex, and this could break one of the more esoteric features of the standard, so I recommend testing it first.  It worked perfectly for me though.

The code below is also just a starting point, you could also include pages from other PDF files or put multiple pages on one page, it's a highly customisable tool.  This however should be enough of a framework to get you started.  I'm still learning all the tricks myself.
