Ejemplo n.º 1
0
        $str2 = "Text can be put into a box of any size. This one is 80x80 pixels and its lower left corner ist at (10, 10). The text is left and right justified. The font size is 8.0.";
        ps_show_boxed($ps, $str2, 10, 10, 80, 80, "justify", NULL);
        end_example_box($ps);
    }
    if (isset($_REQUEST['box16']) && $_REQUEST['box16'] == "true") {
        if ($x > 3) {
            $y -= 150;
            $x = 0;
        }
        begin_example_box($ps, LEFT_BORDER + (EXAMPLE_BOX_WIDTH + 30) * $x++, $y, "Text with CR", $psfont);
        ps_setfont($ps, $psfont, 8.0);
        ps_set_value($ps, "leading", 11);
        ps_set_parameter($ps, "linebreak", "true");
        $str4 = "If the parameter linebreak is turned on\neach line will be ended with a carriage return.\nCR are marked with a '\\n' in this paragraph.";
        ps_show_boxed($ps, $str4, 10, 10, 80, 80, "center", NULL);
        ps_set_parameter($ps, "linebreak", "false");
        end_example_box($ps);
    }
    ps_end_page($ps);
    ps_close($ps);
    ps_delete($ps);
}
for ($x = 1; $x <= 16; $x++) {
    $checked[$x] = "";
}
foreach ($_GET as $key => $value) {
    list($nothing, $number) = split('box', $key);
    if ($value == "true") {
        $checked[$number] = "checked";
    } else {
        $checked[$number] = "";
Ejemplo n.º 2
0
ps_set_info($ps, "Creator", "fontsample.php");
ps_set_info($ps, "Author", "Uwe Steinmann");
ps_set_info($ps, "Title", "Font sample");
ps_set_info($ps, "BoundingBox", "0 0 596 842");
$colwidth = 25;
$rowheight = 25;
$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);
Ejemplo n.º 3
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');
     }
 }
Ejemplo n.º 4
0
    ps_rect($p, 0, 0, EXAMPLE_BOX_WIDTH, EXAMPLE_BOX_HEIGHT);
    ps_stroke($p);
    ps_moveto($p, 0, EXAMPLE_BOX_HEIGHT - EXAMPLE_BOX_TITLE_HEIGHT);
    ps_lineto($p, EXAMPLE_BOX_WIDTH, EXAMPLE_BOX_HEIGHT - EXAMPLE_BOX_TITLE_HEIGHT);
    ps_stroke($p);
}
function end_example_box($p)
{
    ps_restore($p);
}
$ps = ps_new();
if (!ps_open_file($ps, "D:/xampp/htdocs/xampp/external/ps/image.ps")) {
    print "Cannot open PostScript file\n";
    exit;
}
ps_set_parameter($ps, "warning", "true");
ps_set_info($ps, "Creator", "image.php");
ps_set_info($ps, "Author", "Uwe Steinmann");
ps_set_info($ps, "Title", "Image examples");
ps_begin_page($ps, 596, 842);
$psfont = ps_findfont($ps, "D:/xampp/htdocs/xampp/external/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, "Indexed image without alpha channel", $psfont);
$psimage = ps_open_image_file($ps, "png", "indexed.png", NULL, 0);
ps_place_image($ps, $psimage, 10, 30, 1.0);
$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);
Ejemplo n.º 5
0
ps_set_value($ps, "charspacing", 0.0);
ps_show_xy($ps, "Some text which will be continued ...", 100, 400);
ps_continue_text($ps, "... in the next line ...");
ps_set_value($ps, "leading", 30);
ps_continue_text($ps, "... and another one with leading set to 30.");
ps_setcolor($ps, "both", "rgb", 1.0, 0.0, 0.0, 0.0);
ps_show_xy($ps, "Text can be written in color.", 100, 340);
ps_end_page($ps);
ps_begin_page($ps, 596, 842);
ps_setfont($ps, $font, 14.0);
ps_set_value($ps, "leading", 16);
ps_show_boxed($ps, "Text can be put into a box. It will automatically line wrapped. The text can left or right justified or centered. The given coordinates specify the lower left corner.", 100, 550, 100, 200, "left");
ps_show_boxed($ps, "Text can be put into a box. It will automatically line wrapped. The text can left or right justified or centered. The given coordinates specify the lower left corner.", 235, 550, 100, 200, "center");
ps_show_boxed($ps, "Text can be put into a box. It will automatically line wrapped. The text can left or right justified or centered. The given coordinates specify the lower left corner.", 370, 550, 100, 200, "right");
ps_set_value($ps, "leading", 30);
$text = "The line spacing (leading) can be set as on page 1. If the text does not fit into the box, it will be cut off. The string length of the remaining text is returned. This makes it quite easy to continue the remaining text in a second, third, fourth etc. box.";
$len = ps_show_boxed($ps, $text, 100, 320, 100, 200, "justify");
$len = ps_show_boxed($ps, substr($text, strlen($text) - $len), 235, 320, 100, 200, "justify");
$len = ps_show_boxed($ps, substr($text, strlen($text) - $len), 370, 320, 100, 200, "justify");
ps_set_value($ps, "leading", 20);
ps_set_parameter($ps, "hyphenation", "true");
ps_set_parameter($ps, "hyphendict", "D:/xampp/htdocs/xampp/external/ps/hyph_en.dic");
ps_set_value($ps, "hyphenminchars", 2);
$text = "You wonder if hyphenation is supported? Yes, of course and it uses the hyphenation files from scribus. Scribus provides hyphenation dictionaries for 14 languages. Another nice feature is Protution. This means that certain characters reach over the left or right margin. This is very useful for hyphens or punctuation to make straight looking margins like the one in the first column (it is very exaggerated).";
ps_set_parameter($ps, "RightMarginKerning", "hyphen=1000");
$len = ps_show_boxed($ps, $text, 100, 90, 100, 200, "justify");
$len = ps_show_boxed($ps, substr($text, strlen($text) - $len), 235, 90, 100, 200, "right");
$len = ps_show_boxed($ps, substr($text, strlen($text) - $len), 370, 90, 100, 200, "left");
ps_end_page($ps);
ps_close($ps);
ps_delete($ps);
Ejemplo n.º 6
0
$radius = 200;
$margin = 20;
$pagecount = 300;
$ps = ps_new();
if (!ps_open_file($ps, "psclock.ps")) {
    print "Cannot open PostScript file\n";
    exit;
}
ps_set_parameter($ps, "warning", "true");
ps_set_info($ps, "Creator", "psclock.php");
ps_set_info($ps, "Author", "Uwe Steinmann");
ps_set_info($ps, "Title", "Analog Clock");
while ($pagecount-- > 0) {
    ps_begin_page($ps, 2 * ($radius + $margin), 2 * ($radius + $margin));
    ps_set_parameter($ps, "transition", "wipe");
    ps_set_value($ps, "duration", 0.5);
    ps_translate($ps, $radius + $margin, $radius + $margin);
    ps_save($ps);
    ps_setcolor($ps, "both", "rgb", 0.0, 0.0, 1.0, 0.0);
    /* minute strokes */
    ps_setlinewidth($ps, 2.0);
    for ($alpha = 0; $alpha < 360; $alpha += 6) {
        ps_rotate($ps, 6.0);
        ps_moveto($ps, $radius, 0.0);
        ps_lineto($ps, $radius - $margin / 3, 0.0);
        ps_stroke($ps);
    }
    ps_restore($ps);
    ps_save($ps);
    /* 5 minute strokes */