/** * Check which major version of pslib is installed * * @return int The mahor version number of pslib * @access private */ function _version() { $result = false; $version = ''; if (function_exists('ps_get_majorversion')) { $version = ps_get_majorversion(); } else { if (function_exists('ps_get_value')) { $version = ps_get_value($this->_ps, 'major', 0); } else { ob_start(); phpinfo(8); $php_info = ob_get_contents(); ob_end_clean(); if (ereg("<td[^>]*>pslib Version *<\\/td><td[^>]*>([^<]*)<\\/td>", $php_info, $result)) { $version = $result[1]; } } } if (ereg('([0-9]{1,2})\\.[0-9]{1,2}(\\.[0-9]{1,2})?', trim($version), $result)) { return $result[1]; } else { return $version; } }
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); 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);
begin_example_box($ps, LEFT_BORDER + (EXAMPLE_BOX_WIDTH + 30) * $x++, $y, "Jpeg cmyk image, rotated", $psfont); $psimage = ps_open_image_file($ps, "jpeg", "cne-cmyk.jpg", NULL, 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);