diff options
Diffstat (limited to 'Master/texmf-dist/scripts/a2ping')
-rwxr-xr-x | Master/texmf-dist/scripts/a2ping/a2ping.pl | 238 |
1 files changed, 118 insertions, 120 deletions
diff --git a/Master/texmf-dist/scripts/a2ping/a2ping.pl b/Master/texmf-dist/scripts/a2ping/a2ping.pl index 39331beb795..0da2e4344e2 100755 --- a/Master/texmf-dist/scripts/a2ping/a2ping.pl +++ b/Master/texmf-dist/scripts/a2ping/a2ping.pl @@ -1,36 +1,34 @@ #! /bin/sh eval '(exit $?0)' && eval 'PERL_BADLANG=x;export PERL_BADLANG;: \ -;exec perl -x -S -- "$0" ${1+"$@"};#'if 0; -eval 'setenv PERL_BADLANG x;exec perl -x -S -- "$0" $argv:q;#'.q+ +;exec perl -x -- "$0" ${1+"$@"};#'if 0; +eval 'setenv PERL_BADLANG x;exec perl -x -- "$0" $argv:q;#'.q+ #!perl -w package Htex::a2ping; $0=~/(.*)/s;unshift@INC,'.';do($1);die$@if$@;__END__+if !1; -# This Perl script was generated by JustLib2 at Wed Apr 23 09:14:13 2003. # Don't touch/remove any lines above; http://www.inf.bme.hu/~pts/justlib # # This program is free software, licensed under the GNU GPL, >=2.0. # This software comes with absolutely NO WARRANTY. Use at your own risk! # -# !! Imp: merge back to a2ping.pa # !! Ghostcript compute pipe too slow -# $ a2ping.pl -v debrecen-hyph.ps de brecen-hyph.pdf -# a2ping.pl 2.77p, 2004-04-28 -- Written by <pts@fazekas.hu> from April 2003. +# $ a2ping.pl -v debrecen-hyph.ps debrecen-hyph.pdf +# a2ping.pl ... -- Written by <pts@fazekas.hu> from April 2003. # This is free software, GNU GPL >=2.0. There is NO WARRANTY. # (epstopdf 2.7 Copyright 1998-2001 by Sebastian Rahtz et al.) # * Strongest BoundingBox comment: %%HiResBoundingBox: # * Doing --PaperSize unchanged # * Output filename: debrecen-hyph.pdf # * Output FileFormat: PDF -# * Ghostscript ps2pdf command: gs -dSAFER +# * Ghostscript ps2pdf command: gs -dSAFER # * Compression: zip # * Input filename: debrecen-hyph.ps # * Computing BBox info from non-EPS PS file -# * Ghostscript compute pipe: gs -dSAFER -dWRITESYSTEMDICT -dNOPAUSE -sDEVICE=bbox -sFN=debrecen-hyph.ps /tmp/a2ping_pl-16977-298938572-c.tgs 2>&1 +# * Ghostscript compute pipe: gs -dSAFER -dWRITESYSTEMDICT -dNOPAUSE -sDEVICE=bbox -sFN=debrecen-hyph.ps /tmp/a2ping_pl-16977-298938572-c.tgs 2>&1 # * Applying BoundingBox from Compute-GS T-: 71 81 539 769 -# * Applying HiResBoundingBox from Compute-GS T-H: 71.837998 81.971997 538.235984 768.113977 +# * Applying HiResBoundingBox from Compute-GS T-H: 71.837998 81.971997 538.235984 768.113977 # * Scanning header for BoundingBox # * Applying BoundingBox from ADSC T-: 0 0 596 842 # * Final BoundingBox: 0 0 596 842 -# * Ghostscript ps2pdf pipe: gs -dSAFER -q -dBATCH -sDEVICE=pdfwrite -sOutputFile =debrecen-hyph.pdf - +# * Ghostscript ps2pdf pipe: gs -dSAFER -q -dBATCH -sDEVICE=pdfwrite -sOutputFile=debrecen-hyph.pdf - # * Done OK, created PDF file debrecen-hyph.pdf (338451 bytes) # package just; BEGIN{$INC{'just.pm'}='just.pm'} @@ -352,7 +350,7 @@ use just +1; # a JustLib application use strict; use integer; use Htex::papers; -BEGIN { $Htex::a2ping::VERSION="2.77p" } +BEGIN { $Htex::a2ping::VERSION="2.83p" } # Imp: option to ignore `%%Orientation: Portrait', which gs respects and rotates by 90 degrees if necessary # Imp: gs(704?!) sometimes finds too small bbox, see Univers.eps @@ -401,7 +399,7 @@ BEGIN { $Htex::a2ping::VERSION="2.77p" } ### program identification my $program = "a2ping.pl"; -my $filedate="2006-11-15"; # my $filedate="2001/03/05"; +my $filedate="2018-03-07"; # See also $Htex::a2ping::VERSION. my $copyright = "Written by <pts\@fazekas.hu> from April 2003. This is free software, GNU GPL >=2.0. There is NO WARRANTY. (epstopdf 2.7 Copyright 1998-2001 by Sebastian Rahtz et al.)\n"; @@ -770,7 +768,7 @@ show_doc() if 1==@ARGV and $ARGV[0] eq '--doc' or $ARGV[0] eq 'doc'; errorUsage "invalid or unknown for --papersize" if !@L; $::opt_papersize="$L[1],$L[2]" # width, height } - } else { die } # unreachable + } else { die } # unreachable } # NEXT opt errorUsage "Too many arguments (multiple input/output files?)" if $I!=@ARGV; # splice @ARGV, 0, $I; @@ -1138,7 +1136,7 @@ my $header; elsif ($S eq "\305\320\323\306") { $iff="DOS-EPSF" } elsif ($S eq "\033%-1") { $iff="UEL" } elsif (substr($S,0,1)eq'%') { $iff="P" } # PS, EPS or PDF - + # PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA if ($iff eq "DOS-EPSF") { # DOS EPSF header read_error if 30-4>read IN, $S, 30-4, 4; @@ -1276,7 +1274,7 @@ my $header; # Dat: PDF to GIF conversion run_sam2p(1,$S); } - + error "cannot create from PDF: FileFormat $FileFormat"; OK: } @@ -1289,7 +1287,7 @@ my $header; } # Dat: Now we are converting from PS|EPS to EPS|markedEPS|PDF|PCL5|PGM -# So we're converting from PS|EPS with Ghostscript +# So we're converting from PS|EPS with Ghostscript ### variables and pattern for BoundingBox search my $bbxpatt = '[0-9eE\.\-]'; @@ -1384,7 +1382,7 @@ sub CorrectBoundingBox($$$$$$$) { /AutoFilterMonoImages true /AutoFilterGrayImages true /AutoFilterColorImages true -/MonoImageFilter /CCITTFaxEncode +/MonoImageFilter /CCITTFaxEncode /GrayImageFilter /DCTEncode /ColorImageFilter /DCTEncode " : " @@ -1543,12 +1541,13 @@ count /OPCOUNT exch def (bbox-success\n) ..print quit } if - .callbeginpage } + % Run the previous contents of /BeginPage: {--.callbeginpage--} + [exch aload pop currentpagedevice /BeginPage get aload pop] cvx >> setpagedevice % vvv do these after our call to /setpagedevice -.currentglobal true .setglobal +currentglobal true setglobal systemdict begin /..paper.redef<< >>def /..print/print load def @@ -1657,7 +1656,7 @@ dup/= exch def /print exch def pop }forall} forall end % systemdict -.setglobal +setglobal systemdict readonly pop (bbox-begin\n) ..print @@ -1680,7 +1679,7 @@ showpage quit or $res!~s/\A(?:\w+ Ghostscript \d|Copyright .* artofcode ).*\n// # AFPL Ghostscript 6.50 (2000-12-02) or $res!~s/.*?^bbox-begin\n//m; if ($res!~s/\nbbox-success\n\Z(?!\n)/\n/) { - warning # not `error', mpost(1) `prologues:=0; ... btex fonts' output won't compile + warning # not `error', mpost(1) `prologues:=0; ... btex fonts' output won't compile "BBox discovery was not successful"; # !! continue only if MetaPost output? goto SKIP_BBOX_DISC; @@ -1771,7 +1770,7 @@ showpage quit if (defined $papersize_x and ($::opt_bboxfrom eq 'papersize' or ($::opt_bboxfrom eq 'guess' and is_set_pagesize_ok()))) { $allow_adsc_bb=0; $do_bb_line->("set 0 0 $papersize_x $papersize_y"," from /PageSize"); # does ($llx,$lly,$urx,$ury)=(0,0,$papersize_x,$papersize_y); - } + } $allow_adsc_bb=0 if ($::opt_bboxfrom eq 'compute-gs') ? ($bbc!=0) : ($::opt_bboxfrom eq 'guess') ? ($bbc!=0 and is_page1_stop()) # Imp: is is_page1_stop() OK here? : 0; @@ -1983,7 +1982,7 @@ if ($FileFormat eq 'PDF' or $FileFormat eq 'PDF1') { $scale3_pnm_fn=$ofn; $ofn=fix_force_out('S3.pnm') if $do_scale3_pnm; # ^^^ Dat: this must be the last call to fix_force_out() - } + } $pipe.="$GSOPTS -sOutputFile=".fnq($ofn)." -"; debug "Ghostscript ps2raster pipe:", $pipe; open(OUT, "| $pipe") or error "Cannot open Ghostscript pipe"; @@ -2000,7 +1999,7 @@ die unless binmode OUT; if (is_need_showpage() and is_page1_stop()) { $to_OUT.="/showpage{showpage quit}bind def\n"; # don't call showpage twice $after_code.="showpage\n"; -} +} error "write OUT" if !print OUT $to_OUT; $to_OUT=""; @@ -2112,7 +2111,7 @@ if (!$ll_zero and ($FileFormat eq 'PDF' or $FileFormat eq 'PDF1')) { # correct / currentdict pdfclose end end end '; die unless close F; - + my $gs2="$GS -dNODISPLAY -dBATCH -sFN=".fnq(fix_pipe_out(undef))." -q ".fnq($tfn); debug "Ghostscript dup pipe: $gs2"; my $offset=`$gs2`; @@ -2360,14 +2359,97 @@ write extra output formats, B<sam2p> and GS are used. PNM output formats are PGM, PGM and PPM. To write PNM output formats, GS is used. +=head1 OPTIONS -=head1 TIPS AND TRICKS +=head2 General Options =over 2 -=item * +=item B<-h>, B<--help> + +Show a summary of the usage + +=item B<--doc> + +Show the man page + +=item B<-v>, B<--(no)verbose> + +Show progress and debug messages (default: no) + +=head2 Options for the Bounding box + +=item B<--(no)hires> + +Use HiResBoundingBox in the input file, if present (default: yes) + +=item B<--(no)exact> + +Use ExactBoundingBox in the input file, if present (default: no) + +=item B<--(no)keepoldmediabox> + +keep only old, [0 0]-based MediaBox in PDF (default: no) + +=item B<--bboxfrom=>I<adsc|compute-gs|guess|pagesize> + +Method for determining the BoundingBox (default: guess) + +=item B<--(no)below> + +Allow page content below and left of the origin (default: no) + + +=head2 Options for graphics and fonts + +=item B<--(no)compress> + +use compression (default: best) -Call with the B<-v> option to see progress and debug messages. +=item B<--(no)antialias> + +render shades at outlines. Possible values: (=I<scale3yes> =I<no> =I<yes>) (default: scale3no) + +=item B<--(no)lossy> + +allow lossy image filters (EPS->PDF) (default: yes) + +=item B<--papersize=>I<unchanged|force-unknown|600bpx5cm> + +(default: default) (bp) + +=item B<--threshold=> + +min color for 1 in 8->1 bit conv (default: 128) + + +=head2 Options for debugging and changing internals + +=item B<--(no)tmpunlink> + +Unlink temporary files (default: yes). Use B<--notmpunklink> if you +want to inspect intermediate files. + +=item B<--gs-cmd=>I<path> + +path to Ghostscript program (default: gs or gswin32c) + +=item B<--gs-ccmd=>I<path> + +path to Ghostscript for BoundingBox calculation (default: gs or gswin32c) + +=item B<--gsextra=>I<GS_ARGS> + +Pass extra arguments to gs + +=item B<--extra=> + +Pass extra arguments to external program (i.e pdftops) + + +=head1 TIPS AND TRICKS + +=over 2 =item * @@ -2433,6 +2515,11 @@ B<--Resolution>. The default is B<--Resolution=72>. If your sampled output file is going to be really big, you should specify B<--AntiAlias=yes> instead of the default B<--AntiAlias=scale3no> to speed up conversion. +=item * + +To make sure fonts are included in a PDF file generated from eps, use +B<--gsextra='-dEmbedAllFonts=true -dPDFSETTINGS=/printer'>. + =back @@ -2470,7 +2557,7 @@ Conversion from PS to EPS: keeps 1st page only, removes setpagedevice etc. =head1 AUTHORS -The author of B<a2ping> is Szabó Péter <F<pts@fazekas.hu>>. +The author of B<a2ping> is Péter Szabó <F<pts@fazekas.hu>>. B<a2ping> is inspired by and historically based on the B<epstopdf> Perl script modified by Thomas Esser, Sept. 1998, but his modifications have @@ -2479,94 +2566,5 @@ share common code anymore. B<epstopdf> is written by Sebastian Rahtz, for Elsevier Science. B<epstopdf> contained extra tricks from Hans Hagen's texutil. -=head1 HISTORY - -=head2 1999/05/06 v2.5 (Heiko Oberdiek) - - * New options: --hires, --exact, --filter, --help. - * Many cosmetics: title, usage, ... - * New code for debug, warning, error - * Detecting of cygwin perl - * Scanning for %%{Hires,Exact,}BoundingBox. - * Scanning only the header in order not to get a wrong - BoundingBox of an included file. - * (atend) supported. - * uses strict; (earlier error detecting). - * changed first comment from '%!PS' to '%!'; - * corrected (atend) pattern: '\s*\(atend\)' - * using of $bbxpat in all BoundingBox cases, - correct the first white space to '...Box:\s*$bb...' - * corrected first line (one line instead of two before 'if 0;'; - -=head2 2000/11/05 v2.6 (Heiko Oberdiek) - - * %%HiresBoundingBox corrected to %%HiResBoundingBox - -=head2 2001/03/05 v2.7 (Heiko Oberdiek) - - * Newline before grestore for the case that there is no - whitespace at the end of the eps file. - -=head2 2003/02/02 (Szabó Péter) - - * option --below - * removes DOS EPSF binary junk correctly - * adds all 3 BoundingBox DSC comments - * reads all 3 BoundingBox DSC comments, and picks the best - * forces BoundingBox to be an integer - * adds %%EndComments and proper %!PS-Adobe-?-? EPSF-?.? header - * adds %%Pages: - * adds invocation syntax: a2ping <infile.eps> <outfile.eps|pdf> - * can convert PDF to EPS (by calling pdftops(1)) and PDF to PDF - * emulates work for PDF input - -=head2 2003/04/16 (Szabó Péter) - - * added PS and sam2p support, renamed to a2ping - * sam2p and pdftops if $InputFilename eq '-'; - * remove PJL UEL header from the beginning - * works for PS non-EPS files for input - * input support for PNG JPEG TIFF PNM BMP GIF LBM XPM PCX TGA via sam2p - * removes ^L (form feed) from end of EPS file - * -x=-c:rle to add sam2p options - -=head2 2003/04/26 (Szabó Péter) - - * omit the unnecessary setpagedevice calls when creating normal eps - * --noverbose --nocompress supported differently - * no more option defaults :-( - * justlib2 - * multi-page output with PS:, PDF:, PCL5: - * after `a2ping -pa4', file out.pcl says: `HP PCL printer data - A4 page - size', instead of `US letter' - * justlib2-ified doesn't depend on Getopt::Long anymore - * fully supports filtering (stdin and/or stdout), PDF and PCL5 output to - pipe (!$$ll_zero) - * adds DSC ``%%DocumentMedia: plain 612 792 0 () ()'' - * BoundingBox precedence for EPS input: --PageSize, %%*BoundingBox, - setpagedevice. Precedence for other inputs: --PageSize, setpagedevice, - %%*BoundingBox - -=head2 2003/09/25 (Szabó Péter) - - * --bboxfrom=adsc: %%BoundingBox overrides -sDEVICE=bbox - * improved bbox discovery - * many bugfixes - * MetaPost EPS input fixes for prologues:=0; - * a2ping.pl -v --papersize=50,60 --bboxfrom=compute-gs t.ps t2.ps - * consistent bbox, --PageSize, /PageSize handling - * consistent --Resolution and --Duplex handling - -=head2 2003/12/02 (Szabó Péter) - - * --bboxfrom=compute-gs option to fix PS -> EPS bbox (gs -sDEVICE=bbox), tuzv.eps - -=head2 2004/02/10 v2.77 (Szabó Péter) - - * the compute-pipe routine is now run unless --bboxfrom=guess with EPS - * added --gsextra= - * added --antialias= - * added FileFormat PBM, PGM, PPM - * separated FileFormat features to FL_* constants - * added --doc - * there is no default FileFormat (PDF) anymore +B<a2ping> contains contributions from several people, see the file +F<HISTORY.txt> for details. Thank you all for contributing! |