All pastes #593795 Raw Edit

Stuff

public text v1 · immutable
#593795 ·published 2007-06-28 15:34 UTC
rendered paste body
...
		$this->open($drawing);
		$this->startSVG();
		$this->adaug();
		$this->endSVG();
...
	function GetSVGcontent($node) {
		$st = "";
		foreach ($node->childNodes as $cnode){
			if ($cnode->nodeType==XML_TEXT_NODE){
				$st .= $cnode->textContent;
			} else if ($cnode->nodeType==XML_ELEMENT_NODE) {
				$st .= "<" . $cnode->tagName;
				if ($attribnodes = $cnode->attributes) {
					$st .= " ";
					foreach ($attribnodes as $anode){
						$st .= $anode->nodeName . "='" . $anode->nodeValue . "' ";
					}
				}
				$nodeText = $this->GetContentAsString($cnode,$obj,$lin);
				if (empty($nodeText) && !$attribnodes){
					$st .= " />";
				} else {
					$st .= ">" . $nodeText . "</" .	$cnode->nodeName . ">";
				}
			}
		}
		return $st;
	}

	Function open($file){
		$this->xdoc = new DOMDocument("1.0","UTF-8");
		$this->xdoc->Load($this->drawing);
		$this->svg = $this->xdoc->getElementsByTagName('svg')->item(0);
	}

	Function startSVG(){
		/**
		 * $BOM = sprintf('%c%c%c',0xEF,0xBB,0xBF);
		 * echo $BOM."<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>";
		 */
		echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>";
		echo "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">";
		echo "<?AdobeSVGViewer save=\"snapshot\"?>";
		echo "<svg width=\"21cm\" height=\"29.7cm\" viewBox=\"0 0 744 1052\" id=\"SVGTest\" preserveAspectRatio=\"xMidYMid meet\" zoomAndPan=\"magnify\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">";

	}

	Function endSVG(){
		echo "</svg>";
	}

	Function adaug(){
		//adaugare element
		$newgrup = $this->xdoc->createElement("text");
		$this->svg->appendChild($newgrup);
		$newgrup->setAttribute("id","texttest");
		$newgrup->setAttribute("x",$this->x-50);
		$newgrup->setAttribute("y",$this->y);
		$newgrup->setAttribute("style","font-size:8px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;font-family:'Arial Unicode MS'");
		$this->y=$this->y+10;

		$textvalue = $this->xdoc->createTextNode("11111111111111111111");
		$newgrup->appendChild($textvalue);

		echo $this->GetSVGcontent($newgrup);
		//$newElement = $this->xdoc->createElement("text");
		//$txtNode = $this->xdoc->createTextNode("Project Manager");
		//$newElement->appendChild($txtNode);
		//$this->svg->appendChild($newElement);
		//$this->showvalue("123321",0,0);

	}
...