Example #1
0
function footer($ps, $text)
{
    $psfont = ps_findfont($ps, "Helvetica", "", 0);
    ps_setfont($ps, $psfont, 8.0);
    $buffer = "This file has been created with pslib " . ps_get_parameter($ps, "dottedversion", 0.0);
    ps_show_xy($ps, $buffer, LEFT_BORDER, 25);
}
Example #2
0
 function PS_GRenderer($format = null, $orientation = 'landscape')
 {
     // Null size does not create a graphic.
     $this->styles = array();
     $this->font = null;
     if (!is_null($format)) {
         $size = $this->_getFormat($format, $orientation);
         $this->width = $size[0];
         $this->height = $size[1];
         $this->ps = ps_new();
         ps_open_file($this->ps, '');
         ps_begin_page($this->ps, $this->width, $this->height);
         $this->font = ps_findfont($this->ps, 'Helvetica', '', 0);
     }
 }
Example #3
0
 ps_moveto($ps, 0, 0);
 ps_lineto($ps, 7, 7);
 ps_stroke($ps);
 ps_moveto($ps, 0, 7);
 ps_lineto($ps, 7, 0);
 ps_stroke($ps);
 ps_end_pattern($ps);
 $pspattern2 = ps_begin_pattern($ps, 10.0, 10.0, 10.0, 10.0, 2);
 ps_moveto($ps, 0, 0);
 ps_lineto($ps, 5, 5);
 ps_stroke($ps);
 ps_end_pattern($ps);
 ps_begin_page($ps, 596, 842);
 ps_set_parameter($ps, "transition", "wipe");
 ps_set_value($ps, "duration", 0.5);
 $psfont = ps_findfont($ps, "{$fontdir}/Helvetica", "", 0);
 $x = 0;
 $y = 675;
 if (isset($_REQUEST['box1']) && $_REQUEST['box1'] == "true") {
     if ($x > 3) {
         $y -= 150;
         $x = 0;
     }
     begin_example_box($ps, LEFT_BORDER + (EXAMPLE_BOX_WIDTH + 30) * $x++, $y, "Lines", $psfont);
     $polydash = array(5.0, 3.0, 1.0, 4.0);
     ps_moveto($ps, 10, 10);
     ps_lineto($ps, 90, 10);
     ps_stroke($ps);
     ps_setdash($ps, 5.0, 5.0);
     ps_moveto($ps, 10, 15);
     ps_lineto($ps, 90, 30);
Example #4
0
$leftmargin = 100;
$bottommargin = 270;
$fontsize = 10.0;
$fontsamplesize = 12.0;
if ($_SERVER["argc"] < 2) {
    usage();
    exit(1);
}
ps_set_parameter($ps, "hyphenation", "true");
ps_set_parameter($ps, "hyphendict", "hyph_en.dic");
$psfont = ps_findfont($ps, "Helvetica", "", 0);
printf("Creating %d pages\n", $_SERVER["argc"] - 1);
for ($k = 1; $k < $_SERVER["argc"]; $k++) {
    printf("Creating page for %s\n", $_SERVER["argv"][$k]);
    ps_begin_page($ps, 596, 842);
    $samplefont = ps_findfont($ps, $_SERVER["argv"][$k], "", 1);
    ps_setfont($ps, $psfont, 15.0);
    $text = sprintf("Fontsample for '%s'", ps_get_parameter($ps, "fontname", $samplefont));
    ps_show_xy($ps, $text, $leftmargin, $bottommargin + 20 * $rowheight);
    ps_setfont($ps, $psfont, 10.0);
    ps_show_xy($ps, "Font encoding: ", $leftmargin, $bottommargin + 19.0 * $rowheight);
    ps_show($ps, ps_get_parameter($ps, "fontencoding", $samplefont));
    ps_show_xy($ps, "capheight: ", $leftmargin, $bottommargin + 18.5 * $rowheight);
    $text = sprintf("%.2f", ps_get_value($ps, "capheight", $samplefont));
    ps_show($ps, $text);
    ps_show_xy($ps, "ascender: ", $leftmargin, $bottommargin + 18.0 * $rowheight);
    $text = sprintf("%.2f", ps_get_value($ps, "ascender", $samplefont));
    ps_show($ps, $text);
    ps_show_xy($ps, "descender: ", $leftmargin, $bottommargin + 17.5 * $rowheight);
    $text = sprintf("%.2f", ps_get_value($ps, "descender", $samplefont));
    ps_show($ps, $text);
Example #5
0
 /**
  * Set the PostScript font
  *
  * @access private
  */
 function _setFont()
 {
     $this->_psFont = false;
     if (isset($this->_font['name'])) {
         ps_set_parameter($this->_ps, 'FontOutline', $this->_font['name'] . '=' . $this->_font['file']);
         $this->_psFont = ps_findfont($this->_ps, $this->_font['name'], $this->_font['encoding'], $this->_font['embed']);
         if ($this->_psFont) {
             ps_setfont($this->_ps, $this->_psFont, $this->_font['size']);
             $this->_setFillStyle($this->_font['color']);
         }
     } else {
         $this->_setFillStyle('black');
     }
 }
Example #6
0
ps_restore($ps);
$buffer = sprintf("%.0f x %.0f pixel", ps_get_value($ps, "imagewidth", $psimage), ps_get_value($ps, "imageheight", $psimage));
ps_setfont($ps, $psfont, 10.0);
ps_show_xy($ps, $buffer, EXAMPLE_BOX_WIDTH - 10 - ps_stringwidth($ps, $buffer, $psfont, 10), 10);
end_example_box($ps);
begin_example_box($ps, LEFT_BORDER + (EXAMPLE_BOX_WIDTH + 30) * $x++, $y, "EPS read from memory", $psfont);
$data = file_get_contents("picture.eps");
$psimage = ps_open_image($ps, "eps", "memory", $data, strlen($data), 0, 0, 0, 0, NULL);
ps_place_image($ps, $psimage, 15, 25, 0.45);
$buffer = sprintf("%.0f x %.0f pixel", ps_get_value($ps, "imagewidth", $psimage), ps_get_value($ps, "imageheight", $psimage));
ps_setfont($ps, $psfont, 10.0);
ps_show_xy($ps, $buffer, EXAMPLE_BOX_WIDTH - 10 - ps_stringwidth($ps, $buffer, $psfont, 10), 10);
end_example_box($ps);
ps_end_page($ps);
ps_begin_page($ps, 596, 842);
$psfont = ps_findfont($ps, "Helvetica", "", 0);
ps_setfont($ps, $psfont, 12.0);
$x = 0;
$y = 625;
begin_example_box($ps, LEFT_BORDER + (EXAMPLE_BOX_WIDTH + 30) * $x++, $y, "Gif image", $psfont);
$psimage = ps_open_image_file($ps, "gif", "debian.gif", NULL, 0);
ps_place_image($ps, $psimage, 25, 10, 2.0);
end_example_box($ps);
begin_example_box($ps, LEFT_BORDER + (EXAMPLE_BOX_WIDTH + 30) * $x++, $y, "Gif image with transparency", $psfont);
$psimage = ps_open_image_file($ps, "gif", "debian-transparent.gif", NULL, 0);
ps_place_image($ps, $psimage, 25, 10, 2.0);
end_example_box($ps);
begin_example_box($ps, LEFT_BORDER + (EXAMPLE_BOX_WIDTH + 30) * $x++, $y, "Gif image interlaced", $psfont);
$psimage = ps_open_image_file($ps, "gif", "interlaced.gif", NULL, 0);
ps_place_image($ps, $psimage, 10, 10, 0.65);
end_example_box($ps);
Example #7
0
ps_moveto($ps, 0, 0);
ps_lineto($ps, 7, 7);
ps_stroke($ps);
ps_moveto($ps, 0, 7);
ps_lineto($ps, 7, 0);
ps_stroke($ps);
ps_end_pattern($ps);
$pspattern2 = ps_begin_pattern($ps, 10.0, 10.0, 10.0, 10.0, 2);
ps_moveto($ps, 0, 0);
ps_lineto($ps, 5, 5);
ps_stroke($ps);
ps_end_pattern($ps);
ps_begin_page($ps, 596, 842);
ps_set_parameter($ps, "transition", "wipe");
ps_set_value($ps, "duration", 0.5);
$psfont = ps_findfont($ps, "htdocs/xampp/external/ps/Helvetica", "", 0);
$x = 0;
$y = 675;
begin_example_box($ps, LEFT_BORDER + (EXAMPLE_BOX_WIDTH + 30) * $x++, $y, "Lines", $psfont);
$polydash = array(5.0, 3.0, 1.0, 4.0);
ps_moveto($ps, 10, 10);
ps_lineto($ps, 90, 10);
ps_stroke($ps);
ps_setdash($ps, 5.0, 5.0);
ps_moveto($ps, 10, 15);
ps_lineto($ps, 90, 30);
ps_stroke($ps);
ps_setdash($ps, 0.0, 0.0);
ps_setlinewidth($ps, 2.0);
ps_moveto($ps, 10, 20);
ps_lineto($ps, 90, 50);
Example #8
0
<?php

$ps = ps_new();
if (!ps_open_file($ps, "D:/xampp/htdocs/xampp/external/ps/text.ps")) {
    print "Cannot open PostScript file\n";
    exit;
}
ps_set_parameter($ps, "warning", "false");
ps_set_info($ps, "Creator", "text.php");
ps_set_info($ps, "Author", "Uwe Steinmann");
ps_set_info($ps, "Title", "Text output");
ps_set_info($ps, "BoundingBox", "0 0 596 842");
ps_set_info($ps, "Orientation", "Portrait");
if (!($font = ps_findfont($ps, "Dustismo", "builtin", 1))) {
    echo "Could not find font.\n";
    exit;
}
ps_begin_page($ps, 596, 842);
ps_setfont($ps, $font, 14.0);
ps_show_xy($ps, "Text starting at position (100, 700) with kerning", 100, 700);
ps_set_parameter($ps, "kerning", "false");
ps_show_xy($ps, "Text starting at position (100, 670) without kerning", 100, 670);
ps_set_parameter($ps, "kerning", "true");
ps_set_parameter($ps, "underline", "true");
ps_show_xy($ps, "Text starting at position (100, 640) with underlining", 100, 640);
ps_set_parameter($ps, "underline", "false");
ps_set_parameter($ps, "overline", "true");
ps_show_xy($ps, "Text starting at position (100, 610) with overlining", 100, 610);
ps_set_parameter($ps, "overline", "false");
ps_set_parameter($ps, "strikeout", "true");
ps_show_xy($ps, "Text starting at position (100, 580) striked out", 100, 580);