Esempio n. 1
0
 function getTextWidth($text, $style)
 {
     return ps_stringwidth($this->ps, $text, $this->font, $style['font']) / $this->width;
 }
Esempio n. 2
0
 $text = sprintf("%.2f", ps_get_value($ps, "descender", $samplefont));
 ps_show($ps, $text);
 for ($i = 0; $i <= 16; $i++) {
     ps_moveto($ps, $leftmargin + $i * $colwidth, $bottommargin);
     ps_lineto($ps, $leftmargin + $i * $colwidth, $bottommargin + 16 * $rowheight);
     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);
Esempio n. 3
0
ps_save($ps);
ps_translate($ps, 72, 10);
ps_rotate($ps, 45);
ps_place_image($ps, $psimage, 0, 0, 0.45);
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);
Esempio n. 4
0
 /**
  * Get the width of a text,
  *
  * @param string $text The text to get the width of
  * @return int The width of the text
  */
 function textWidth($text)
 {
     if ($this->_psFont === false) {
         return $this->_font['size'] * 0.7 * strlen($text);
     } else {
         return ps_stringwidth($this->_ps, $text, $this->_psFont, $this->_font['size']);
     }
 }
Esempio n. 5
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);