Friday, May 28, 2010: Shuffle for Booklet « from the old blog archive »
I have a reading record homework, where I have to read 10 stories, write the details about them, give them point of views, and write down 10 new vocabularies for each story. It needs to be printed on an A5 booklet, that is, one A4 paper folded in half to form 4 A5 pages.
First, I made the template in iWork, but then I realized that iWork can't make booklets. I think that I will use FPDF and FPDI to do this job.
So here's the thing I am doing.
- Input Data: A pdf file of A5 pages.
- Output Data: An A4 landscape PDF file with all the pages shuffled for printing booklets.
But I found out that I can only output from first page to the last page, so I need to know first how to print a booklet of N pages. This is the topic of the blog post, which shows you the most straightforward way of computing which input page goes to which side of the output pages. Here's how the algorithm work.
First, calculate the number of papers needed for N page, which is ⌈N / 4⌉ For example, I want a booklet of 16 pages, I need 4 pieces of paper. That means 8 pages.
Then, put these papers on top of each other, fold them in half. You get booklet like this.
Starting from the front of your booklet, label that page 1, then turn your page, label it 2 and 3. Do this for all pages.
Now you know what to print on each page.
Transform the above instructions into code. I get this.
An example...
P.S. I should have seen ps2book before I start writing this.
add / view all comments
Responses