sub BEGIN { $App::Author = 'Vadim V. Konovalov'; $App::Name = 'print-pdf'; $App::Version = '0.1'; $App::Description = <<'EOS'; prints PDF file(s) via Acrobat via OLE technology EOS $App::Arguments = <<"EOS"; --no-print -- to skip printing --no-log -- to skip log file creation --log=[ofile] -- output log, default=log-print.txt --dir=[idir] -- directory, where required files are; default=current files to be processed EOS $App::TODO = <<"EOS"; 1. implement --quit, which will optionally quit acrobat. EOS $App::ChangesHistory = <<'EOS'; 0.1: first version EOS } use strict; use Cwd; if ($#ARGV==-1) { print STDERR <<"EOS"; $App::Name version $App::Version Arguments: $App::Arguments $App::Description EOS exit; } my %opts = ( # %known_opts enumerates allowed opts as well as specifies default # and initial values my %known_opts = ( 'debug' => 0, 'dir' => '.', 'verbose' => 1, 'print' => 1, 'log' => 'log-print.txt', ), #options itself my %specified_opts = ( (map {/^--([\-_\w]+)=(.*)$/} @ARGV), # +--opt=smth (map {/^no-?(.*)$/i?($1=>0):($_=>1)} map {/^--([\-_\w]+)$/} @ARGV) +, # --opt --no-opt --noopt ), ); die "option '$_' is not recognized" for grep {!exists $known_opts{$_}} + keys %specified_opts; @ARGV = grep {!/^--/} @ARGV; my $fhlog; if ($opts{log}) { unless (open $fhlog, ">>$opts{log}") {print STDERR "Can not open log + file $opts{log}: $!\n"} print $fhlog "# date=".scalar(localtime)."\n"; print $fhlog "# dir=$opts{dir}\n"; } chdir $opts{dir} or die "can't chdir to '$opts{dir}'"; my @files = map{s/\//\\/g;$_} map {!/^\w:[\\\/]/?cwd.'/'.$_:$_} map {g +lob} @ARGV; use VK::Acrobat; my $acro = new VK::Acrobat(-verbose=>0); my $abat = $acro->{acro}; my $adoc = $acro->{acrodoc}; for my $fn (@files) { unless (-e $fn) { print STDERR "file $fn does not seem to exist!"; #next; } #$abat->Show; (my $tit=$fn) =~s/^.*?([^\\\/]+)$/=$1=/; my $rc = $adoc->Open($fn,$tit); #print STDERR "rc=$rc\n"; if ($rc==0) { print STDERR "ERROR!!!\n"; next; } my $pddoc = $adoc->GetPDDoc; my $pp = $pddoc->GetNumPages; #print "pp=$pp\n"; print STDERR "[$fn][$pp] printing ...\n"; if ($fhlog) { print $fhlog "fn=$fn pp=$pp\n"; } if ($opts{print}) { $adoc->PrintPages( #Silent 0, # long nFirstPage, $pp-1, # long nLastPage, 3, # long nPSLevel, 0, # long bBinaryOk, 0, # long bShrinkToFit, #0, # long bReverse, #0, # long bFarEastFontOpt, #0, # long bEmitHalftones, #0, # long iPageOption); ); } $adoc->Close(1); }
In reply to pdf files print utility on Win32 by Courage
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |