--- author: '' category: '' date: 2010/08/13 18:46 description: '' link: '' priority: '' slug: BB909 tags: nerdness, open source, programming, python title: Things I learned publishing a magazine type: text updated: 2010/08/13 18:46 url_type: '' --- Today at 00:00:00 GMT-3 `PET: Python entre todos `_ was indeed launched, in time (arbitrary but forced) and in budget ($0). So, what did I learn? I learned a lot! * The only thing you need to publish an e-mag is time and content. * Time can be converted into content, but if you write everything yourself it's a blog, not a magazine. Luckily, PET found great contributors. * If you want utilitarian design, rst2pdf can do the job * In fact, it can do it better than other tools in some ways + I can push a fixed version of the PDFs in 5 minutes for all layouts. How much would it take me using Scribus or other DTP? In a magazine where correctness matters, that's a big deal. + TOCs are better than in most amateur PDF magazines I've seen. The in-content-TOC is clickable, and the PDF TOC is perfect. + Page numbers in the PDF TOC make sense (no, the cover is not page 1) + I am producing 6 PDF versions: A4(bw, colour), A5(bw,colour), Booklet(bw, colour) and I could add any other I want in a few minutes. * I learned about PDF imposition! Let's explain the last one: Suppose you want to print a small booklet, and you have 32 pages of content. How do you do that? The easiest way is to print it 2-up double-sided in A4 paper so that you can stack the pages, fold them down the middle, staple them, and get a nice A5 booklet. The problem is that the page ordering is hard to get right. For example, for a 4-page booklet, you need to print one A4 page with pages 4-1 on one side and 2-3 on the other. For an 8 page booklet it's 8-1,2-7,3-6,4-5. Lucklily there's a way to get this done automatically: 1. Install podofo 3. Get booklet-A4.plan (see below) 2. Run this:: podofoimpose my-A5-pages.pdf my-booklet.pdf booklet-A4.plan lua booklet-A4.plan is this: .. code-block:: lua ---Generic Booklet (A4) --- ---It is said generic as it will try to determine ---automatically how to fit the booklet onto A4 ---paper sheets, scaling pages if necessary. ---it is well suited for office documents for ---which you do not care too much about resulting ---imposition artefacts since it manages to save ---paper! --- -- print("Booklet") -- We output an A4 booklet PageWidth = 595.27559 PageHeight = 841.88976 print("PageCount",PageCount) -- We assume that H > W -- Argh, we now can do better since we have "if" ;-) -- Scale = PageHeight / (2*SourceWidth) if(SourceWidth <= SourceHeight) then -- If you A5 pages are not really A5, uncomment the next line -- Scale = PageHeight / (2*SourceWidth) Scale = 1 rot = 90 xof = SourceHeight yofRA = 0 yofRB = SourceWidth yofVA = 0 yofVB = SourceWidth else -- If you A5 pages are not really A5, uncomment the next line -- Scale = PageHeight / (2*SourceHeight) Scale = 1 rot = 0 xof = 0; yofRA = 0 yofRB = SourceHeight yofVA = SourceHeight yofVB = 0 end do rest = PageCount % 4 totp = PageCount if rest ~= 0 then totp = totp + ( 4 - rest) end inc = 0 count = 0 imax = totp/4 while count < imax do -- We assume that podofoimpose will discard invalid records -- such as those with source page greater than PageCount -- print(totp, inc, rot, xof,yofRA, yofRA, yofVA, yofVB) -- Recto PushRecord(totp - inc , inc + 1 , rot, xof , yofRA) PushRecord(inc + 1 , inc + 1 , rot, xof , yofRB) -- Verso PushRecord(inc + 2 , inc + 2 , rot, xof , yofVA) PushRecord(totp-(inc + 1) , inc + 2 , rot, xof, yofVB) count = count + 1 inc = inc + 2 end end That code is taken from here: http://www.oep-h.com/impose/ And voilá, you get a scrambled PDF with the pages in exactly the right order (and empty pages added as needed).