Marcin Kasperski avatar Marcin Kasperski committed 24ac588

.

Comments (0)

Files changed (1)

print_in_parts.pl

 #!/usr/bin/perl -w
 #
-# Print given .pdf file in pieces, 20 pages each, waiting for
-# the end of earlier part before sending next one.
-#
-# Requires modern Linux printing tools (lp and lpstat, I test the
-# script on Ubuntu with CUPS), uses default printer configured on
-# the machine.
-#
-# Requires also perl plus Moose, MooseX::Getopt, and PDF::API2
-# modules.
+
+=head1 print_in_parts.pl
+
+Print given .pdf or .ps file in pieces, 20 pages each, waiting for the
+end of earlier part before sending next one.
+
+Requires modern Linux printing tools (lp and lpstat, I test the script
+on Ubuntu with CUPS), uses default printer configured on the machine,
+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.
+
+Requires also perl plus Moose, MooseX::Getopt, and PDF::API2 modules.
+
+Simplest usage (print whole bigfile.pdf in chunks of 20 pages):
+
+    perl print_in_parts.pl --file=bigfile.pdf
+
+More complicated usage:
+
+    perl print_in_parts.pl --file=bigfile.pdf --since=41 --split=10
+
+(print, in chunks of 10 pages, part of bigfile.pdf starting from page 41)
+
+=cut
 
 package PrintMe;
 use Moose;
     my $self = shift;
 
     unless($self->file =~ /\.pdf$/i) {
-        die "Only .pdf files are currently handled\n";
+        die "Only .pdf files are currently handled.\nNote: support for .ps could be easily added if useful.\n";
     }
 
     my $doc = PDF::API2->open($self->file);
         sleep(1);
     }
 
-    print "READY\n";
+    print ".. printer ready\n" if $self->verbose;
 }
 
+# Checking whether anything happens on default printer
 sub printer_active {
     my $self = shift;
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.