home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / txpdf56.zip / txt2pdf.pl < prev   
Perl Script  |  2002-03-11  |  38KB  |  1,128 lines

  1. #!/usr/bin/perl
  2. # Require Perl5
  3. #
  4. # txt2pdf -- Text to PDF
  5. #
  6. # by SANFACE Software <sanface@sanface.com> 25 March 2002
  7. #
  8. # txt2pdf 5.x is shareware: its cost is $99. Try it for 30 days.
  9. # If you decide to continue using it, register NOW via a SECURE SERVER at
  10. # http://www.regsoft.net/purchase.php3?productid=6347
  11. # or contact SANFACE Software sanface@sanface.com
  12. #
  13. # This is version 5.6
  14. #
  15. use strict;
  16. use Getopt::Long;
  17. use File::Basename;
  18. use File::Find;
  19. use File::DosGlob 'glob';
  20.  
  21. my $version="5.6";
  22. my $fpos=0;
  23. my $producer="txt2pdf";
  24. my $pageNO;
  25. my $lineNO;
  26. # Default paper is Letter size
  27. my $pageHeight=792;
  28. my $pageWidth=612;
  29. my @location;
  30. my @pageObj;
  31. my $lines=0; my $bflines=0;
  32. my $buf="";
  33. my $input=""; my $output=""; my $saveinput;
  34. my $elem="";
  35. my $configure="txt2pdf.cfg";
  36. my $help=0; my $default=0; my $verbose=0; my $Version; my $border=0; my $paper="";
  37. my $landscape=0; my $list=0;
  38. my $npage=0; my $stdin=0;
  39. my $transition=""; my $motion=""; my $direction=0; my $dimension=""; my $rotate=0;
  40. my $bgdesign=""; my $fgdesign=""; my $epdi=0; my $epdn=0; my @epd;
  41. my (@color,@fontmark);
  42. my $colori=0; my $fontmarki=0;
  43. my $obj=0;
  44. my $Tpages=0; my $resources=0; my $root=0; my $info=0;
  45. my $BF; my $EF;
  46. my @annots; my $LLx=48;
  47. my $title="";
  48. my $counter;
  49. my $recursive=""; my $match="";
  50. my $line; my $page;
  51. my $companyname="SANFACE Software";
  52. my $pdfdir=""; my $txtdir=""; my $newoutput; my $newinput;
  53. my $txt2pdfHome="http://www.sanface.com/$producer.html";
  54. my $Unregistered="Generated by unregistered $producer v.$version \251 $companyname 2002\nAvailable at $txt2pdfHome \n";
  55. my $SANFACEmail="mailto:sanface\@sanface.com";
  56. my $SECURESERVER="http://www.regsoft.net/purchase.php3?productid=6347";
  57. my $font; my $times = 0; my $timef = 0; my $loop=1;
  58.  
  59. $configure = $ENV{'TXT2PDFCFG'} if (! -e "$configure");
  60.  
  61. &GetOptions("configure=s"  => \$configure,
  62.             "help"         => \$help,
  63.             "default"      => \$default,
  64.             "landscape"    => \$landscape,
  65.         "list=s"       => \$list,
  66.             "paper=s"      => \$paper,
  67.             "npage"        => \$npage,
  68.             "recursive=s"  => \$recursive,
  69.             "match=s"      => \$match,
  70.             "border"       => \$border,
  71.             "pdfdir=s"     => \$pdfdir,
  72.             "txtdir=s"     => \$txtdir,
  73.             ""             => \$stdin,
  74.             "current"      => \$Version,
  75.             "verbose"      => \$verbose) || printusage() ;
  76. my @elem=("tmpdir","author","creator","keywords","subject","title","landscape",
  77.           "paper","font","lines","tab","pointSize","vertSpace","transition",
  78.           "npage","colour","fontmark","beginfile","endfile","border","bgdesign","fgdesign",
  79.           "pagemode","pagelayout","rotate","typeencoding","withextension",
  80.           "sleep","pdfdir","txtdir","viewerpreferences","fit","list");
  81. my %option=(tmpdir             => './',
  82.             author             => '',
  83.             creator            => '',
  84.             keywords           => '',
  85.             subject            => '',
  86.             title              => '',
  87.             landscape          => '0',
  88.             paper              => 'letter',
  89.             font               => 'Courier',
  90.             npage              => '0',
  91.             lines              => '',
  92.             pointSize          => '10',
  93.             vertSpace          => '12',
  94.             transition         => '',
  95.             tab                => '8',
  96.             colour             => '',
  97.             fontmark           => '',
  98.             beginfile          => '',
  99.             endfile            => '',
  100.             border             => '0',
  101.             bgdesign           => '',
  102.             fgdesign           => '',
  103.             pagemode           => '',
  104.             pagelayout         => '',
  105.             typeencoding       => 'default',
  106.             rotate             => '0',
  107.             withextension      => '0',
  108.             sleep              => '0',
  109.             pdfdir             => '',
  110.             txtdir             => '',
  111.         viewerpreferences  => '',
  112.             fit                => '0',
  113.             list               => '');
  114.  
  115. if($Version) {print "$producer $version\n";exit;}
  116. $help and printusage();
  117. $default and defaultparams();
  118. my $tmpelem; my $var;
  119. if (-e $configure) {
  120.   open (CNF, "$configure");
  121.   while (<CNF>) {
  122.     s/\t/ /g;        #replace tabs by space
  123.     next if /^ *\#/; #ignore comment lines
  124.     next if /^ *$/;  #ignore empty lines
  125.     foreach $elem (@elem) {
  126.       if (/ *$elem *: *(.*)/i) {
  127.         $tmpelem=$1;
  128.         if ($tmpelem=~/#!ENV#(.*)#!\/ENV#/) {
  129.           $var=$ENV{$1};
  130.           $tmpelem=~s/#!ENV#(.*)#!\/ENV#/$var/;
  131.           }
  132.         $option{$elem}=$tmpelem;
  133.         }
  134.       }
  135.     }
  136.   close(CNF);
  137.   } else {
  138.   &Warning("to set your txt2pdf configuration file you can use:\ntxt2pdf.cfg or -configure your_txt2pdf.cfg or TXT2PDFCFG\nElse the program will use the default parameters\n-default to see the default parameters\n")
  139.   }
  140. $list and $option{'list'}=$list;
  141. if ($option{'list'}) {
  142. open (LIST, "$option{'list'}") ||
  143.      die "txt2pdf: couldn't open list file $option{'list'}\n";
  144.   while (<LIST>) {
  145.     s/\t/ /g;        #replace tabs by space
  146.     next if /^ *\#/; #ignore comment lines
  147.     next if /^ *$/;  #ignore empty lines
  148.     push @ARGV,$_;
  149.     }
  150. close(LIST);
  151.   }
  152. $paper and $option{'paper'}=$paper;
  153. $landscape and $option{'landscape'}=$landscape;
  154. $npage and $option{'npage'}=$npage;
  155. $border and $option{'border'}=$border;
  156. $pdfdir and $option{'pdfdir'}=$pdfdir;
  157. $txtdir and $option{'txtdir'}=$txtdir;
  158.  
  159. print <<FEE;
  160.  
  161. This is an UNREGISTERED version of $producer.
  162. Registration fee is \$99.
  163. Register NOW via a SECURE SERVER at
  164. $SECURESERVER
  165. or contact $companyname $SANFACEmail
  166.  
  167.  
  168. FEE
  169.  
  170. if ($stdin) {push @ARGV,"-";}
  171. if (uc($option{'paper'}) =~ /A3/)           {$pageWidth=842;  $pageHeight=1190;}
  172. elsif (uc($option{'paper'}) =~ /A4/)        {$pageWidth=595;  $pageHeight=842; }
  173. elsif (uc($option{'paper'}) =~ /A5/)        {$pageWidth=421;  $pageHeight=595; }
  174. elsif (uc($option{'paper'}) =~ /TABLOID/)   {$pageWidth=792;  $pageHeight=1224;}
  175. elsif (uc($option{'paper'}) =~ /LEDGER/)    {$pageWidth=1224; $pageHeight=792; }
  176. elsif (uc($option{'paper'}) =~ /LEGAL/)     {$pageWidth=612;  $pageHeight=1008;}
  177. elsif (uc($option{'paper'}) =~ /STATEMENT/) {$pageWidth=396;  $pageHeight=612; }
  178. elsif (uc($option{'paper'}) =~ /EXECUTIVE/) {$pageWidth=540;  $pageHeight=720; }
  179. elsif ($option{'paper'}=~/(\d+)x(\d+)/) {
  180.    if ($1<72) {$pageWidth=72}  else {$pageWidth=$1}
  181.    if ($2<72) {$pageHeight=72} else {$pageHeight=$2}
  182.    }
  183. else {
  184.   if (($option{'paper'}) && (uc($option{'paper'}) !~ /LETTER/))
  185.     {&Warning("the set paper $option{'paper'} isn't supported\n$producer will use the default paper (letter)")}
  186.   }
  187.  
  188. if ($option{'landscape'}) {
  189.   my $tmp=$pageHeight;
  190.   $pageHeight=$pageWidth;
  191.   $pageWidth=$tmp;
  192.   }
  193. my $npagex=$pageWidth/2;
  194. my $npagey=20;
  195. my $typeencoding=$option{'typeencoding'};
  196. if (($typeencoding !~ /MacRomanEncoding/) && ($typeencoding !~ /MacExpertEncoding/) && ($typeencoding !~ /WinAnsiEncoding/) && ($typeencoding !~ /default/))
  197.   {&Warning("the set encoding $typeencoding isn't MacRomanEncoding or MacExpertEncoding or WinAnsiEncoding or default\n$producer will use the default encoding (ISOLatin1Encoding)")}
  198.  
  199. if ($option{'transition'} =~ /replace/) {$transition=""}
  200. elsif ($option{'transition'} =~ /dissolve/) {$transition="Dissolve"}
  201. elsif ($option{'transition'}=~/box!(.*)!/)
  202.   {
  203.   $transition="Box";
  204.   if ($1 eq "I" || $1 eq "O") {$motion=$1}
  205.   else     {
  206.     &Warning("the set motion $1 with $transition transition isn't supported\n$producer will use the $transition I (Input) motion");
  207.     $motion="I";
  208.     }
  209.   }
  210. elsif ($option{'transition'}=~/glitter!(.*)!/)
  211.   {
  212.   $transition="Glitter";
  213.   if ($1 == 0 || $1 == 270 || $1 == 315) {$direction=$1}
  214.   else
  215.     {&Warning("the set direction $1 with $transition transition isn't supported\n$producer will use the $transition 0 direction")}
  216.   }
  217. elsif ($option{'transition'}=~/wipe!(.*)!/)
  218.   {
  219.   $transition="Wipe";
  220.   if ($1 == 0 || $1 == 90 || $1 == 180 || $1 == 270) {$direction=$1}
  221.   else
  222.     {&Warning("the set direction $1 with $transition transition isn't supported\n$producer will use the $transition 0 direction")}
  223.   }
  224. elsif ($option{'transition'}=~/blinds!(.*)!/)
  225.   {
  226.   $transition="Blinds";
  227.   if ($1 eq "H" || $1 eq "V") {$dimension=$1}
  228.   else     {
  229.     &Warning("the set dimension $1 with $transition transition isn't supported\n$producer will use the $transition H dimension");
  230.     $dimension="H";
  231.     }
  232.   }
  233. elsif ($option{'transition'}=~/split!(.*)!(.*)!/)
  234.   {
  235.   $transition="Split";
  236.   if ($1 eq "H" || $1 eq "V") {$dimension=$1}
  237.   else     {
  238.     &Warning("the set dimension $1 with $transition transition isn't supported\n$producer will use the $transition H dimension");
  239.     $dimension="H";
  240.     }
  241.   if ($2 eq "I" || $2 eq "O") {$motion=$2}
  242.   else     {
  243.     &Warning("the set motion $1 with $transition transition isn't supported\n$producer will use the $transition I (Input) motion");
  244.     $motion="I";
  245.     }
  246.   }
  247. else { 
  248.   if ($option{'transition'})
  249.     {
  250.     &Warning("the set transition $option{'transition'} isn't supported\n$producer will use the default transition (replace)");
  251.     $option{'transition'}="";
  252.     }
  253.   }
  254.  
  255.   if (($option{'pagemode'} !~ /FullScreen/) && ($option{'pagemode'} ne "")){
  256.     &Warning("the set page mode $option{'pagemode'} isn't supported\n$producer will use the default page mode (UseNone)");
  257.     $option{'pagemode'}="";
  258.     }
  259.  
  260.   if (($option{'pagelayout'} !~ /OneColumn/) && ($option{'pagelayout'} !~ /TwoColumnRight/) && ($option{'pagelayout'} !~ /TwoColumnLeft/) && ($option{'pagelayout'} ne "")) {
  261.     &Warning("the set page layout $option{'pagelayout'} isn't supported\n$producer will use the default page layout (SinglePage)");
  262.     $option{'pagelayout'}="";
  263.     }
  264.  
  265. if ($option{'lines'}) {$lines = $option{'lines'}}
  266. else {$lines = ($pageHeight - 72) / $option{'vertSpace'}}
  267. $lines = int $lines;
  268. if (($option{'font'} !~ /Courier/) && ($option{'font'} !~ /Helvetica/) && ($option{'font'} !~ /Times/)) {
  269.   &Warning("the set font $option{'font'} isn't Courier or Helvetica or Times\n$producer will use the default font (Courier)");
  270.   $option{'font'}="Courier";
  271.   }
  272. if (($option{'rotate'} == 0) || ($option{'rotate'} == 90) || ($option{'rotate'} == 180) || ($option{'rotate'} == 270))
  273.   {$rotate=$option{'rotate'}}
  274. else {
  275.    &Warning("the set rotate $option{'rotate'} isn't supported\n$producer will use the default rotate (0)");
  276.    $rotate=0;
  277.    }
  278. if ($option{'colour'})
  279.   {
  280.   open (COLOUR, "$option{'colour'}") ||
  281.      die "txt2pdf: couldn't open colour file $option{'colour'}\n";
  282.   while (<COLOUR>) {
  283.     if (/^(.*);(.*)$/) {
  284.       $color[$colori*4]=$1;
  285.       ($color[$colori*4+1],$color[$colori*4+2],$color[$colori*4+3])=split(/:/,$2);
  286. #      if($color[$colori*4+1] > 1.0 || $color[$colori*4+2] > 1.0 || $color[$colori*4+3] > 1.0) {
  287. #        # Use 255 based color scheme
  288. #        my($i);
  289. #        for($i=1;$i<4;$i++){$color[$colori*4+$i] = sprintf("%4f",$color[$colori*4+$i]/255.0)}
  290. #        }
  291.       $colori++;
  292.       }
  293.     }
  294.   close(COLOUR);
  295.   }
  296. if ($option{'fontmark'})
  297.   {
  298.   open (FONTMARK, "$option{'fontmark'}") ||
  299.      die "txt2pdf: couldn't open fontmark file $option{'fontmark'}\n";
  300.   while (<FONTMARK>) {
  301.     if (/^(.*);(.*)$/) {
  302.       $fontmark[$fontmarki*2]=$1;
  303.       $fontmark[$fontmarki*2+1]=$2;
  304.       if    ($fontmark[$fontmarki*2+1] eq "bold") {$fontmark[$fontmarki*2+1]="/F3"}
  305.       elsif ($fontmark[$fontmarki*2+1] eq "italic") {$fontmark[$fontmarki*2+1]="/F2"}
  306.       elsif ($fontmark[$fontmarki*2+1] eq "bolditalic") {$fontmark[$fontmarki*2+1]="/F4"}
  307.       else {$fontmark[$fontmarki*2+1]="/F1"}
  308.       $fontmarki++;
  309.       }
  310.     }
  311.   close(FONTMARK);
  312.   }
  313. if ($option{'bgdesign'})
  314.   {
  315.   open (BGDESIGN, "$option{'bgdesign'}") ||
  316.      die "$producer: couldn't open background design file $option{'bgdesign'}\n";
  317.   while (<BGDESIGN>) {
  318.     s/\015$//;
  319.     if (/^#!epd#(.*);(.*);(.*);(.*);(.*);(.*);(.*)#!\/epd#$/) {
  320.       $epd[$epdi*9]=$1;
  321.       $epd[$epdi*9+2]=0;
  322.       $epd[$epdi*9+3]=$2;
  323.       $epd[$epdi*9+4]=$3;
  324.       $epd[$epdi*9+5]=$4;
  325.       $epd[$epdi*9+6]=$5;
  326.       $epd[$epdi*9+7]=$6;
  327.       $epd[$epdi*9+8]=$7;
  328.       $epdi++;
  329.       next;
  330.       }
  331.     $bgdesign.=$_;
  332.     }
  333.   close(BGDESIGN);
  334.   }
  335. if ($option{'fgdesign'})
  336.   {
  337.   open (FGDESIGN, "$option{'fgdesign'}") ||
  338.      die "$producer: couldn't open foreground design file $option{'fgdesign'}\n";
  339.   while (<FGDESIGN>) {s/\015$//;$fgdesign.=$_;}
  340.   close(FGDESIGN);
  341.   }
  342.  
  343. sub wanted {
  344.   if ($File::Find::name=~/$match/) {
  345.     push @ARGV,$File::Find::name;
  346.     }
  347.   }
  348.  
  349. if ($match && !$recursive) {
  350.    print "You can use -match option only with -recursive option\n";
  351.    exit;
  352.    }
  353.  
  354. SLEEP:
  355. if ($recursive) {
  356.   if($loop == 1) {
  357.     $match=~s/\./\\./g;
  358.     $match=~s/\*/.*/g;
  359.     $match=~s/\?/./g;
  360.     $match=~s/$/\$/;
  361.     }
  362.   @ARGV=();
  363.   find (\&wanted,"$recursive");
  364.   }
  365.  
  366. my $URy=$pageHeight - 42;
  367. my $tmpfile = $option{'tmpdir'} . "txt2pdf$$";
  368.  
  369.   if ($option{'beginfile'}) {
  370.     open (BEGINFILE,$option{'beginfile'}) ||
  371.       die qq!$producer: couldn't open input file $option{'beginfile'}\n!;
  372.     binmode BEGINFILE;
  373.     while(<BEGINFILE>) {
  374.       s/\r?\n$/\n/;
  375.       s/\r/\n/g;
  376.       $bflines++;
  377.       $_=&TAB($_);
  378.       $BF.=$_;
  379.       }
  380.     close(BEGINFILE);
  381.     }
  382.   if ($option{'endfile'}) {
  383.     open (ENDFILE,$option{'endfile'}) ||
  384.       die qq!$producer: couldn't open input file $option{'endfile'}\n!;
  385.     binmode ENDFILE;
  386.     while(<ENDFILE>) {
  387.       s/\r?\n$/\n/;
  388.       s/\r/\n/g;
  389.       $_=&TAB($_);
  390.       $EF.=$_;
  391.       }
  392.     close(ENDFILE);
  393.     }
  394.  
  395. if (@ARGV) {
  396.   my @files;
  397.   my $i;
  398.  
  399.   if ($^O =~ /^MSWin32$/i && !$recursive) {
  400.     foreach $i (@ARGV) {
  401.       if($i=~/\*|\?/) {push @files,glob($i)}
  402.       else {push @files,$i}
  403.       }
  404.     }
  405.   else {@files = @ARGV}
  406.   foreach $input (@files) {
  407.     $obj=0;
  408.     $pageNO=0;
  409.     $fpos=0;
  410.     @pageObj='';
  411.     $verbose and $times = time;
  412.     if(!$option{'title'}) {$title=basename($input,"")}
  413.     else {$title=$option{'title'}}
  414.     $verbose and print "Processing $input file\n";
  415.     if ($stdin) {open (OUT, ">-") || die "$producer: couldn't open standard output\n"}
  416.     else {
  417.       $output=$input;
  418.       $saveinput=$input;
  419.       my $out=basename($output,"");
  420.       if ($out=~/(.*)\..*/ and !$option{'withextension'}) {$out=~s/(.*)\..*/$1\.pdf/;}
  421.         else {$out.=".pdf";}
  422.       $output=dirname($output,"");
  423.   
  424.       if ($^O =~ /VMS/ ) {
  425. # On OpenVMS: Also don't add '/' if dir ends in ']' or ':'
  426. #    e.g. VMS filepecs look like
  427.         $output.="/" if ($output !~ /(\/|\\|]|:)$/ );
  428.       } elsif ($^O eq 'MacOS') {
  429.         $output.=":" if ($output !~ /:$/ ); # macs are a bit different...
  430.       } else {
  431. # concat '/' only if dir doesn't already end in a '/' or '\\'
  432.         $output.="/" if ($output !~ /(\/|\\)$/ );
  433.       }
  434.       $output.=$out;
  435.       open (OUT, ">$output") || die "$producer: couldn't open output file $output\n";
  436.     }
  437.     binmode OUT;
  438.     &ReorganizeFile($input);
  439.     &WriteLink($tmpfile);
  440.     &WriteHeader();
  441.     &WritePages($tmpfile);
  442.     &WriteRest();
  443.     close(OUT);
  444.  
  445.     # a simple user-interface enhancement
  446.     # make a MacOS double-clickable file
  447.     if ($^O eq 'MacOS') {MacPerl::SetFileInfo('CARO','PDF ', $output)}
  448.     $verbose and print "Writing $output file\n";
  449.     }
  450.     if ($^O =~ /VMS/ ) {
  451. # On OpenVMS, need While to delete all versions of tmpfile
  452.       while ( unlink($tmpfile) ) {};
  453.     } else {
  454.       unlink($tmpfile);
  455.     }
  456.   if($option{'txtdir'} ne "")
  457.     {
  458.     $newinput=$option{'txtdir'}.basename($saveinput);
  459.     rename $saveinput,$newinput;
  460.     $verbose and print "Moving $saveinput file in the $option{'txtdir'} directory\n";
  461.     }
  462.   if($option{'pdfdir'} ne "")
  463.     {
  464.     $newoutput=$option{'pdfdir'}.basename($output);
  465.     rename $output,$newoutput;
  466.     $verbose and print "Moving $output file in the $option{'pdfdir'} directory\n";
  467.     }
  468.   if ($verbose) {$timef = time; printf ("PDF generation time = %4.2f sec\n", $timef - $times );}
  469.   if($option{'sleep'}) {
  470.     sleep $option{'sleep'};
  471.     $loop++;
  472.     $verbose and print "\nLoop number $loop\n";
  473.     goto SLEEP;
  474.     }
  475.   } else {
  476.   print "$producer -help to read the online help\n";
  477.   if($option{'sleep'}) {
  478.     sleep $option{'sleep'};
  479.     $loop++;
  480.     $verbose and print "\nLoop number $loop\n";
  481.     goto SLEEP;
  482.     }
  483.   }
  484.  
  485. sub ReorganizeFile {
  486.   my $file=shift(@_);
  487.  
  488.   my $i;
  489.   my $temporary;
  490.   open (IN, "$file") || die "$producer: couldn't open input file $file\n";
  491.   open (TEMP, ">$tmpfile") || die "$producer: couldn't open temporary file $tmpfile\n";
  492.   binmode TEMP;
  493.   if($BF) {print TEMP "$BF"}
  494.   binmode IN;
  495.   while (<IN>) {
  496.     s/\r?\n$/\n/;
  497.     s/\r/\n/g;
  498.     $_ = &TAB($_);
  499.     print TEMP "$_";
  500.     }
  501.   if($EF) {print TEMP "$EF"}
  502.   print TEMP "\n";
  503.   print TEMP $Unregistered;
  504.   close(IN);
  505.   close(TEMP);
  506.   }
  507.  
  508. sub WriteLink {
  509.   my $file=shift(@_);
  510.  
  511.   # Start PDF
  512.   &pos("%PDF-1.2\n");
  513.   # It is recommended that the second line of a PDF file be a comment that
  514.   # contains at least four characters with codes 128 or greater
  515.   &pos("%Γπ╧╙\n");
  516.   $line=0;
  517.   $page=1;
  518.   open (IN, "$file") || die "$producer: couldn't open input file $file\n";
  519.   my $linktemp;
  520.   binmode IN;
  521.   while (<IN>) {
  522.     $line++;
  523.     $linktemp=$_;
  524.     while ($linktemp=~/(.*)((http|ftp|mailto|https|file|ldap|news):[^ \n)]+)( +|$|\))/i) {
  525.       $linktemp=$1;
  526.       &Link(length $1,length $2,$2,"url");
  527.       }
  528.     ##  14May99 - Modified to handle the mime: marker.  It's just a
  529.     ##            tweak of the original link test
  530.     while ($linktemp=~/(.*)(mime:[^ \n)]+)( +|$|\))/i) {
  531.       $linktemp=$1;
  532.       &Link(length $1,length $2,$2,"file");
  533.       }
  534.     if ($line == $lines) {
  535.         $line=0;
  536.         $page++;
  537.       }
  538.     }
  539.   close (IN);
  540.   }
  541.  
  542. sub WriteHeader {
  543.   my $sec=0; my $min=0; my $hour=0; my $mday=0; my $mon=0; my $year=0;
  544.   my $wday=0; my $yday=0; my $isdst=0; my $date="";
  545.   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
  546.   ++$mon;                              # $mon is 0..11
  547.   $year += 1900;
  548.   my $gm = (gmtime(time))[2];
  549.   my $local = (localtime(time))[2];
  550.   my $diff = $local - $gm;
  551.   if ($diff <= -12) { $diff += 24 }
  552.   elsif ($diff > 12) { $diff -= 24 }
  553.   my $zone = $diff;
  554.   if ($zone =~ /-/) {$zone = sprintf "%.2d00", $zone}
  555.   else  {$zone = sprintf "+%.2d00", $zone}
  556.   $date=sprintf "D:$year%.2ld%.2ld%.2ld%.2ld%.2ld$zone",$mon,$mday,$hour,$min,$sec;
  557.   $location[++$obj]=$fpos;
  558.   $info=$obj;
  559.   &pos("$obj 0 obj\n");
  560.   &pos("<<\n");
  561.   $option{'author'} and &pos("/Author ($option{'author'})\n");
  562.   &pos("/CreationDate ($date)\n");
  563.   $option{'creator'} and &pos("/Creator ($option{'creator'})\n");
  564.   &pos("/Producer ($producer v$version \\251 $companyname 2002)\n");
  565.   &pos("/Title ($title)\n");
  566.   $option{'subject'} and &pos("/Subject ($option{'subject'})\n");
  567.   $option{'keywords'} and &pos("/Keywords ($option{'keywords'})\n");
  568.   &pos(">>\n");
  569.   &pos("endobj\n");
  570.   $root=++$obj;
  571.   $Tpages=++$obj;
  572.   $epdn=($#epd+1)/9;
  573.   my $i=0;
  574.   my $epdbox="";
  575.   for (1..$epdn) {
  576.     open (EPD, $epd[$i*9]) || die "$producer: couldn't open image $epd[$i*9]\n";
  577.     binmode EPD;
  578.     while (<EPD>) {
  579.       s/\r?\n$/\n/;
  580.       s/\r/\n/g;
  581.       /BBox\((.*)\)/ and $epdbox=join(' ',split(/,/,$1));
  582.       }
  583.     $location[++$obj]=$fpos;
  584.     $epd[$i*9+2]=$obj;
  585.     &pos("$obj 0 obj\n");
  586.     &pos("<<\n/Type /XObject\n/Subtype /Form\n/FormType 1 /Name /Fm$i\n/Matrix [ 1 0 0 1 0 0 ]\n/BBox [ $epdbox ]\n");
  587.     $buf=sprintf "/Length %d 0 R ",$obj+1; &pos($buf);
  588.     &pos("/Resources << >> >>\n");
  589.     &pos("stream\n");
  590.     my $streamStart=$fpos;
  591.     open (EPD, $epd[$i*9]) || die "$producer: couldn't open image $epd[$i*9]\n";
  592.     binmode EPD;
  593.     while (<EPD>) {
  594.       / *%(.*)/ and next;
  595.       &pos("$_");
  596.       }
  597.     close(EPD);
  598.     my $streamEnd=$fpos;
  599.     &pos("\nendstream\n");
  600.     &pos("endobj\n");
  601.     $location[++$obj]=$fpos;
  602.     &pos("$obj 0 obj\n");
  603.     $buf=sprintf "%d\n",$streamEnd-$streamStart; &pos($buf);
  604.     &pos("endobj\n");
  605.     $i++;
  606.     }
  607.   my $encoding=$obj+5;
  608.   $resources=$obj+6;
  609.   $location[++$obj]=$fpos;
  610.   &pos("$obj 0 obj\n");
  611.   &pos("<<\n");
  612.   &pos("/Type /Font\n");
  613.   &pos("/Subtype /Type1\n");
  614.   &pos("/Name /F1\n");
  615.   &pos("/Encoding $encoding 0 R\n");
  616.   if ($option{'font'} eq "Times") {&pos("/BaseFont /$option{'font'}-Roman\n")}
  617.   else {&pos("/BaseFont /$option{'font'}\n")}
  618.   &pos(">>\n");
  619.   &pos("endobj\n");
  620.   $location[++$obj]=$fpos;
  621.   &pos("$obj 0 obj\n");
  622.   &pos("<<\n");
  623.   &pos("/Type /Font\n");
  624.   &pos("/Subtype /Type1\n");
  625.   &pos("/Name /F2\n");
  626.   &pos("/Encoding $encoding 0 R\n");
  627.   if ($option{'font'} eq "Times") {&pos("/BaseFont /$option{'font'}-Italic\n")}
  628.   else {&pos("/BaseFont /$option{'font'}-Oblique\n")}
  629.   &pos(">>\n");
  630.   &pos("endobj\n");
  631.   $location[++$obj]=$fpos;
  632.   &pos("$obj 0 obj\n");
  633.   &pos("<<\n");
  634.   &pos("/Type /Font\n");
  635.   &pos("/Subtype /Type1\n");
  636.   &pos("/Name /F3\n");
  637.   &pos("/Encoding $encoding 0 R\n");
  638.   &pos("/BaseFont /$option{'font'}-Bold\n");
  639.   &pos(">>\n");
  640.   &pos("endobj\n");
  641.   $location[++$obj]=$fpos;
  642.   &pos("$obj 0 obj\n");
  643.   &pos("<<\n");
  644.   &pos("/Type /Font\n");
  645.   &pos("/Subtype /Type1\n");
  646.   &pos("/Name /F4\n");
  647.   &pos("/Encoding $encoding 0 R\n");
  648.   if ($option{'font'} eq "Times") {&pos("/BaseFont /$option{'font'}-BoldItalic\n")}
  649.   else {&pos("/BaseFont /$option{'font'}-BoldOblique\n")}
  650.   &pos(">>\n");
  651.   &pos("endobj\n");
  652. # ISOLatin1Encoding
  653.   $location[++$obj]=$fpos;
  654.   &pos("$obj 0 obj\n");
  655.   &pos("<<\n");
  656.   &pos("/Type /Encoding\n");
  657.   if ($typeencoding eq "WinAnsiEncoding") {&pos("/BaseEncoding /WinAnsiEncoding\n")}
  658.   elsif ($typeencoding eq "MacRomanEncoding") {&pos("/BaseEncoding /MacRomanEncoding\n")}
  659.   elsif ($typeencoding eq "MacExpertEncoding") {&pos("/BaseEncoding /MacExpertEncoding\n")}
  660.   else {
  661.     &pos("/Differences [ 0 /.notdef /.notdef /.notdef /.notdef\n");
  662.     &pos("/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  663.     &pos("/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  664.     &pos("/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  665.     &pos("/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  666.     &pos("/.notdef /.notdef /.notdef /.notdef /space /exclam\n");
  667.     &pos("/quotedbl /numbersign /dollar /percent /ampersand\n");
  668.     &pos("/quoteright /parenleft /parenright /asterisk /plus /comma\n");
  669.     &pos("/hyphen /period /slash /zero /one /two /three /four /five\n");
  670.     &pos("/six /seven /eight /nine /colon /semicolon /less /equal\n");
  671.     &pos("/greater /question /at /A /B /C /D /E /F /G /H /I /J /K /L\n");
  672.     &pos("/M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft\n");
  673.     &pos("/backslash /bracketright /asciicircum /underscore\n");
  674.     &pos("/quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o /p\n");
  675.     &pos("/q /r /s /t /u /v /w /x /y /z /braceleft /bar /braceright\n");
  676.     &pos("/asciitilde /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  677.     &pos("/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  678.     &pos("/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
  679.     &pos("/dotlessi /grave /acute /circumflex /tilde /macron /breve\n");
  680.     &pos("/dotaccent /dieresis /.notdef /ring /cedilla /.notdef\n");
  681.     &pos("/hungarumlaut /ogonek /caron /space /exclamdown /cent\n");
  682.     &pos("/sterling /currency /yen /brokenbar /section /dieresis\n");
  683.     &pos("/copyright /ordfeminine /guillemotleft /logicalnot /hyphen\n");
  684.     &pos("/registered /macron /degree /plusminus /twosuperior\n");
  685.     &pos("/threesuperior /acute /mu /paragraph /periodcentered\n");
  686.     &pos("/cedilla /onesuperior /ordmasculine /guillemotright\n");
  687.     &pos("/onequarter /onehalf /threequarters /questiondown /Agrave\n");
  688.     &pos("/Aacute /Acircumflex /Atilde /Adieresis /Aring /AE\n");
  689.     &pos("/Ccedilla /Egrave /Eacute /Ecircumflex /Edieresis /Igrave\n");
  690.     &pos("/Iacute /Icircumflex /Idieresis /Eth /Ntilde /Ograve\n");
  691.     &pos("/Oacute /Ocircumflex /Otilde /Odieresis /multiply /Oslash\n");
  692.     &pos("/Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn\n");
  693.     &pos("/germandbls /agrave /aacute /acircumflex /atilde /adieresis\n");
  694.     &pos("/aring /ae /ccedilla /egrave /eacute /ecircumflex\n");
  695.     &pos("/edieresis /igrave /iacute /icircumflex /idieresis /eth\n");
  696.     &pos("/ntilde /ograve /oacute /ocircumflex /otilde /odieresis\n");
  697.     &pos("/divide /oslash /ugrave /uacute /ucircumflex /udieresis\n");
  698.     &pos("/yacute /thorn /ydieresis ]\n");
  699.     }
  700.   &pos(">>\n");
  701.   &pos("endobj\n");
  702.   $location[++$obj]=$fpos;
  703.   &pos("$obj 0 obj\n");
  704.   &pos("<<\n");
  705.   $buf=sprintf "  /Font << /F1 %d 0 R /F2 %d 0 R /F3 %d 0 R /F4 %d 0 R >>\n",
  706.        $obj-5, $obj-4, $obj-3, $obj-2;
  707.   &pos($buf);
  708.   &pos("  /ProcSet [ /PDF /Text ]\n");
  709.   &pos("  /XObject << ");
  710.   $i=0;
  711.   for (1..$epdn) {
  712.     &pos("/Fm$i $epd[$i*9+2] 0 R ");
  713.     $i++;
  714.     }
  715.   &pos(">>\n");
  716.   &pos(">>\n");
  717.   &pos("endobj\n");
  718.   }
  719.  
  720. sub WritePages {
  721.   my $file=shift(@_);
  722.  
  723.   my $columns="";
  724.   my $pageNO2=1;
  725.   my $temp;
  726.   my $i;
  727.   my $parseword;
  728.   my $thistest;
  729.   my $testfont;
  730.   my $converted=0;
  731.  
  732.   open (IN, "$file") || die "$producer: couldn't open input file $file\n";
  733.   my $beginstream = &StartPage();
  734.   $lineNO=-1;
  735.   binmode IN;
  736.   while (<IN>) {
  737.     $temp=$_;
  738.     $lineNO++;
  739.     if ($lineNO eq $lines) {
  740.       if ($option{'npage'}) {
  741.         &pos("/F2 $option{'pointSize'} Tf\n");
  742.         &pos("1 0 0 1 $npagex $npagey Tm\n($pageNO) Tj\n");
  743.         &pos("/F1 $option{'pointSize'} Tf\n");
  744.         }
  745.       &EndPage($beginstream);
  746.       $beginstream = &StartPage();
  747.       }
  748.     chop($temp);
  749.     $temp=~s/\\/\\\\/g;
  750.     $temp=~s/\(/\\(/g;
  751.     $temp=~s/\)/\\)/g;
  752.     &pos("T* (");
  753.     my $color=($#color+1)/4;
  754.     my $il=0;
  755.     for (1..$color) {
  756.       $temp=~s/($color[$il*4])/) Tj\n $color[$il*4+1] $color[$il*4+2] $color[$il*4+3] rg\n ($1) Tj\n 0 0 0 rg\n (/g;
  757.       $il++;
  758.       }
  759.     my $fontmark=($#fontmark+1)/2;
  760.     $il=0;
  761.     for (1..$fontmark) {
  762.       $temp=~s/($fontmark[$il*2])/) Tj\n $fontmark[$il*2+1] $option{'pointSize'} Tf\n ($1) Tj\n \/F1 $option{'pointSize'} Tf\n (/g;
  763.       $il++;
  764.       }
  765. #    if ($temp=~/((http|ftp|mailto|mime|https|file|ldap|news):[^ \n]*) /i)
  766. #      {
  767. #      $substring=") Tj\n 0 0 1 rg\n ($1) Tj\n 0 0 0 rg (";
  768. #      $temp=~s/$1/$substring/g;
  769. #      }
  770.     &pos("$temp");                                               
  771.     &pos(") Tj\n");
  772.     }
  773.   close(IN);
  774.   if ($option{'npage'}) {
  775.     &pos("/F2 $option{'pointSize'} Tf\n");
  776.     &pos("1 0 0 1 $npagex $npagey Tm\n($pageNO) Tj\n");
  777.     &pos("/F1 $option{'pointSize'} Tf\n");
  778.     }
  779.   &EndPage($beginstream);
  780.   }
  781.  
  782. # End PDF
  783. sub WriteRest {
  784.   my $i;
  785.   $location[$root]=$fpos;
  786.   &pos("$root 0 obj\n");
  787.   &pos("<<\n");
  788.   &pos("/Type /Catalog\n");
  789.   &pos("/Pages $Tpages 0 R\n");
  790. #  &pos("/OpenAction << /Dest [ 1 /XYZ null null 5 ] >>\n");
  791.   if ($option{'pagemode'}) {&pos("/PageMode /$option{'pagemode'}\n")};
  792.   if ($option{'pagelayout'}) {&pos("/PageLayout /$option{'pagelayout'}\n")};
  793.   if ($option{'viewerpreferences'}) {&pos("/ViewerPreferences <<$option{'viewerpreferences'}>>\n")}
  794.   if ($option{'fit'}) {&pos("/OpenAction <</S /GoTo /D [0 /Fit]>>\n")}
  795.   &pos(">>\n");
  796.   &pos("endobj\n");
  797.   $location[$Tpages]=$fpos;
  798.   &pos("$Tpages 0 obj\n");
  799.   &pos("<<\n");
  800.   &pos("/Type /Pages\n");
  801.   &pos("/Count $pageNO\n");
  802.   &pos("/MediaBox [ 0 0 $pageWidth $pageHeight ]\n");
  803.   &pos("/Kids [ ");
  804.   for ($i=1; $i<=$pageNO;$i++) {&pos("$pageObj[$i] 0 R ");}
  805.   &pos("]\n");
  806.   &pos(">>\n");
  807.   &pos("endobj\n");
  808.   my $xfer = $fpos;
  809.   &pos("xref\n");
  810.   $buf=sprintf "0 %d\n",$obj+1; &pos($buf);
  811.   &pos("0000000000 65535 f \n");
  812.   my $num="";
  813.   for ($i=1;$i<=$obj;$i++) {
  814.     $buf=sprintf "%.10ld 00000 n \n",$location[$i];
  815.     &pos($buf);
  816.     }
  817.   &pos("trailer\n");
  818.   &pos("<<\n");
  819.   $buf=sprintf "/Size %d\n",$obj+1; &pos($buf);
  820.   &pos("/Root $root 0 R\n");
  821.   &pos("/Info $info 0 R\n");
  822.   &pos(">>\n");
  823.   &pos("startxref\n");
  824.   &pos("$xfer\n");
  825.   &pos("%%EOF\n");
  826.   }
  827.  
  828. sub StartPage {
  829.  
  830.   $location[++$obj]=$fpos;
  831.   $pageObj[++$pageNO]=$obj;
  832.   &pos("$obj 0 obj\n");
  833.   &pos("<<\n");
  834.   &pos("/Type /Page\n");
  835.   &pos("/Parent $Tpages 0 R\n");
  836.   &pos("/Resources $resources 0 R\n");
  837.   $buf=sprintf "/Contents %d 0 R\n",++$obj; &pos($buf);
  838.   &pos("/Rotate $rotate\n");
  839.   if ($transition eq "Dissolve") {&pos("/Trans << /Type /Trans /S /$transition >>\n")}
  840.   if ($transition eq "Box") {&pos("/Trans << /Type /Trans /S /$transition /M /$motion >>\n")}
  841.   if ($transition eq "Glitter") {&pos("/Trans << /Type /Trans /S /$transition /Di $direction >>\n")}
  842.   if ($transition eq "Wipe") {&pos("/Trans << /Type /Trans /S /$transition /Di $direction >>\n")}
  843.   if ($transition eq "Blinds") {&pos("/Trans << /Type /Trans /S /$transition /Dm /$dimension >>\n")}
  844.   if ($transition eq "Split") {&pos("/Trans << /Type /Trans /S /$transition /Dm /$dimension /M /$motion >>\n")}
  845.   $annots[$pageNO] and &pos("/Annots [ $annots[$pageNO]]\n");
  846.   &pos(">>\n");
  847.   &pos("endobj\n");
  848.   $location[$obj]=$fpos;
  849.   &pos("$obj 0 obj\n");
  850.   &pos("<<\n");
  851.   $buf=sprintf "/Length %d 0 R\n",$obj+1; &pos($buf);
  852.   &pos(">>\n");
  853.   &pos("stream\n");
  854.   my $strmPos=$fpos;
  855.   my $i=0;
  856.   if ($epdn) {
  857.     $i=0;
  858.     for (1..$epdn) {
  859.       &pos("q $epd[$i*9+3] $epd[$i*9+4] $epd[$i*9+5] $epd[$i*9+6] $epd[$i*9+7] $epd[$i*9+8] cm /Fm$i Do Q\n");
  860.       $i++;
  861.       }
  862.     }
  863.   my $default=15;
  864.   my $Width=$pageWidth - $default;
  865.   my $Height=$pageHeight - $default;
  866.   if ($option{'border'}) {
  867.     &pos("2 w\n");
  868.     &pos("1 1 1 rg\n");
  869.     &pos("$default $default m\n$Width $default l\n");
  870.     &pos("$Width $default m\n$Width $Height l\n");
  871.     &pos("$Width $Height m\n$default $Height l\n");
  872.     &pos("$default $Height m\n$default $default l\n");
  873.     &pos("B*\n");
  874.     }
  875.   if ($bgdesign) {&pos("$bgdesign")}
  876.   &pos("BT\n");
  877.   &pos("/F1 $option{'pointSize'} Tf\n");
  878.   $buf=sprintf "1 0 0 1 50 %d Tm\n",$pageHeight-40; &pos($buf);
  879.   &pos("$option{'vertSpace'} TL\n");
  880.   return ($strmPos);
  881.   }
  882.  
  883. sub EndPage {
  884.   my $streamStart=shift(@_);
  885.   my $streamEnd=0;
  886.   &pos("ET\n");
  887.   if ($fgdesign) {&pos("$fgdesign")}
  888.   $streamEnd=$fpos;
  889.   &pos("endstream\n");
  890.   &pos("endobj\n");
  891.   $location[++$obj]=$fpos;
  892.   &pos("$obj 0 obj\n");
  893.   $buf=sprintf "%d\n",$streamEnd-$streamStart; &pos($buf);
  894.   &pos("endobj\n");
  895.   $lineNO=0;
  896.   }
  897.  
  898. sub Link {
  899.   my $linkbegin=shift(@_);
  900.   my $linkend=shift(@_);
  901.   my $link=shift(@_);
  902.   my $type=shift(@_);
  903.  
  904.   my $tmpline=$line;
  905.   $location[++$obj]=$fpos;
  906.   &pos("$obj 0 obj\n");
  907.   &pos("<<\n");
  908.   &pos("/A <<\n");
  909.   if ($type eq "url") {
  910.     &pos("/S /URI\n");
  911.     &pos("/URI ($link)\n");
  912.     } else {
  913.     &pos("/S /Launch\n");
  914.     my $slink = substr($link, 5); ## Pull the file: from the front
  915.     &pos("/F ($slink)\n");
  916.     }
  917.   &pos(">>\n");
  918.   &pos("/Type /Annot\n");
  919.   &pos("/Subtype /Link\n");
  920. # LLx LLy URx URy
  921.   if ($option{'font'} eq "Courier") {
  922.     $buf=sprintf "/Rect [%d %d %d %d]\n",
  923. $LLx+$linkbegin*$option{'pointSize'}*0.6,
  924. $URy-($tmpline)*($option{'vertSpace'}-$option{'pointSize'})-$tmpline*$option{'pointSize'},
  925. $LLx+($linkbegin+$linkend)*$option{'pointSize'}*0.6+$option{'pointSize'}*0.3,
  926. $URy-($tmpline)*($option{'vertSpace'}-$option{'pointSize'})-($tmpline-1)*$option{'pointSize'};
  927.     }
  928.   elsif ($option{'font'} eq "Helvetica") {
  929.     $buf=sprintf "/Rect [%d %d %d %d]\n",
  930. $LLx+$linkbegin*($option{'pointSize'}/2-1),
  931. $URy-($tmpline)*($option{'vertSpace'}-$option{'pointSize'})-$tmpline*$option{'pointSize'},
  932. $LLx+$linkbegin*($option{'pointSize'}/2-1)+($linkend+1)*($option{'pointSize'}/2-1),
  933. $URy-($tmpline)*($option{'vertSpace'}-$option{'pointSize'})-($tmpline-1)*$option{'pointSize'};
  934.     }
  935.   else {
  936.     $buf=sprintf "/Rect [%d %d %d %d]\n",
  937. $LLx+$linkbegin*($option{'pointSize'}/2-1),
  938. $URy-($tmpline)*($option{'vertSpace'}-$option{'pointSize'})-$tmpline*$option{'pointSize'},
  939. $LLx+$linkbegin*($option{'pointSize'}/2-1)+($linkend+1)*($option{'pointSize'}/2-1),
  940. $URy-($tmpline)*($option{'vertSpace'}-$option{'pointSize'})-($tmpline-1)*$option{'pointSize'};
  941.     }
  942.   &pos($buf);
  943. # Bordo azzurro
  944. #  &pos("/C [0 0 1]\n");
  945. # Rettangolo invisibile
  946.   &pos("/Border [0 0 0]\n");
  947.   &pos("/H /I\n");
  948.   &pos(">>\n");
  949.   &pos("endobj\n");
  950.   $annots[$page].="$obj 0 R ";
  951.   }
  952.  
  953. sub TAB {
  954.   my $line=shift(@_);
  955.   while($line=~/([^\t]*)\t/) {
  956.     my $spaces="";
  957.     my $spaceNO=$option{'tab'}-(length $1)%$option{'tab'};
  958.     for(1..$spaceNO) {$spaces.=" ";}
  959.     $line=~s/([^\t]*)\t/$1$spaces/;
  960.     }
  961.   return($line);
  962.   }
  963.  
  964. sub pos {
  965.   my $string = shift(@_);
  966.   $fpos+=length $string;
  967.   print OUT "$string";
  968.   }
  969.  
  970. sub Warning {
  971.   my $string = shift(@_);
  972.   print <<WARNING;
  973. Warning: $string
  974.  
  975. WARNING
  976.   }
  977.  
  978. sub printusage {
  979.     print <<USAGEDESC;
  980.  
  981. usage:
  982.         $producer [-options ...] list
  983.  
  984. where options include:
  985.     -help                        print out this message
  986.     -default                     print out the default parameters
  987.     -configure file              default $producer.cfg
  988.     -landscape
  989.     -list file                   a list of textual input files
  990.     -paper format                default letter, valid formats: A3 (or a3),
  991.                                  A4 (or a4), A5 (or a5), widthxheight
  992.     -npage                       add page number
  993.     -recursive directory         scan recursively the directory
  994.     -match     files             match different files ex. *.pdf, a?.*
  995.                                  (require -recursive option)
  996.     -border                      border line
  997.     -pdfdir directory            the directory where you want to put the PDFs
  998.     -txtdir directory            the directory where you want to put the texts
  999.     -current                     the program version
  1000.     -verbose                     verbose
  1001.     -                            use STDIN and STDOUT
  1002.  
  1003. list:
  1004.     with list you can use metacharacters and relative and absolute path name
  1005.  
  1006. example:
  1007.     $producer *.txt
  1008.     $producer -m "a*.txt" -r my_directory
  1009.  
  1010.  
  1011. If you want to know more about this tool, you might want
  1012. to read the docs. They came together with $producer!
  1013.  
  1014. Home: $txt2pdfHome
  1015.  
  1016. USAGEDESC
  1017.     exit(1);
  1018. }
  1019.  
  1020. sub defaultparams {
  1021.     print <<DEFAULTPARAMS;
  1022.  
  1023. tmpdir : ./
  1024. paper : letter
  1025. landscape : 0
  1026. font : Courier
  1027. npage : 0
  1028. lines : 60
  1029. tab : 8
  1030. pointSize : 10
  1031. vertSpace : 12
  1032. typeencoding : default
  1033.  
  1034. DEFAULTPARAMS
  1035.     exit(1);
  1036. }
  1037.  
  1038. exit 0;
  1039.  
  1040. # __END__
  1041.  
  1042. =head1 NAME
  1043.  
  1044. TXT2PDF - Version 5.6 25th March 2002
  1045.  
  1046. =head1 SYNOPSIS
  1047.  
  1048. Syntax : txt2pdf [-options] files
  1049.  
  1050. =head1 DESCRIPTION
  1051.  
  1052. TXT2PDF  is a very flexible and powerful PERL5 program.
  1053. It's a converter from text files to PDF format files.  
  1054.  
  1055. =head1 Features
  1056.  
  1057. TXT2PDF is a native converter,  you don't need to  pass through PostScript
  1058. format.  Some  feature  of TXT2PDF includes :
  1059.  
  1060.  o every   word  like  http://...   ftp://...   mailto:...   https://... 
  1061.    file:...  ldap:... news:...  will become an URL
  1062.  o every word like mime:... will become a link that launch the correct
  1063.    application and opens the file 
  1064.  o you can add page number in every page
  1065.  o you can add text at the beginning and at the end of every file
  1066.  o you can add a border to every page
  1067.  o you can use background and foreground layers
  1068.  o every predefined encodings (WinAnsiEncoding, MacRomanEncoding,
  1069.    MacExpertEncoding) supported inside the PDF format is
  1070.    supported + the Unix default
  1071.  o STDIN and STDOUT support
  1072.  
  1073. =head1 Options
  1074.  
  1075. where options include:
  1076.  
  1077.     -help                        print out this message
  1078.     -default                     print out the default parameters
  1079.     -configure file              default txt2pdf.cfg
  1080.     -landscape
  1081.     -list file                   a list of textual input files
  1082.     -paper format                default letter, valid formats: A3 (or a3),
  1083.                                  A4 (or a4), A5 (or a5), widthxheight
  1084.     -npage                       add page number
  1085.     -recursive directory         scan recursively the directory
  1086.     -match     files             match different files ex. *.pdf, a?.*
  1087.                                  (require -recursive option)
  1088.     -border                      border line
  1089.     -pdfdir directory            the directory where you want to put the PDFs
  1090.     -textdir directory           the directory where you want to put the texts
  1091.     -current                     the program version
  1092.     -verbose                     verbose
  1093.     -                            use STDIN and STDOUT
  1094.  
  1095. list:
  1096.  
  1097.    with list you can use metacharacters and relative and absolute path 
  1098.    name
  1099.  
  1100. -configure  filename:  with this option you can configure an alternate
  1101. configuration file (the default  configuration  file  is  txt2pdf.cfg,
  1102. located  in txt2pdf directory).  This option is very useful if you use
  1103. txt2pdf in a automatic task (e.g.  cron).  e.g.
  1104.  
  1105.   txt2pdf -c c.cfg *.c
  1106.   txt2pdf -m "a*.txt" -r my_directory
  1107.  
  1108. -match files -recursive directory: with  these option  you can convert 
  1109. all the files in the directory and in every its subdirectories
  1110. e.g
  1111. txt2pdf -m "a*.txt" -r .
  1112. to convert  every file  beginning with a and with txt extension to PDF
  1113. inside the . directory and in every its subdirectories 
  1114.  
  1115. Every file of the list is converted in a PDF file.  If the file has an
  1116. extension the extension is changed with .pdf extension,  if  the  file
  1117. doesn't have an extension the .pdf extension is added.
  1118.  
  1119. ASCII 8 chars are converted using ISO Latin1 Encoding
  1120.  
  1121. CreationDate (The date the document was created) in Info dictionary is
  1122. automatically set.
  1123.  
  1124. The   automatic   convertion   of  words  like  http://...   ftp://...
  1125. mailto:...  https://...  file:...  ldap:...  news:...  to URLs.
  1126.  
  1127. =cut
  1128.