File: gs-eps.2

package info (click to toggle)
texlive-doc 2005.dfsg.2-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 125,100 kB
  • ctags: 12,558
  • sloc: xml: 24,267; perl: 14,394; makefile: 727; sh: 324; lisp: 276; java: 159; sed: 4
file content (41 lines) | stat: -rw-r--r-- 1,062 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
open (EPSFILE,$epsfile);

undef $bbox;
undef $showpg;
while (<EPSFILE>) {
  $bbox = $_ if /\%\%\s*BoundingBox:\s*\d+\s+\d+\s+\d+\s+\d+/;
  $showpage = $_ if /showpage/;
  last if ($bbox && $showpage);
  }

if (! $bbox) {
  printf "Cannot find a bounding box in $epsfile";
  exit 1;
  }

$bbox =~ s/\D*//;   # remove everything preceding the digits

($llx,$lly,$urx,$ury) = split(/\s/,$bbox);

$xsize = sprintf("%d", (($urx - $llx) * $res / 72) + 0.5);
$ysize = sprintf("%d", (($ury - $lly) * $res / 72) + 0.5);

printf "$llx neg $lly neg translate .gt. gs-eps-a.$$\n";
printf "quit .gt. gs-eps-b.$$\n";

if (! $showpg) {
  printf "showpage .gt. gs-eps-b.$$\n";
  printf "quit .gtgt. gs-eps-b.$$\n";
  }

# join sillyness to keep the length of lines in the
# script small enough to print in the book.
$gscmd = join(" ", "gs -sDEVICE=$device",
                   "-q -sOutputFile=$outputfile",
                   "-g${xsize}x${ysize} -r$res",
	 	   "gs-eps-a.$$ $epsfile -",
		   ".lt. gs-eps-b.$$");

printf "$gscmd\n";

printf "rm -f gs-eps-a.$$ gs-eps-b.$$\n";