1. Marcin Kasperski
  2. script_print

Overview

HTTPS SSH

print_in_parts.pl

Print given .pdf file in pieces, 20 (or whatever you specify) pages each, waiting until printer finishes previous part before feeding it with the next one.

I wrote it to handle repeatable problems with my printer hanging, crashing, or working very slowly when asked to print large graphics-intensive PDFs.

Usage

Simplest usage:

perl print_in_parts.pl --file=bigfile.pdf

(print whole bigfile.pdf in chunks of 20 pages)

More complicated usage:

perl print_in_parts.pl --file=bigfile.pdf --since=41 --split=10 --prompt

(print, in chunks of 10 pages, part of bigfile.pdf starting from page 41, ask for confirmation before printing each chunk)

Jobs are sent to the default printer configured on the machine. You can use lpstat -d to verify which printer is configured as such, and lpoptions (or printer settings, or CUPS web administration page) to change.

Script claims A4 page size, and requests two-side printing. Those options (printer, page size, duplex) can be fine-tuned if necessary by editing printing command in the script code below.

Preparing PDF for print

Unnecessary margins can be cut with

briss

Well layed out "two-pages per paper page, skip uninteresting parts" pdf can be prepared with sth like

pdfnup file.pdf 2-7,19-20,18-64

I happened to see PDFs which looked correctly on the screen, but printed incorrectly (effects like missing letters, unexpected spacing between letters, missing or broken images). It usually helps to open such file in evince, print it to file (or to PDF printer), then feed the result to this script.

Requirements

The script uses modern Linux printing tools: lp and lpstat. I test it on Ubuntu with CUPS (but it should work on other modern Linuxes).

To run script as such, one needs perl, and Moose, MooseX::Getopt, and PDF::API2 modules.