Example #1
0
 /**
  * Parse from DOM node.
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $actualPpi = $node->hasAttribute(IdmlAttributes::ActualPpi) ? $node->getAttribute(IdmlAttributes::ActualPpi) : '';
     $xy = explode(' ', $actualPpi);
     if (count($xy) == 2) {
         $this->ppiX = $xy[0];
         $this->ppiY = $xy[1];
     }
     // Get original width and height (in InDesign units of 72ppi)
     $graphicBoundNodes = $node->getElementsByTagName('GraphicBounds');
     $graphicBoundNode = $graphicBoundNodes->item(0);
     if ($graphicBoundNode) {
         $top = $graphicBoundNode->getAttribute(IdmlAttributes::Top);
         $left = $graphicBoundNode->getAttribute(IdmlAttributes::Left);
         $bottom = $graphicBoundNode->getAttribute(IdmlAttributes::Bottom);
         $right = $graphicBoundNode->getAttribute(IdmlAttributes::Right);
         $this->boundary = new IdmlBoundary($top, $left, $bottom, $right);
         $this->width = $this->boundary->getWidth();
         $this->height = $this->boundary->getHeight();
     }
     // Load image content.
     $xpath = new DOMXPath($node->ownerDocument);
     $q = "./Properties/Contents";
     $contentNodes = $xpath->query($q, $node);
     if ($contentNodes->length > 0) {
         $contentNode = $contentNodes->item(0);
         $this->imageContent = IdmlParserHelper::getCData($contentNode);
         $this->embeddedImage = true;
     }
     $this->idmlTag = "img";
     $this->processImage();
 }