Cups vs LPR
Posted in PDF on May 18th, 2011 by adam – Comments OffI don’t know if anyone else has this problem, but when I try to print large files using CUPS (I have Ubuntu installed) then it seems it sometimes dies with an out-of-memory error on the printer. When I try and print the same thing with the lpr command directly with a command like:
lpr -o landscape -o sides=two-sided-short-edge -o number-up=1 / hbic_a5.pdf_combined.pdf
Then it prints fine. Seems odd to me since I understood printers are meant to manage the printing process ‘one page at a time’ and hence I can’t see why CUPS should die like this and LPR works ok.
Printer and Memory
Posted in PDF, Printers and Printing on January 6th, 2011 by adam – 1 CommentI have recently been using a Samsung ML-2850 Duplex printer for creating books with book-formatted PDF (generated by Booki). In order to do this I made a script to manipulate the PDF so that I had two A5 manuals side by side on an A4. When I had run the commands for this on a manual the size was increased dramatically. One manual went up from 1.6 MB to 10 MB or so.
After doing this I discovered that some manuals would print only a few pages on my printer and then stop, and others would not print at all. After a lot of hair pulling I discovered that the default printing system in Ubuntu (CUPS) does not manage printing large files very well and hence the printer was dying because it didnt have enough memory available to complete the job. I took a long time to work this out since there is not much documentation about this online, additionally it has hard to discover what kind of memory is needed for a specific printer online AND all the electronic shops I visited knew nothing about printer memory.
CUPS revealed no information in the error logs…so after some frustration I finally wrote a little script to print the double sided pages 2 at a time. This actually worked. I still had a little issue that if too many jobs were sent to the printer (too many double page print requests at any one time) the printer could still also die. So…I slowed the speed in which the requests where made and….it worked! I’m very sad the printer doesnt print it straight off but I am also glad this hack seems to work…posting here incase anyone else has a similar issue…the script could be optimised a lot!
#!/bin/bash c=0 PAGES='/usr/bin/pdfinfo $1 | grep Pages | tr -dc '[0-9]'' COUNT=1 SLEEP=0while [ $COUNT -le $PAGES ] ; do echo "print ".$COUNT "-" $((COUNT+1)) lpr -P ML-2850-Series -o Resolution=600x600dpi -o PageSize=A4 / -o Duplex=DuplexTumble -o page-ranges=$COUNT-$((COUNT+1)) $1 sleep 17 ((COUNT++)) ((COUNT++)) ((SLEEP++)) done
Free Software PDF Readers
Posted in PDF, Printers and Printing on January 4th, 2011 by adam – Comments OffRecently I was hunting around for free software PDF readers. Here is a good list:
http://www.pdfreaders.org/
The PDF readers I have tried for Ubuntu (Linux) include kpdf, evince (the default viewer), okular, ghostview (gs), and xpdf. Of these I prefer evince for its simplicity.
One big downside of the free software readers is that none of them enable booklet printing. Acroreader is not free but enables printing of booklets for any PDF. It would be fantastic to see this feature in evince as otherwise you need a script to create the booklet out of a standard PDF, then open it and print it the standard way.
It is possible to create booklets using scripts. There is the PDFBook script that does a good job (http://www.ctan.org/tex-archive/support/pdfbook/) and it is also possible to use shell scripts to process PDF using the pdfnup command to create booklets. I recently wanted to print the same PDF side by side on a single A4 so I wrote the following script to do the job:
#!/bin/bash pdftk $1 burst for f in pg_* do pdftk $f $f cat output $f.pdf rm $f donefor g in pg_* do pdfnup --nup 2x1 $g --outfile $g.pdf rm $g donepdftk pg_* cat output $1_combined.pdf rm pg_*
Seems to work ok albeit a little inefficient.
