36 function postscript($fname =
"", $author =
"",
$title =
"Generated with PSLib 0.4", $orientation =
"Portrait",
42 if (!$this->fp = fopen($fname,
"w"))
54 $this->
string .=
"%!PS-Adobe-3.0 \n";
55 $this->
string .=
'%%Creator: ' . $author .
" using PSLib (http://pslib.codigolivre.org.br)\n";
56 $this->
string .=
'%%CreationDate: ' . date(
"d/m/Y, H:i") .
"\n";
57 $this->
string .=
'%%LanguageLevel: 2';
58 $this->
string .=
'%%Title: ' .
$title .
"\n";
59 $this->
string .=
"%%PageOrder: Ascend \n";
60 $this->
string .=
'%%Orientation: ' . $orientation .
"\n";
61 $this->
string .=
"%%DocumentMedia: A4 595 842 0 () ()\n";
62 $this->
string .=
"%%EndComments \n";
63 $this->
string .=
"%%BeginProlog \n";
64 $this->
string .=
"%%BeginResource: definicoes \n";
67 if (!empty($this->resources))
69 foreach ($this->resources as $r)
71 $this->
string .= $r .
" \n";
75 $this->
string .=
"%%EndResource \n";
76 $this->
string .=
"%%EndProlog \n\n";
78 $this->
string .=
"/d {bind def} bind def \n";
79 $this->
string .=
"/D {def} d \n";
80 $this->
string .=
"/t true D \n";
82 .=
"/np {newpath} D /cp {closepath} D /gs {gsave} D /gr {grestore} D /sk {stroke} D /fl {fill} D /rt {rotate} D /s {show} D /ff {findfont} D /cf {scalefont setfont} d /mv {moveto} D /lw {setlinewidth} D /lt {lineto} D /sc {setrgbcolor} D /sp {showpage} D /rc {-1 -1 -1 sc} D \n";
84 if ($this->ISOLatin1 ==
true)
87 $this->
string .=
'/FL [';
88 $this->
string .=
'/Arial /Arial-Bold /Arial-Italic /Arial-BoldItalic ';
89 $this->
string .=
'/Times /Times-Roman /Times-Bold /Times-BoldItalic ';
90 $this->
string .=
'/Courier /Courier-Oblique /Courier-Bold /Courier-BoldOblique';
91 $this->
string .=
'/Helvetica /Helvetica-Oblique /Helvetica-Bold /Helvetica-BoldOblique';
94 if (!empty($this->fonts))
96 foreach ($this->fonts as $f)
98 $this->
string .=
"/$f ";
102 $this->
string .=
"] D \n";
106 dup dup findfont dup length dict
107 begin{1 index /FID ne{D}{pop pop}
111 .=
"/Encoding ISOLatin1Encoding D currentdict end definefont} D
113 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
114 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
115 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
116 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
117 /space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quoteright
118 /parenleft/parenright/asterisk/plus/comma/hyphen/period/slash
119 /zero/one/two/three/four/five/six/seven/eight/nine/colon/semicolon
120 /less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N
121 /O/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright
122 /asciicircum/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m
123 /n/o/p/q/r/s/t/u/v/w/x/y/z/braceleft/bar/braceright/asciitilde
124 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
125 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
126 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
127 /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
128 /.notdef/space/exclamdown/cent/sterling/currency/yen/brokenbar
129 /section/dieresis/copyright/ordfeminine/guillemotleft/logicalnot
130 /hyphen/registered/macron/degree/plusminus/twosuperior/threesuperior
131 /acute/mu/paragraph/periodcentered/cedilla/onesuperior/ordmasculine
132 /guillemotright/onequarter/onehalf/threequarters/questiondown
133 /Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla
134 /Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
135 /Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
136 /multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute
137 /Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis
138 /aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave
139 /iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex
140 /otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis
141 /yacute/thorn/ydieresis
145 .=
"[128/backslash 129/parenleft 130/parenright 141/circumflex 142/tilde
146 143/perthousand 144/dagger 145/daggerdbl 146/Ydieresis 147/scaron 148/Scaron
147 149/oe 150/OE 151/guilsinglleft 152/guilsinglright 153/quotesinglbase
148 154/quotedblbase 155/quotedblleft 156/quotedblright 157/endash 158/emdash
152 .=
"aload length 2 idiv 1 1 3 -1 roll{pop ISOLatin1Encoding 3 1 roll put}for
153 t{FL{ReencodeISO D}forall}{4 1 FL length 1 sub{FL E get ReencodeISO D}for}ifelse \n";
167 if ($this->ISOLatin1 ==
true)
171 if (!empty($this->fonts))
173 foreach ($this->fonts as $f)
185 $this->fonts[] = $font;
195 $this->
string .= $line .
" \n";
203 $this->resources[] = $res;
211 $this->ISOLatin1 = $var;
219 $this->
string .=
"%%Page: " . $page .
' ' .
$page .
"\n";
227 $this->
string .=
"sp \n";
235 $this->
string .=
"sp \n";
239 fwrite($this->fp, $this->
string);
243 return ($this->
string);
247 function line($xcoord_from = 0, $ycoord_from = 0, $xcoord_to = 0, $ycoord_to = 0, $linewidth = 0)
249 if ((!$xcoord_from) || (!$ycoord_to) || (!$xcoord_to) || (!$ycoord_to) || (!$linewidth))
252 $this->
string .= $linewidth .
" lw ";
253 $this->
string .= $xcoord_from .
' ' . $ycoord_from .
" mv \n";
254 $this->
string .= $xcoord_to .
' ' . $ycoord_to .
" lt \n";
255 $this->
string .=
"sk \n";
263 if ((empty($xcoord)) || (empty($ycoord)))
266 $this->
string .= $xcoord .
' ' . $ycoord .
" mv \n";
274 if ((!$xcoord) || (!$ycoord) || (!$font_name) || (!$font_size))
277 $this->
string .= $xcoord .
' ' . $ycoord .
" mv \n";
278 $this->
string .=
'/' . $font_name .
' ff ' . $font_size .
" cf \n";
292 if ($f = join(
'', file($ps_file)))
301 function circle($xcoord, $ycoord, $ray, $linewidth)
303 if ((!$xcoord) || (!$ycoord) || (!$ray) || (!$linewidth))
306 $this->
arc($xcoord, $ycoord, $ray, $linewidth, 1, 360);
314 if ((!$xcoord) || (!$ycoord) || (!$ray) || (!$linewidth) || (!
$red) || (!
$green) || (!
$blue))
323 function arc($xcoord, $ycoord, $ray, $linewidth, $angle_start, $angle_end)
325 if ((!$xcoord) || (!$ycoord) || (!$ray) || (!$angle_start) || (!$angle_end) || (!$linewidth))
328 $this->
string .=
"np \n";
329 $this->
string .= $linewidth .
" lw \n";
330 $this->
string .= $xcoord .
' ' . $ycoord .
' ' . $ray .
' ' . $angle_start .
' ' . $angle_end .
" arc \n";
331 $this->
string .=
"cp \n";
332 $this->
string .=
"sk \n";
341 if ((!$xcoord) || (!$ycoord) || (!$ray) || (!$angle_start) || (!$angle_end) || (!$linewidth))
344 $this->
string .=
"np \n";
345 $this->
string .= $linewidth .
" lw \n";
346 $this->
string .= $xcoord .
' ' . $ycoord .
' ' . $ray .
' ' . $angle_start .
' ' . $angle_end .
" arc \n";
347 $this->
string .=
"cp \n";
350 $this->
string .=
"gs \n";
352 $this->
string .=
"$red $green $blue sc fl\n";
355 $this->
string .=
"gr \n";
357 $this->
string .=
"sk \n";
363 function rect($xcoord_from, $ycoord_from, $xcoord_to, $ycoord_to, $linewidth)
365 if ((!$xcoord_from) || (!$ycoord_from) || (!$xcoord_to) || (!$ycoord_to) || (!$linewidth))
368 $this->
string .= $linewidth .
" lw \n";
369 $this->
string .=
"np \n";
370 $this->
string .= $xcoord_from .
' ' . $ycoord_from .
" mv \n";
371 $this->
string .= $xcoord_to .
' ' . $ycoord_from .
" lt \n";
372 $this->
string .= $xcoord_to .
' ' . $ycoord_to .
" lt \n";
373 $this->
string .= $xcoord_from .
" " . $ycoord_to .
" lt \n";
374 $this->
string .=
"cp \n";
375 $this->
string .=
"sk \n";
384 if ((!$xcoord_from) || (!$ycoord_from) || (!$xcoord_to) || (!$ycoord_to) || (!$linewidth) || (!
$red)
388 $this->
string .=
"np \n";
389 $this->
string .= $linewidth .
" lw \n";
390 $this->
string .= $xcoord_from .
' ' . $ycoord_from .
" mv \n";
391 $this->
string .= $xcoord_to .
' ' . $ycoord_from .
" lt \n";
392 $this->
string .= $xcoord_to .
' ' . $ycoord_to .
" lt \n";
393 $this->
string .= $xcoord_from .
' ' . $ycoord_to .
" lt \n";
394 $this->
string .=
"cp \n";
397 $this->
string .=
"gs \n";
399 $this->
string .=
"$red $green $blue sc fl \n";
402 $this->
string .=
"gr \n";
404 $this->
string .=
"sk \n";
416 if (($degrees ==
'0') or ($degrees ==
'360'))
418 $this->
string .=
"gr \n";
422 $this->
string .=
"gs \n";
423 $this->
string .= $degrees .
" rt \n";
432 if ((!$font_name) || (!$font_size))
435 $this->
string .=
'/' . $font_name .
' ff ' . $font_size .
" cf \n";
463 $restart_color =
true;
470 $this->
string .=
"( $text ) dup stringwidth pop 2 div neg 0 rmoveto s \n";
475 $this->
string .=
"( $text ) dup stringwidth pop neg 0 rmoveto s \n";
480 $this->
string .=
"( $text ) s \n";
489 $this->
set_color($red1, $green1, $blue1);
502 eval (
"\$text = \"$text\";");
503 $this->
string .=
'(' . $text .
") s \n";
512 if ((!$text) || (!$xcoord) || (!$ycoord))
515 $this->
moveto($xcoord, $ycoord);
526 if ((!$text) || (!$xcoord) || (!$ycoord) || (!$font_name) || (!$font_size))
529 $this->
set_font($font_name, $font_size);
544 $this->
string .=
"rc \n";
548 $this->
string .=
"$red $green $blue sc \n";
rect_fill($xcoord_from, $ycoord_from, $xcoord_to, $ycoord_to, $linewidth, $red, $green, $blue, $border=false)
arc($xcoord, $ycoord, $ray, $linewidth, $angle_start, $angle_end)
show($text, $red='', $green='', $blue='', $justify='l')
show_xy_font($text, $xcoord, $ycoord, $font_name, $font_size, $red='', $green='', $blue='', $justify='l')
line($xcoord_from=0, $ycoord_from=0, $xcoord_to=0, $ycoord_to=0, $linewidth=0)
show_xy($text, $xcoord, $ycoord, $red='', $green='', $blue='', $justify='l')
circle($xcoord, $ycoord, $ray, $linewidth)
arc_fill($xcoord, $ycoord, $ray, $linewidth, $angle_start, $angle_end, $red, $green, $blue, $border=false)
encode_ISOLatin1($var=true)
circle_fill($xcoord, $ycoord, $ray, $linewidth, $red, $green, $blue, $border=false)
rect($xcoord_from, $ycoord_from, $xcoord_to, $ycoord_to, $linewidth)
postscript($fname="", $author="", $title="Generated with PSLib 0.4", $orientation="Portrait", $fonts="")
moveto_font($xcoord, $ycoord, $font_name, $font_size)
set_font($font_name, $font_size)
set_color($red=-1, $green=-1, $blue=-1)