Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ps_translate(3) [php man page]

PS_TRANSLATE(3) 							 1							   PS_TRANSLATE(3)

ps_translate - Sets translation

SYNOPSIS
bool ps_translate (resource $psdoc, float $x, float $y) DESCRIPTION
Sets a new initial point of the coordinate system. PARAMETERS
o $psdoc - Resource identifier of the postscript file as returned by ps_new(3). o $x - x-coordinate of the origin of the translated coordinate system. o $y - y-coordinate of the origin of the translated coordinate system. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 Translation of the coordinate system <?php function rectangle($ps) { ps_moveto($ps, 0, 0); ps_lineto($ps, 0, 50); ps_lineto($ps, 50, 50); ps_lineto($ps, 50, 0); ps_lineto($ps, 0, 0); ps_stroke($ps); } $ps = ps_new(); if (!ps_open_file($ps, "translate.ps")) { print "Cannot open PostScript file "; exit; } ps_set_info($ps, "Creator", "translate.php"); ps_set_info($ps, "Author", "Uwe Steinmann"); ps_set_info($ps, "Title", "Translated example"); ps_set_info($ps, "BoundingBox", "0 0 596 842"); $psfont = ps_findfont($ps, "Helvetica", "", 0); ps_begin_page($ps, 596, 842); ps_set_text_pos($ps, 100, 100); ps_translate($ps, 500, 750); rectangle($ps); ps_translate($ps, -500, -750); ps_setfont($ps, $psfont, 8.0); ps_show($ps, "Text at initial position"); ps_end_page($ps); ps_begin_page($ps, 596, 842); ps_set_text_pos($ps, 100, 100); ps_save($ps); ps_translate($ps, 500, 750); rectangle($ps); ps_restore($ps); ps_setfont($ps, $psfont, 8.0); ps_show($ps, "Text at initial position"); ps_end_page($ps); ps_delete($ps); ?> The above example demonstrates two possible ways to place a graphic (in this case just a rectangle) at any position on the page, while the graphic itself uses its own coordinate system. The trick is to change the origin of the current coordinate system before drawing the rectangle. The translation has to be undone after the graphic has been drawn. On the second page a slightly different and more elegant approach is applied. Instead of undoing the translation with a second call of ps_translate(3) the graphics context is saved before modifying the coordinate system and restored after drawing the rectangle. SEE ALSO
ps_scale(3), ps_rotate(3). PHP Documentation Group PS_TRANSLATE(3)

Check Out this Related Man Page

PS_FINDFONT(3)								 1							    PS_FINDFONT(3)

ps_findfont - Loads a font

SYNOPSIS
int ps_findfont (resource $psdoc, string $fontname, string $encoding, [bool $embed = false]) DESCRIPTION
Loads a font for later use. Before text is output with a loaded font it must be set with ps_setfont(3). This function needs the adobe font metric file in order to calculate the space used up by the characters. A font which is loaded within a page will only be available on that page. Fonts which are to be used in the complete document have to be loaded before the first call of ps_begin_page(3). Calling ps_find- font(3) between pages will make that font available for all following pages. The name of the afm file must be $fontname .afm. If the font shall be embedded the file $fontname .pfb containing the font outline must be present as well. Calling ps_findfont(3) before the first page requires to output the postscript header which includes the BoundingBox for the whole docu- ment. Usually the BoundingBox is set with the first call of ps_begin_page(3) which now comes after ps_findfont(3). Consequently the Bound- ingBox has not been set and a warning will be issued when ps_findfont(3) is called. In order to prevent this situation, one should call ps_set_parameter(3) to set the BoundingBox before ps_findfont(3) is called. PARAMETERS
o $psdoc - Resource identifier of the postscript file as returned by ps_new(3). o $fontname - The name of the font. o $encoding -ps_findfont(3) will try to load the file passed in the parameter $encoding. Encoding files are of the same syntax as those used by dvips(1). They contain a font encoding vector (which is currently not used but must be present) and a list of extra ligatures to extend the list of ligatures derived from the afm file. $encoding can be NULL or the empty string if the default encoding (TeXBase1) shall be used. If the encoding is set to builtin then there will be no reencoding and the font specific encoding will be used. This is very useful with symbol fonts. o $embed - If set to a value >0 the font will be embedded into the document. This requires the font outline (.pfb file) to be present. RETURN VALUES
Returns the identifier of the font or zero in case of an error. The identifier is a positive number. SEE ALSO
ps_begin_page(3), ps_setfont(3). PHP Documentation Group PS_FINDFONT(3)
Man Page