diff options
| author | Guilhem Moulin <guilhem.moulin@chalmers.se> | 2010-09-23 02:02:46 +0200 | 
|---|---|---|
| committer | Guilhem Moulin <guilhem.moulin@chalmers.se> | 2010-09-23 02:02:46 +0200 | 
| commit | 807eba001ee768e6156423213080dc0ffe50695e (patch) | |
| tree | d5a209dcace71d202e1181b7c21b46d2d7083764 /pdftool.pl | |
| parent | aec59a5b1051381b0fba66852c852b5999352d16 (diff) | |
A couple of new things.
TODO: pdf non seekable, a fork keeps hand
Diffstat (limited to 'pdftool.pl')
| -rwxr-xr-x | pdftool.pl | 34 | 
1 files changed, 21 insertions, 13 deletions
| @@ -104,13 +104,14 @@ if ($filename eq "-") {      # Need to copy the whole input to an auxiliary file, since      # conversion from pdf to ps requires random access to the data +    # TODO: only for pdfs      $filename = "$tmpdir/pdftool-stdin-" . int(rand 2**16) . lc ".$filetype";      open(AUXFD, '>', "$filename")          or die "Can't read write into `$filename'";      push @auxfiles, "$filename";      # cat > $filename -    print AUXFD $fstline; +    seek STDIN, 0, 0;      while (<FILE>) {          print AUXFD $_;      } @@ -121,21 +122,19 @@ close(FILE);  # Convert to ps, or read the input file  if ($filetype eq "PDF") { -    open(PSFILE, '|-', "$pdf2ps $filename -") +    open *PSFILE, '|-', "$pdf2ps", "$filename", "-" +#    open2 PSFILE, '<&STDIN', "$pdf2ps $filename -"          or die "Error with `$pdf2ps $filename -'";  } else { -    open(PSFILE, '<', "$filename") +    open *PSFILE, '<', "$filename"          or die "Can't open `$filename'";  }  push @auxfds, fileno PSFILE;  # Resize file to our papersize -open2(*PSRESIZE, "<&PSFILE", "psresize -p$papersize") -    or die "Error with `psresize -p$papersize'"; -#push @auxfds, fileno \*PSRESIZE; +open2 *PSRESIZE, "<&PSFILE", "$psresize", "-p$papersize" +    or die "Error with `$psresize -p$papersize'"; -open("<&PSRESIZE", "cat"); -exit 0;  # pscrop  *PSCROP = *PSRESIZE; @@ -145,20 +144,29 @@ exit 0;  # psnup  # TODO: sometimes unecessary -open2(*PSNUP, "<&PSBOOK", "psnup -p$papersize -m$mnup -$nup") -    or die "Error with `psnup -p$papersize -m$mnup -$nup'"; +open2 *PSNUP, "<&PSBOOK", "$psnup", "-p$papersize", "-m$mnup", "-$nup" +    or die "Error with `$psnup -p$papersize -m$mnup -$nup'";  # TODO: not always stdout -open2(">&STDOUT", "<&PSBOOK", "ps2pdf -sPAPERSIZE=$papersize - -") -    or die "Error with `ps2pdf -sPAPERSIZE=$papersize - -'"; +open2 ">&STDOUT", "<&PSNUP", "$ps2pdf -sPAPERSIZE=$papersize - -" +    or die "Error with `$ps2pdf -sPAPERSIZE=$papersize - -'"; +#flush; +print  STDERR "ok\n"; +close STDIN; +close STDOUT; +close PSNUP; +close PSBOOK; +close PSCROP; +close PSRESIZE; +close PSFILE;  # close auxiliary filehandles -map {close $_} @auxfds; +#map {close $_} @auxfds;  # delete auxiliary files  unlink @auxfiles; | 
