Martin Vermeer wrote:

> On Thu, Jun 12, 2003 at 01:57:13PM +0000, Angus Leeming spake thusly:
>  
>> Martin Vermeer wrote:
>> >> In this latter case, the script generates pstex and pstex_t output and
>> >> then converts the image to png using gs. I tried to generate a pdf
>> >> image rather than a png one but failed :-(
>> > 
>> > I use epstopdf manually (part of tetex) and works fine. It's a perl
>> > script and might give you ideas what to do.
>> 
>> Wonderful! Thank you. (The script simply invokes it).
> 
> Problem: can we count on its presence? (tetex may not be always the
> distro used, though it is recommended) Inclusion in our scripts is of
> course an option, but then you have to have perl (do we anyway?).
> 
> As this is meant only for a small subset of epses generated by one
> program, trimming it down and sh-fying it might be worthwhile.

Maybe. Actually, it doesn't look too bad.

It generates a pdf file using gs
        gs -q -sDEVICE=pdfwrite -sOutputFile=${output} ${input}

and it manipulates the input eps file to ensure that the BoundingBox info is 
appropriate for pdf output. Should be easy enough.

Angus


### variables and pattern for BoundingBox search
my $bbxpatt = '[0-9eE\.\-]';
               # protect backslashes: "\\" gets '\'
my $BBValues = 
"\\s*($bbxpatt+)\\s+($bbxpatt+)\\s+($bbxpatt+)\\s+($bbxpatt+)";
my $BBCorrected = 0;

sub CorrectBoundingBox {
  my ($llx, $lly, $urx, $ury) = @_;
  debug "Old BoundingBox:", $llx, $lly, $urx, $ury;
  my ($width, $height) = ($urx - $llx, $ury - $lly);
  my ($xoffset, $yoffset) = (-$llx, -$lly);
  debug "New BoundingBox: 0 0", $width, $height;
  debug "Offset:", $xoffset, $yoffset;

  print OUT "%%BoundingBox: 0 0 $width $height\n";
  print OUT "<< /PageSize [$width $height] >> setpagedevice\n";
  print OUT "gsave $xoffset $yoffset translate\n";
}


Reply via email to