/** * Export as SVG to image document using inkscape. * * It will save a temporary file on default system tempo folder. * * @param string $filename try to use complete path. Works better. * @param integer $width * @param integer $height * * @return boolean ? */ public function exportInkscape($filename, $width = null, $height = null) { include_once 'inkscape.php'; //support export using inkscape $format = SVGDocument::getFileExtension($filename); $inkscape = new Inkscape($this); $inkscape->setSize($width, $height); return $inkscape->export($format, $filename); }
/** * Export the object as xml text, OR xml file. * * If the file extension is svgz, the function will save it correctely; * * @param string $filename the file to save, is optional, you can output to a var * @return string the xml string if filename is not passed */ public function asXML($filename = null) { //if is svgz use compres.zlib to load the compacted SVG if (SVGDocument::getFileExtension($filename) == self::EXTENSION_COMPACT) { //verify if zlib is installed if (!function_exists('gzopen')) { throw new Exception('GZip support not installed.'); return false; } $filename = 'compress.zlib://' . $filename; } $xml = parent::asXML(null); //need to do it, if pass a null filename it return an error if ($filename) { return file_put_contents($filename, $xml); } return $xml; }