navelfluff

Navelfluff har flyttat till / on muuttanut osoitteeseen / has moved to
Navelfluff.org
english, geek30-Jan-2006 16:02

Do this:

pdftops -level2 book.pdf book.0.ps && pstops "4:0@1.2(-0.5cm,-3.5cm),1@1.2(-3cm,-3.5cm),2@1.2(-1cm,-3.5cm),3@1.2(-3cm,-3.5cm)" book.0.ps | psbook | psnup -2 | pstops "2:0@1.0(-0.00cm,0.0cm),1U@1.0(21cm,29.7cm)" > book.ps

Last friday, i wanted to use less paper to print out a 256 page book on mobile programming. I wanted to print a booklet. I wanted this so bad that i spent most of the friday trying to figure out how to do it. So as not to be the only one benefiting from my mammoth waste of time, i’ll share my findings. I’m sure you could do more McDinking with the settings but at the stage i came up with the one liner above, i’d completely had it (and i still needed to print, cut and bind the damn thing). I should also note that on Windows, with proper HP drivers, i have been able to accomplish the same magic by just ticking a checkbox, but no such checkbox exists on this do-it-yourself system of a Linux. Whee.

Here’s an explanation of my behemoth one-liner, broken into steps.

First, you take a PDF file created from a TeX source. The operation will be a lot simpler if you start with something formatted for a full A4 page; TeX does this very nice formatting commended by the Church of Knuth that makes text easier to read. If you’re just going to output A4 (or Letter) printouts, i strongly suggest you stick to the original settings. Also, if you have the original TeX source, you can do a lot of the tweakings elsewhere than here and save yourself from a lot of work. Here i started with a PDF file with no access to the source.

pdftops -level2 book.pdf book.0.ps

Pdftops translates the PDF file into a PostScript file. Since our printer (and oldish Laserjet) coughs on overly complex PostScript Level 3, i asked the file to be translated into older PostScript.

TEX (there, i wrote it correctly once — now can you leave me alone?) formats the page to work beautifully on an unadultered size, but in this case, i’m going to zoom it down to fit the page on half a sheet. In its original size, TeX leaves rather giant margins around the text, which, i stress, is fine if used as is, but on an A5, the text gets rather small for my eyes. So i zoom.

pstops "4:0@1.2(-0.5cm,-3.5cm),1@1.2(-3cm,-3.5cm),2@1.2(-1cm,-3.5cm),3@1.2(-3cm,-3.5cm)" book.0.ps book.1.ps

This magnifies the page by 20%, then (yes, after scaling) moves the resulting page a various amount of centimetres to the left, and 3½ cm down (which means it actually moves 1.2 * 3.5 cm down). The four-phase translations (Xcm,-3.5cm) are a result from much tweaking, McDinking and frustration.

Then comes my favourite command.

psbook book.1.ps book.2.ps

Psbook re-orders the pages of the original PDF stream to be book(let)-printable. It felt like a miracle to find it. After that, pages can be re-shuffled so that two pages are fit on one sheet:

psnup -2 book2.ps book.3.ps

But we’re not done just yet. Since many duplex printers (which is a fancy name for a printer that can print on both sides of a paper) print the reverse side of the paper upside down, we have to accommodate for this. Again we use the pstops command:

pstops "2:0@1.0(-0.00cm,0.0cm),1U@1.0(21cm,29.7cm)" book.3.ps book.ps

The second argument (1U…) rotates the page upside-down, then offsets it so that the resulting output actually hits the page. It’s quite intuitive if you’re a transformation matrix.

The whole exercise leaves you with a book.ps, which you can send to the printer using lpr -Pprinter book.ps or translate back into PDF if you want to confuse somebody else.

english, geek 15:29

I’ve used a PDA for a few years now and i’m quite happy with a gadget which works like a calendar that actually reminds me to look at it. I use it as a shopping list, a small surf board, a to-do list and a platform to play solitaire and sudoku on. Granted, there are cheaper options available but a geek needs his toys :)

The most valuable feature of a PDA is actually in its ability to synchronize with your full size computer (which is why one of my computers still run Windows). The PDA the becomes a live extension to the desktop computer (which in reality is a laptop computer, which mostly resides on my desk — unless it travels in my backpack and on occasions emerges into a sofa laptop… now where was i?). For example, ListPro is an insanely great piece of software if you get the desk+pocket pc edition.

Not long ago, i got (to borrow) a phone from work. Again, a “smart phone” is only really useful if it synchronizes with a full size computer, so i installed Nokia PC Suite. Promptly, my MS Actice Synch stopped synching. I uninstalled the PC Suite (and probably un/re-installed MS Active Sync) and the PDA came back. I made a political decision to keep the PDA as my main computer extension and the phone as a manually edited thingamajing. Because i knew that there would soon be another phone replacing this one.

Flash forward to last week. My professor tells me it’s Christmas. He has a Nokia N70 for me! Whee! After much pondering i decide to have the phone as my primary PDA, so i uninstall the MS bit and install the new and shiny PC Suite. Much to my surprise, the installation and synchronization goes entirely without pain and works the first time executed. Nokia has improved a lot.

I still have the Communicator 9k5 which i decide to synch as well. After all, i’ve edited a lot of PIM stuff on it.

My computer does not like this. Windows figures out that i have a Nokia 9500 connected, but that’s where it stops. PC Suite doesn’t care for the Communicator even if it’s built to cope with many phones. Seems like Nokia doesn’t sport “universal drivers”.

But hey, now somebody else is jealous too, because PC Suite refuses to recognize the N70 and i now have exactly zero gadgets that talk with the computer. Way to go.

One trick i’ve learned from my previous life is never to connect a Nokia phone to the computer before installing the drivers. It frells your computer. It’s ridiculous it has to work this way (though i don’t think work is a suitable word here) but that’s how it is. I just didn’t expect you’d have to install more Nokia drivers after installing current ones.

What i am requesting for is this. A universal synchronization interface for Windows. And Linux. Actually i have it that they’re pretty far with it on Linux even if i haven’t managed to actually get any of my gadgets to speak with Linux. But Windows is where all the money is. Please, design a way for a phone and a PDA to both be able to talk with my computer. I’d really, really appreciate it.

In the meantime, please give back my Nokia connection. I will not connect a phone to my computer without installing the drivers again. I promise.