Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ps_begin_page(3) [php man page]

PS_BEGIN_PAGE(3)							 1							  PS_BEGIN_PAGE(3)

ps_begin_page - Start a new page

SYNOPSIS
bool ps_begin_page (resource $psdoc, float $width, float $height) DESCRIPTION
Starts a new page. Although the parameters $width and $height imply a different page size for each page, this is not possible in Post- Script. The first call of ps_begin_page(3) will set the page size for the whole document. Consecutive calls will have no effect, except for creating a new page. The situation is different if you intent to convert the PostScript document into PDF. This function places pdfmarks into the document which can set the size for each page indiviually. The resulting PDF document will have different page sizes. Though PostScript does not know different page sizes, pslib places a bounding box for each page into the document. This size is evaluated by some PostScript viewers and will have precedence over the BoundingBox in the Header of the document. This can lead to unexpected results when you set a BoundingBox whose lower left corner is not (0, 0), because the bounding box of the page will always have a lower left corner (0, 0) and overwrites the global setting. Each page is encapsulated into save/restore. This means, that most of the settings made on one page will not be retained on the next page. If there is up to the first call of ps_begin_page(3) no call of ps_findfont(3), then the header of the PostScript document will be output and the bounding box will be set to the size of the first page. The lower left corner of the bounding box is set to (0, 0). If ps_find- font(3) was called before, then the header has been output already, and the document will not have a valid bounding box. In order to pre- vent this, one should call ps_set_info(3) to set the info field BoundingBox and possibly Orientation before any ps_findfont(3) or ps_begin_page(3) calls. Note Up to version 0.2.6 of pslib, this function will always overwrite the BoundingBox and Orientation, if it has been set before with ps_set_info(3) and ps_findfont(3) has not been called before. PARAMETERS
o $psdoc - Resource identifier of the postscript file as returned by ps_new(3). o $width - The width of the page in pixel, e.g. 596 for A4 format. o $height - The height of the page in pixel, e.g. 842 for A4 format. RETURN VALUES
Returns TRUE on success or FALSE on failure. SEE ALSO
ps_end_page(3), ps_findfont(3), ps_set_info(3). PHP Documentation Group PS_BEGIN_PAGE(3)

Check Out this Related 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)
Man Page