<?php $ps = ps_new(); if (!ps_open_file($ps, "-")) { print "Cannot open PostScript file\n"; exit; } ps_set_info($ps, "Creator", "draw.php"); ps_set_info($ps, "Author", "Uwe Steinmann"); ps_set_info($ps, "Title", "Creating document in memory"); ps_begin_page($ps, 596, 842); ps_end_page($ps); ps_close($ps); echo ps_get_buffer($ps); ps_delete($ps);
function writeToStream($stream) { ps_end_page($this->ps); ps_close($this->ps); $buf = ps_get_buffer($this->ps); fwrite($stream, $buf); ps_delete($this->ps); }
/** * Output the result of the canvas * * @param array $param Parameter array * @abstract */ function save($param = false) { parent::save($param); ps_end_page($this->_ps); ps_close($this->_ps); if ($param['filename'] == "") { $buf = ps_get_buffer($this->_ps); $len = strlen($buf); $fp = @fopen($param['filename'], 'wb'); if ($fp) { fwrite($fp, $buf, strlen($buf)); fclose($fp); } } ps_delete($this->_ps); }