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 begin_example_box($p, $llx, $lly, $title, $font)
 {
     ps_save($p);
     ps_translate($p, $llx, $lly);
     ps_setcolor($p, "fill", "gray", 0.5, 0.0, 0.0, 0.0);
     ps_rect($p, 0, EXAMPLE_BOX_HEIGHT - EXAMPLE_BOX_TITLE_HEIGHT, EXAMPLE_BOX_WIDTH, EXAMPLE_BOX_TITLE_HEIGHT);
     ps_fill($p);
     ps_setcolor($p, "stroke", "gray", 1.0, 0.0, 0.0, 0.0);
     ps_setfont($p, $font, 12.0);
     ps_show_xy($p, $title, 10, EXAMPLE_BOX_HEIGHT - EXAMPLE_BOX_TITLE_HEIGHT + 5);
     ps_setlinewidth($p, 1.0);
     ps_setcolor($p, "stroke", "gray", 0.0, 0.0, 0.0, 0.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);
 }
Example #3
0
ps_circle($psdoc, 450, 250, 80);
ps_fill($psdoc);
ps_circle($psdoc, 450, 450, 80);
ps_fill($psdoc);
ps_circle($psdoc, 450, 650, 80);
ps_fill($psdoc);
ps_circle($psdoc, 650, 250, 80);
ps_fill($psdoc);
ps_circle($psdoc, 650, 450, 80);
ps_fill($psdoc);
ps_circle($psdoc, 650, 650, 80);
ps_fill($psdoc);
ps_end_glyph($psdoc);
ps_add_kerning($psdoc, "one", "two", 100);
ps_add_ligature($psdoc, "one", "two", "nine");
ps_add_ligature($psdoc, "nine", "three", "zero");
ps_end_font($psdoc);
ps_begin_page($psdoc, 596, 842);
ps_setfont($psdoc, $myfont, 80.0);
ps_show_xy($psdoc, "123456", 80, 700);
ps_setfont($psdoc, $myfont, 60.0);
ps_show_xy($psdoc, "12345678", 80, 600);
ps_setfont($psdoc, $myfont, 40.0);
ps_show_xy($psdoc, "1234567890", 80, 500);
ps_setfont($psdoc, $myfont, 20.0);
ps_show_xy($psdoc, "1234567890", 80, 400);
ps_setfont($psdoc, $myfont, 10.0);
ps_show_xy($psdoc, "1234567890", 80, 300);
ps_end_page($psdoc);
ps_close($psdoc);
ps_delete($psdoc);
Example #4
0
     ps_stroke($ps);
 }
 for ($j = 0; $j <= 16; $j++) {
     ps_moveto($ps, $leftmargin, $bottommargin + $j * $rowheight);
     ps_lineto($ps, $leftmargin + 16 * $colwidth, $bottommargin + $j * $rowheight);
     ps_stroke($ps);
 }
 ps_setfont($ps, $psfont, $fontsize);
 for ($i = 0; $i < 16; $i++) {
     $text = sprintf("x%X", $i);
     $textwidth = ps_stringwidth($ps, $text, $psfont, $fontsize);
     ps_show_xy($ps, $text, $leftmargin + $i * $colwidth + $colwidth / 2 - $textwidth / 2, $bottommargin + 16 * $rowheight + $fontsize / 2);
 }
 for ($j = 0; $j < 16; $j++) {
     $text = sprintf("%Xx", $j);
     ps_show_xy($ps, $text, $leftmargin - 1.7 * $fontsize, $bottommargin + (15 - $j) * $rowheight + $rowheight / 2 - $fontsize / 2);
 }
 /* The symbol itself */
 ps_setfont($ps, $samplefont, $fontsamplesize);
 ps_setlinewidth($ps, 0.4);
 for ($j = 0; $j < 16; $j++) {
     for ($i = 0; $i < 16; $i++) {
         $textwidth = ps_symbol_width($ps, $j * 16 + $i, $psfont, $fontsize);
         ps_set_value($ps, "textx", $leftmargin + $i * $colwidth + $colwidth / 2 - $textwidth / 2);
         ps_set_value($ps, "texty", $bottommargin + (15 - $j) * $rowheight + $rowheight / 2 + 3 - $fontsize / 2);
         //ps_show_xy($ps, $text, $leftmargin+$i*$colwidth+$colwidth/2-$textwidth/2, $bottommargin+(15-$j)*$rowheight+$rowheight/2-$fontsize/2);
         //			ps_show($ps, $text);
         ps_symbol($ps, $j * 16 + $i);
         ps_moveto($ps, $leftmargin + $i * $colwidth + $colwidth / 2 - $textwidth / 2, $bottommargin + (15 - $j) * $rowheight + $rowheight / 2 + 3 - $fontsize / 2);
         ps_lineto($ps, $leftmargin + $i * $colwidth + $colwidth / 2 + $textwidth / 2, $bottommargin + (15 - $j) * $rowheight + $rowheight / 2 + 3 - $fontsize / 2);
         ps_stroke($ps);
Example #5
0
 /**
  * Writes text
  *
  * Parameter array:
  * 'x': int X-point of text
  * 'y': int Y-point of text
  * 'text': string The text to add
  * 'alignment': array [optional] Alignment
  * 'color': mixed [optional] The color of the text
  */
 function addText($params)
 {
     $x = $this->_getX($params['x']);
     $y = $this->_getY($params['y']);
     $text = $params['text'];
     $color = isset($params['color']) ? $params['color'] : false;
     $alignment = isset($params['alignment']) ? $params['alignment'] : false;
     $this->_setFont();
     $textWidth = $this->textWidth($text);
     $textHeight = $this->textHeight($text);
     if (!is_array($alignment)) {
         $alignment = array('vertical' => 'top', 'horizontal' => 'left');
     }
     if (!isset($alignment['vertical'])) {
         $alignment['vertical'] = 'top';
     }
     if (!isset($alignment['horizontal'])) {
         $alignment['horizontal'] = 'left';
     }
     if ($alignment['horizontal'] == 'right') {
         $x = $x - $textWidth;
     } elseif ($alignment['horizontal'] == 'center') {
         $x = $x - $textWidth / 2;
     }
     $y -= $textHeight;
     if ($alignment['vertical'] == 'bottom') {
         $y = $y + $textHeight;
     } elseif ($alignment['vertical'] == 'center') {
         $y = $y + $textHeight / 2;
     }
     if ($color === false && isset($this->_font['color'])) {
         $color = $this->_font['color'];
     }
     ps_show_xy($this->_ps, $text, $x, $y);
     parent::addText($params);
 }
Example #6
0
ps_set_parameter($ps, "ligatures", "false");
ps_show_xy($ps, "Text without ligatures ffi fi fl ff", 100, 520);
ps_set_parameter($ps, "ligatures", "true");
ps_set_value($ps, "charspacing", 2.0);
ps_show_xy($ps, "Text with char spacing set to 2.0", 100, 490);
ps_set_value($ps, "charspacing", 0.0);
ps_show_xy($ps, "Text with char spacing set to 0.0", 100, 460);
ps_set_value($ps, "charspacing", -2.0);
ps_show_xy($ps, "Text with char spacing set to -2.0", 100, 430);
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");
Example #7
0
}
ps_set_parameter($ps, "warning", "true");
ps_set_info($ps, "Creator", "hyperlinks.php");
ps_set_info($ps, "Author", "Uwe Steinmann");
ps_set_info($ps, "Title", "Creating Hyperlinks with pdfmarks");
$fontsize = 20.0;
ps_begin_page($ps, 596, 842);
$b1 = ps_add_bookmark($ps, "Content", 0, 0);
ps_add_bookmark($ps, "First Page", $b1, 0);
$psfont = ps_findfont($ps, "Helvetica", "", 0);
ps_setfont($ps, $psfont, $fontsize);
ps_set_value($ps, "leading", 14.0);
ps_show_xy($ps, "This is a web link", 100, 100);
$len = ps_stringwidth($ps, "This is a web link", $psfont, $fontsize);
ps_add_weblink($ps, 100, 100, 100 + $len, 130, "http://www.mmk-hagen.de");
ps_show_xy($ps, "This is a pdf link to an external document", 100, 150);
$len = ps_stringwidth($ps, "This is a pdf link to an external document", $psfont, $fontsize);
ps_add_pdflink($ps, 100, 150, 100 + $len, 180, "test.pdf", 1, "fitpage");
ps_show_xy($ps, "This is a launch link", 100, 200);
$len = ps_stringwidth($ps, "This is a launch link", $psfont, $fontsize);
ps_add_launchlink($ps, 100, 200, 100 + $len, 230, "/usr/bin/gedit");
ps_show_xy($ps, "This is a pdf link within the document", 100, 250);
$len = ps_stringwidth($ps, "This is a pdf link within the document", $psfont, $fontsize);
ps_add_locallink($ps, 100, 250, 100 + $len, 280, 2, "fitpage");
ps_end_page($ps);
ps_begin_page($ps, 300, 300);
ps_add_bookmark($ps, "Second Page", $b1, 0);
ps_add_note($ps, 100, 100, 200, 200, "This is the contents of the note", "Title of Note", "help", 1);
ps_end_page($ps);
ps_close($ps);
ps_delete($ps);