/** * @licstart The following is the entire license notice for the * Javascript code in this page * * Copyright 2019 Mozilla Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @licend The above is the entire license notice for the * Javascript code in this page */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SVGGraphics = void 0; var _util = require("../shared/util"); var _display_utils = require("./display_utils"); var _is_node = _interopRequireDefault(require("../shared/is_node")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var SVGGraphics = function SVGGraphics() { throw new Error('Not implemented: SVGGraphics'); }; exports.SVGGraphics = SVGGraphics; { var opListToTree = function opListToTree(opList) { var opTree = []; var tmp = []; var _iteratorNormalCompletion = true; var _didIteratorError = false; var _iteratorError = undefined; try { for (var _iterator = opList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { var opListElement = _step.value; if (opListElement.fn === 'save') { opTree.push({ 'fnId': 92, 'fn': 'group', 'items': [] }); tmp.push(opTree); opTree = opTree[opTree.length - 1].items; continue; } if (opListElement.fn === 'restore') { opTree = tmp.pop(); } else { opTree.push(opListElement); } } } catch (err) { _didIteratorError = true; _iteratorError = err; } finally { try { if (!_iteratorNormalCompletion && _iterator["return"] != null) { _iterator["return"](); } } finally { if (_didIteratorError) { throw _iteratorError; } } } return opTree; }; var pf = function pf(value) { if (Number.isInteger(value)) { return value.toString(); } var s = value.toFixed(10); var i = s.length - 1; if (s[i] !== '0') { return s; } do { i--; } while (s[i] === '0'); return s.substring(0, s[i] === '.' ? i : i + 1); }; var pm = function pm(m) { if (m[4] === 0 && m[5] === 0) { if (m[1] === 0 && m[2] === 0) { if (m[0] === 1 && m[3] === 1) { return ''; } return "scale(".concat(pf(m[0]), " ").concat(pf(m[3]), ")"); } if (m[0] === m[3] && m[1] === -m[2]) { var a = Math.acos(m[0]) * 180 / Math.PI; return "rotate(".concat(pf(a), ")"); } } else { if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) { return "translate(".concat(pf(m[4]), " ").concat(pf(m[5]), ")"); } } return "matrix(".concat(pf(m[0]), " ").concat(pf(m[1]), " ").concat(pf(m[2]), " ").concat(pf(m[3]), " ").concat(pf(m[4]), " ") + "".concat(pf(m[5]), ")"); }; var SVG_DEFAULTS = { fontStyle: 'normal', fontWeight: 'normal', fillColor: '#000000' }; var XML_NS = 'http://www.w3.org/XML/1998/namespace'; var XLINK_NS = 'http://www.w3.org/1999/xlink'; var LINE_CAP_STYLES = ['butt', 'round', 'square']; var LINE_JOIN_STYLES = ['miter', 'round', 'bevel']; var convertImgDataToPng = function () { var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]); var CHUNK_WRAPPER_SIZE = 12; var crcTable = new Int32Array(256); for (var i = 0; i < 256; i++) { var c = i; for (var h = 0; h < 8; h++) { if (c & 1) { c = 0xedB88320 ^ c >> 1 & 0x7fffffff; } else { c = c >> 1 & 0x7fffffff; } } crcTable[i] = c; } function crc32(data, start, end) { var crc = -1; for (var _i = start; _i < end; _i++) { var a = (crc ^ data[_i]) & 0xff; var b = crcTable[a]; crc = crc >>> 8 ^ b; } return crc ^ -1; } function writePngChunk(type, body, data, offset) { var p = offset; var len = body.length; data[p] = len >> 24 & 0xff; data[p + 1] = len >> 16 & 0xff; data[p + 2] = len >> 8 & 0xff; data[p + 3] = len & 0xff; p += 4; data[p] = type.charCodeAt(0) & 0xff; data[p + 1] = type.charCodeAt(1) & 0xff; data[p + 2] = type.charCodeAt(2) & 0xff; data[p + 3] = type.charCodeAt(3) & 0xff; p += 4; data.set(body, p); p += body.length; var crc = crc32(data, offset + 4, p); data[p] = crc >> 24 & 0xff; data[p + 1] = crc >> 16 & 0xff; data[p + 2] = crc >> 8 & 0xff; data[p + 3] = crc & 0xff; } function adler32(data, start, end) { var a = 1; var b = 0; for (var _i2 = start; _i2 < end; ++_i2) { a = (a + (data[_i2] & 0xff)) % 65521; b = (b + a) % 65521; } return b << 16 | a; } function deflateSync(literals) { if (!(0, _is_node["default"])()) { return deflateSyncUncompressed(literals); } try { var input; if (parseInt(process.versions.node) >= 8) { input = literals; } else { input = new Buffer(literals); } var output = require('zlib').deflateSync(input, { level: 9 }); return output instanceof Uint8Array ? output : new Uint8Array(output); } catch (e) { (0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e); } return deflateSyncUncompressed(literals); } function deflateSyncUncompressed(literals) { var len = literals.length; var maxBlockLength = 0xFFFF; var deflateBlocks = Math.ceil(len / maxBlockLength); var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4); var pi = 0; idat[pi++] = 0x78; idat[pi++] = 0x9c; var pos = 0; while (len > maxBlockLength) { idat[pi++] = 0x00; idat[pi++] = 0xff; idat[pi++] = 0xff; idat[pi++] = 0x00; idat[pi++] = 0x00; idat.set(literals.subarray(pos, pos + maxBlockLength), pi); pi += maxBlockLength; pos += maxBlockLength; len -= maxBlockLength; } idat[pi++] = 0x01; idat[pi++] = len & 0xff; idat[pi++] = len >> 8 & 0xff; idat[pi++] = ~len & 0xffff & 0xff; idat[pi++] = (~len & 0xffff) >> 8 & 0xff; idat.set(literals.subarray(pos), pi); pi += literals.length - pos; var adler = adler32(literals, 0, literals.length); idat[pi++] = adler >> 24 & 0xff; idat[pi++] = adler >> 16 & 0xff; idat[pi++] = adler >> 8 & 0xff; idat[pi++] = adler & 0xff; return idat; } function encode(imgData, kind, forceDataSchema, isMask) { var width = imgData.width; var height = imgData.height; var bitDepth, colorType, lineSize; var bytes = imgData.data; switch (kind) { case _util.ImageKind.GRAYSCALE_1BPP: colorType = 0; bitDepth = 1; lineSize = width + 7 >> 3; break; case _util.ImageKind.RGB_24BPP: colorType = 2; bitDepth = 8; lineSize = width * 3; break; case _util.ImageKind.RGBA_32BPP: colorType = 6; bitDepth = 8; lineSize = width * 4; break; default: throw new Error('invalid format'); } var literals = new Uint8Array((1 + lineSize) * height); var offsetLiterals = 0, offsetBytes = 0; for (var y = 0; y < height; ++y) { literals[offsetLiterals++] = 0; literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals); offsetBytes += lineSize; offsetLiterals += lineSize; } if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) { offsetLiterals = 0; for (var _y = 0; _y < height; _y++) { offsetLiterals++; for (var _i3 = 0; _i3 < lineSize; _i3++) { literals[offsetLiterals++] ^= 0xFF; } } } var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]); var idat = deflateSync(literals); var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length; var data = new Uint8Array(pngLength); var offset = 0; data.set(PNG_HEADER, offset); offset += PNG_HEADER.length; writePngChunk('IHDR', ihdr, data, offset); offset += CHUNK_WRAPPER_SIZE + ihdr.length; writePngChunk('IDATA', idat, data, offset); offset += CHUNK_WRAPPER_SIZE + idat.length; writePngChunk('IEND', new Uint8Array(0), data, offset); return (0, _util.createObjectURL)(data, 'image/png', forceDataSchema); } return function convertImgDataToPng(imgData, forceDataSchema, isMask) { var kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind; return encode(imgData, kind, forceDataSchema, isMask); }; }(); var SVGExtraState = /*#__PURE__*/ function () { function SVGExtraState() { _classCallCheck(this, SVGExtraState); this.fontSizeScale = 1; this.fontWeight = SVG_DEFAULTS.fontWeight; this.fontSize = 0; this.textMatrix = _util.IDENTITY_MATRIX; this.fontMatrix = _util.FONT_IDENTITY_MATRIX; this.leading = 0; this.textRenderingMode = _util.TextRenderingMode.FILL; this.textMatrixScale = 1; this.x = 0; this.y = 0; this.lineX = 0; this.lineY = 0; this.charSpacing = 0; this.wordSpacing = 0; this.textHScale = 1; this.textRise = 0; this.fillColor = SVG_DEFAULTS.fillColor; this.strokeColor = '#000000'; this.fillAlpha = 1; this.strokeAlpha = 1; this.lineWidth = 1; this.lineJoin = ''; this.lineCap = ''; this.miterLimit = 0; this.dashArray = []; this.dashPhase = 0; this.dependencies = []; this.activeClipUrl = null; this.clipGroup = null; this.maskId = ''; } _createClass(SVGExtraState, [{ key: "clone", value: function clone() { return Object.create(this); } }, { key: "setCurrentPoint", value: function setCurrentPoint(x, y) { this.x = x; this.y = y; } }]); return SVGExtraState; }(); var clipCount = 0; var maskCount = 0; var shadingCount = 0; exports.SVGGraphics = SVGGraphics = /*#__PURE__*/ function () { function SVGGraphics(commonObjs, objs, forceDataSchema) { _classCallCheck(this, SVGGraphics); this.svgFactory = new _display_utils.DOMSVGFactory(); this.current = new SVGExtraState(); this.transformMatrix = _util.IDENTITY_MATRIX; this.transformStack = []; this.extraStack = []; this.commonObjs = commonObjs; this.objs = objs; this.pendingClip = null; this.pendingEOFill = false; this.embedFonts = false; this.embeddedFonts = Object.create(null); this.cssStyle = null; this.forceDataSchema = !!forceDataSchema; this._operatorIdMapping = []; for (var op in _util.OPS) { this._operatorIdMapping[_util.OPS[op]] = op; } } _createClass(SVGGraphics, [{ key: "save", value: function save() { this.transformStack.push(this.transformMatrix); var old = this.current; this.extraStack.push(old); this.current = old.clone(); } }, { key: "restore", value: function restore() { this.transformMatrix = this.transformStack.pop(); this.current = this.extraStack.pop(); this.pendingClip = null; this.tgrp = null; } }, { key: "group", value: function group(items) { this.save(); this.executeOpTree(items); this.restore(); } }, { key: "loadDependencies", value: function loadDependencies(operatorList) { var _this = this; var fnArray = operatorList.fnArray; var argsArray = operatorList.argsArray; for (var i = 0, ii = fnArray.length; i < ii; i++) { if (fnArray[i] !== _util.OPS.dependency) { continue; } var _iteratorNormalCompletion2 = true; var _didIteratorError2 = false; var _iteratorError2 = undefined; try { var _loop = function _loop() { var obj = _step2.value; var objsPool = obj.startsWith('g_') ? _this.commonObjs : _this.objs; var promise = new Promise(function (resolve) { objsPool.get(obj, resolve); }); _this.current.dependencies.push(promise); }; for (var _iterator2 = argsArray[i][Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { _loop(); } } catch (err) { _didIteratorError2 = true; _iteratorError2 = err; } finally { try { if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) { _iterator2["return"](); } } finally { if (_didIteratorError2) { throw _iteratorError2; } } } } return Promise.all(this.current.dependencies); } }, { key: "transform", value: function transform(a, b, c, d, e, f) { var transformMatrix = [a, b, c, d, e, f]; this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix); this.tgrp = null; } }, { key: "getSVG", value: function getSVG(operatorList, viewport) { var _this2 = this; this.viewport = viewport; var svgElement = this._initialize(viewport); return this.loadDependencies(operatorList).then(function () { _this2.transformMatrix = _util.IDENTITY_MATRIX; _this2.executeOpTree(_this2.convertOpList(operatorList)); return svgElement; }); } }, { key: "convertOpList", value: function convertOpList(operatorList) { var operatorIdMapping = this._operatorIdMapping; var argsArray = operatorList.argsArray; var fnArray = operatorList.fnArray; var opList = []; for (var i = 0, ii = fnArray.length; i < ii; i++) { var fnId = fnArray[i]; opList.push({ 'fnId': fnId, 'fn': operatorIdMapping[fnId], 'args': argsArray[i] }); } return opListToTree(opList); } }, { key: "executeOpTree", value: function executeOpTree(opTree) { var _iteratorNormalCompletion3 = true; var _didIteratorError3 = false; var _iteratorError3 = undefined; try { for (var _iterator3 = opTree[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) { var opTreeElement = _step3.value; var fn = opTreeElement.fn; var fnId = opTreeElement.fnId; var args = opTreeElement.args; switch (fnId | 0) { case _util.OPS.beginText: this.beginText(); break; case _util.OPS.dependency: break; case _util.OPS.setLeading: this.setLeading(args); break; case _util.OPS.setLeadingMoveText: this.setLeadingMoveText(args[0], args[1]); break; case _util.OPS.setFont: this.setFont(args); break; case _util.OPS.showText: this.showText(args[0]); break; case _util.OPS.showSpacedText: this.showText(args[0]); break; case _util.OPS.endText: this.endText(); break; case _util.OPS.moveText: this.moveText(args[0], args[1]); break; case _util.OPS.setCharSpacing: this.setCharSpacing(args[0]); break; case _util.OPS.setWordSpacing: this.setWordSpacing(args[0]); break; case _util.OPS.setHScale: this.setHScale(args[0]); break; case _util.OPS.setTextMatrix: this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]); break; case _util.OPS.setTextRise: this.setTextRise(args[0]); break; case _util.OPS.setTextRenderingMode: this.setTextRenderingMode(args[0]); break; case _util.OPS.setLineWidth: this.setLineWidth(args[0]); break; case _util.OPS.setLineJoin: this.setLineJoin(args[0]); break; case _util.OPS.setLineCap: this.setLineCap(args[0]); break; case _util.OPS.setMiterLimit: this.setMiterLimit(args[0]); break; case _util.OPS.setFillRGBColor: this.setFillRGBColor(args[0], args[1], args[2]); break; case _util.OPS.setStrokeRGBColor: this.setStrokeRGBColor(args[0], args[1], args[2]); break; case _util.OPS.setStrokeColorN: this.setStrokeColorN(args); break; case _util.OPS.setFillColorN: this.setFillColorN(args); break; case _util.OPS.shadingFill: this.shadingFill(args[0]); break; case _util.OPS.setDash: this.setDash(args[0], args[1]); break; case _util.OPS.setRenderingIntent: this.setRenderingIntent(args[0]); break; case _util.OPS.setFlatness: this.setFlatness(args[0]); break; case _util.OPS.setGState: this.setGState(args[0]); break; case _util.OPS.fill: this.fill(); break; case _util.OPS.eoFill: this.eoFill(); break; case _util.OPS.stroke: this.stroke(); break; case _util.OPS.fillStroke: this.fillStroke(); break; case _util.OPS.eoFillStroke: this.eoFillStroke(); break; case _util.OPS.clip: this.clip('nonzero'); break; case _util.OPS.eoClip: this.clip('evenodd'); break; case _util.OPS.paintSolidColorImageMask: this.paintSolidColorImageMask(); break; case _util.OPS.paintJpegXObject: this.paintJpegXObject(args[0], args[1], args[2]); break; case _util.OPS.paintImageXObject: this.paintImageXObject(args[0]); break; case _util.OPS.paintInlineImageXObject: this.paintInlineImageXObject(args[0]); break; case _util.OPS.paintImageMaskXObject: this.paintImageMaskXObject(args[0]); break; case _util.OPS.paintFormXObjectBegin: this.paintFormXObjectBegin(args[0], args[1]); break; case _util.OPS.paintFormXObjectEnd: this.paintFormXObjectEnd(); break; case _util.OPS.closePath: this.closePath(); break; case _util.OPS.closeStroke: this.closeStroke(); break; case _util.OPS.closeFillStroke: this.closeFillStroke(); break; case _util.OPS.closeEOFillStroke: this.closeEOFillStroke(); break; case _util.OPS.nextLine: this.nextLine(); break; case _util.OPS.transform: this.transform(args[0], args[1], args[2], args[3], args[4], args[5]); break; case _util.OPS.constructPath: this.constructPath(args[0], args[1]); break; case _util.OPS.endPath: this.endPath(); break; case 92: this.group(opTreeElement.items); break; default: (0, _util.warn)("Unimplemented operator ".concat(fn)); break; } } } catch (err) { _didIteratorError3 = true; _iteratorError3 = err; } finally { try { if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) { _iterator3["return"](); } } finally { if (_didIteratorError3) { throw _iteratorError3; } } } } }, { key: "setWordSpacing", value: function setWordSpacing(wordSpacing) { this.current.wordSpacing = wordSpacing; } }, { key: "setCharSpacing", value: function setCharSpacing(charSpacing) { this.current.charSpacing = charSpacing; } }, { key: "nextLine", value: function nextLine() { this.moveText(0, this.current.leading); } }, { key: "setTextMatrix", value: function setTextMatrix(a, b, c, d, e, f) { var current = this.current; current.textMatrix = current.lineMatrix = [a, b, c, d, e, f]; current.textMatrixScale = Math.sqrt(a * a + b * b); current.x = current.lineX = 0; current.y = current.lineY = 0; current.xcoords = []; current.tspan = this.svgFactory.createElement('svg:tspan'); current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px")); current.tspan.setAttributeNS(null, 'y', pf(-current.y)); current.txtElement = this.svgFactory.createElement('svg:text'); current.txtElement.appendChild(current.tspan); } }, { key: "beginText", value: function beginText() { var current = this.current; current.x = current.lineX = 0; current.y = current.lineY = 0; current.textMatrix = _util.IDENTITY_MATRIX; current.lineMatrix = _util.IDENTITY_MATRIX; current.textMatrixScale = 1; current.tspan = this.svgFactory.createElement('svg:tspan'); current.txtElement = this.svgFactory.createElement('svg:text'); current.txtgrp = this.svgFactory.createElement('svg:g'); current.xcoords = []; } }, { key: "moveText", value: function moveText(x, y) { var current = this.current; current.x = current.lineX += x; current.y = current.lineY += y; current.xcoords = []; current.tspan = this.svgFactory.createElement('svg:tspan'); current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px")); current.tspan.setAttributeNS(null, 'y', pf(-current.y)); } }, { key: "showText", value: function showText(glyphs) { var current = this.current; var font = current.font; var fontSize = current.fontSize; if (fontSize === 0) { return; } var charSpacing = current.charSpacing; var wordSpacing = current.wordSpacing; var fontDirection = current.fontDirection; var textHScale = current.textHScale * fontDirection; var vertical = font.vertical; var widthAdvanceScale = fontSize * current.fontMatrix[0]; var x = 0; var _iteratorNormalCompletion4 = true; var _didIteratorError4 = false; var _iteratorError4 = undefined; try { for (var _iterator4 = glyphs[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { var glyph = _step4.value; if (glyph === null) { x += fontDirection * wordSpacing; continue; } else if ((0, _util.isNum)(glyph)) { x += -glyph * fontSize * 0.001; continue; } var width = glyph.width; var character = glyph.fontChar; var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing; var charWidth = width * widthAdvanceScale + spacing * fontDirection; if (!glyph.isInFont && !font.missingFile) { x += charWidth; continue; } current.xcoords.push(current.x + x * textHScale); current.tspan.textContent += character; x += charWidth; } } catch (err) { _didIteratorError4 = true; _iteratorError4 = err; } finally { try { if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) { _iterator4["return"](); } } finally { if (_didIteratorError4) { throw _iteratorError4; } } } if (vertical) { current.y -= x * textHScale; } else { current.x += x * textHScale; } current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' ')); current.tspan.setAttributeNS(null, 'y', pf(-current.y)); current.tspan.setAttributeNS(null, 'font-family', current.fontFamily); current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px")); if (current.fontStyle !== SVG_DEFAULTS.fontStyle) { current.tspan.setAttributeNS(null, 'font-style', current.fontStyle); } if (current.fontWeight !== SVG_DEFAULTS.fontWeight) { current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight); } var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK; if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) { if (current.fillColor !== SVG_DEFAULTS.fillColor) { current.tspan.setAttributeNS(null, 'fill', current.fillColor); } if (current.fillAlpha < 1) { current.tspan.setAttributeNS(null, 'fill-opacity', current.fillAlpha); } } else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) { current.tspan.setAttributeNS(null, 'fill', 'transparent'); } else { current.tspan.setAttributeNS(null, 'fill', 'none'); } if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) { var lineWidthScale = 1 / (current.textMatrixScale || 1); this._setStrokeAttributes(current.tspan, lineWidthScale); } var textMatrix = current.textMatrix; if (current.textRise !== 0) { textMatrix = textMatrix.slice(); textMatrix[5] += current.textRise; } current.txtElement.setAttributeNS(null, 'transform', "".concat(pm(textMatrix), " scale(1, -1)")); current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve'); current.txtElement.appendChild(current.tspan); current.txtgrp.appendChild(current.txtElement); this._ensureTransformGroup().appendChild(current.txtElement); } }, { key: "setLeadingMoveText", value: function setLeadingMoveText(x, y) { this.setLeading(-y); this.moveText(x, y); } }, { key: "addFontStyle", value: function addFontStyle(fontObj) { if (!this.cssStyle) { this.cssStyle = this.svgFactory.createElement('svg:style'); this.cssStyle.setAttributeNS(null, 'type', 'text/css'); this.defs.appendChild(this.cssStyle); } var url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema); this.cssStyle.textContent += "@font-face { font-family: \"".concat(fontObj.loadedName, "\";") + " src: url(".concat(url, "); }\n"); } }, { key: "setFont", value: function setFont(details) { var current = this.current; var fontObj = this.commonObjs.get(details[0]); var size = details[1]; current.font = fontObj; if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) { this.addFontStyle(fontObj); this.embeddedFonts[fontObj.loadedName] = fontObj; } current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX; var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal'; var italic = fontObj.italic ? 'italic' : 'normal'; if (size < 0) { size = -size; current.fontDirection = -1; } else { current.fontDirection = 1; } current.fontSize = size; current.fontFamily = fontObj.loadedName; current.fontWeight = bold; current.fontStyle = italic; current.tspan = this.svgFactory.createElement('svg:tspan'); current.tspan.setAttributeNS(null, 'y', pf(-current.y)); current.xcoords = []; } }, { key: "endText", value: function endText() { var current = this.current; if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && current.txtElement && current.txtElement.hasChildNodes()) { current.element = current.txtElement; this.clip('nonzero'); this.endPath(); } } }, { key: "setLineWidth", value: function setLineWidth(width) { if (width > 0) { this.current.lineWidth = width; } } }, { key: "setLineCap", value: function setLineCap(style) { this.current.lineCap = LINE_CAP_STYLES[style]; } }, { key: "setLineJoin", value: function setLineJoin(style) { this.current.lineJoin = LINE_JOIN_STYLES[style]; } }, { key: "setMiterLimit", value: function setMiterLimit(limit) { this.current.miterLimit = limit; } }, { key: "setStrokeAlpha", value: function setStrokeAlpha(strokeAlpha) { this.current.strokeAlpha = strokeAlpha; } }, { key: "setStrokeRGBColor", value: function setStrokeRGBColor(r, g, b) { this.current.strokeColor = _util.Util.makeCssRgb(r, g, b); } }, { key: "setFillAlpha", value: function setFillAlpha(fillAlpha) { this.current.fillAlpha = fillAlpha; } }, { key: "setFillRGBColor", value: function setFillRGBColor(r, g, b) { this.current.fillColor = _util.Util.makeCssRgb(r, g, b); this.current.tspan = this.svgFactory.createElement('svg:tspan'); this.current.xcoords = []; } }, { key: "setStrokeColorN", value: function setStrokeColorN(args) { this.current.strokeColor = this._makeColorN_Pattern(args); } }, { key: "setFillColorN", value: function setFillColorN(args) { this.current.fillColor = this._makeColorN_Pattern(args); } }, { key: "shadingFill", value: function shadingFill(args) { var width = this.viewport.width; var height = this.viewport.height; var inv = _util.Util.inverseTransform(this.transformMatrix); var bl = _util.Util.applyTransform([0, 0], inv); var br = _util.Util.applyTransform([0, height], inv); var ul = _util.Util.applyTransform([width, 0], inv); var ur = _util.Util.applyTransform([width, height], inv); var x0 = Math.min(bl[0], br[0], ul[0], ur[0]); var y0 = Math.min(bl[1], br[1], ul[1], ur[1]); var x1 = Math.max(bl[0], br[0], ul[0], ur[0]); var y1 = Math.max(bl[1], br[1], ul[1], ur[1]); var rect = this.svgFactory.createElement('svg:rect'); rect.setAttributeNS(null, 'x', x0); rect.setAttributeNS(null, 'y', y0); rect.setAttributeNS(null, 'width', x1 - x0); rect.setAttributeNS(null, 'height', y1 - y0); rect.setAttributeNS(null, 'fill', this._makeShadingPattern(args)); this._ensureTransformGroup().appendChild(rect); } }, { key: "_makeColorN_Pattern", value: function _makeColorN_Pattern(args) { if (args[0] === 'TilingPattern') { return this._makeTilingPattern(args); } return this._makeShadingPattern(args); } }, { key: "_makeTilingPattern", value: function _makeTilingPattern(args) { var color = args[1]; var operatorList = args[2]; var matrix = args[3] || _util.IDENTITY_MATRIX; var _args$ = _slicedToArray(args[4], 4), x0 = _args$[0], y0 = _args$[1], x1 = _args$[2], y1 = _args$[3]; var xstep = args[5]; var ystep = args[6]; var paintType = args[7]; var tilingId = "shading".concat(shadingCount++); var _Util$applyTransform = _util.Util.applyTransform([x0, y0], matrix), _Util$applyTransform2 = _slicedToArray(_Util$applyTransform, 2), tx0 = _Util$applyTransform2[0], ty0 = _Util$applyTransform2[1]; var _Util$applyTransform3 = _util.Util.applyTransform([x1, y1], matrix), _Util$applyTransform4 = _slicedToArray(_Util$applyTransform3, 2), tx1 = _Util$applyTransform4[0], ty1 = _Util$applyTransform4[1]; var _Util$singularValueDe = _util.Util.singularValueDecompose2dScale(matrix), _Util$singularValueDe2 = _slicedToArray(_Util$singularValueDe, 2), xscale = _Util$singularValueDe2[0], yscale = _Util$singularValueDe2[1]; var txstep = xstep * xscale; var tystep = ystep * yscale; var tiling = this.svgFactory.createElement('svg:pattern'); tiling.setAttributeNS(null, 'id', tilingId); tiling.setAttributeNS(null, 'patternUnits', 'userSpaceOnUse'); tiling.setAttributeNS(null, 'width', txstep); tiling.setAttributeNS(null, 'height', tystep); tiling.setAttributeNS(null, 'x', "".concat(tx0)); tiling.setAttributeNS(null, 'y', "".concat(ty0)); var svg = this.svg; var transformMatrix = this.transformMatrix; var fillColor = this.current.fillColor; var strokeColor = this.current.strokeColor; var bbox = this.svgFactory.create(tx1 - tx0, ty1 - ty0); this.svg = bbox; this.transformMatrix = matrix; if (paintType === 2) { var cssColor = _util.Util.makeCssRgb.apply(_util.Util, _toConsumableArray(color)); this.current.fillColor = cssColor; this.current.strokeColor = cssColor; } this.executeOpTree(this.convertOpList(operatorList)); this.svg = svg; this.transformMatrix = transformMatrix; this.current.fillColor = fillColor; this.current.strokeColor = strokeColor; tiling.appendChild(bbox.childNodes[0]); this.defs.appendChild(tiling); return "url(#".concat(tilingId, ")"); } }, { key: "_makeShadingPattern", value: function _makeShadingPattern(args) { switch (args[0]) { case 'RadialAxial': var shadingId = "shading".concat(shadingCount++); var colorStops = args[2]; var gradient; switch (args[1]) { case 'axial': var point0 = args[3]; var point1 = args[4]; gradient = this.svgFactory.createElement('svg:linearGradient'); gradient.setAttributeNS(null, 'id', shadingId); gradient.setAttributeNS(null, 'gradientUnits', 'userSpaceOnUse'); gradient.setAttributeNS(null, 'x1', point0[0]); gradient.setAttributeNS(null, 'y1', point0[1]); gradient.setAttributeNS(null, 'x2', point1[0]); gradient.setAttributeNS(null, 'y2', point1[1]); break; case 'radial': var focalPoint = args[3]; var circlePoint = args[4]; var focalRadius = args[5]; var circleRadius = args[6]; gradient = this.svgFactory.createElement('svg:radialGradient'); gradient.setAttributeNS(null, 'id', shadingId); gradient.setAttributeNS(null, 'gradientUnits', 'userSpaceOnUse'); gradient.setAttributeNS(null, 'cx', circlePoint[0]); gradient.setAttributeNS(null, 'cy', circlePoint[1]); gradient.setAttributeNS(null, 'r', circleRadius); gradient.setAttributeNS(null, 'fx', focalPoint[0]); gradient.setAttributeNS(null, 'fy', focalPoint[1]); gradient.setAttributeNS(null, 'fr', focalRadius); break; default: throw new Error("Unknown RadialAxial type: ".concat(args[1])); } var _iteratorNormalCompletion5 = true; var _didIteratorError5 = false; var _iteratorError5 = undefined; try { for (var _iterator5 = colorStops[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) { var colorStop = _step5.value; var stop = this.svgFactory.createElement('svg:stop'); stop.setAttributeNS(null, 'offset', colorStop[0]); stop.setAttributeNS(null, 'stop-color', colorStop[1]); gradient.appendChild(stop); } } catch (err) { _didIteratorError5 = true; _iteratorError5 = err; } finally { try { if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) { _iterator5["return"](); } } finally { if (_didIteratorError5) { throw _iteratorError5; } } } this.defs.appendChild(gradient); return "url(#".concat(shadingId, ")"); case 'Mesh': (0, _util.warn)('Unimplemented pattern Mesh'); return null; case 'Dummy': return 'hotpink'; default: throw new Error("Unknown IR type: ".concat(args[0])); } } }, { key: "setDash", value: function setDash(dashArray, dashPhase) { this.current.dashArray = dashArray; this.current.dashPhase = dashPhase; } }, { key: "constructPath", value: function constructPath(ops, args) { var current = this.current; var x = current.x, y = current.y; var d = []; var j = 0; var _iteratorNormalCompletion6 = true; var _didIteratorError6 = false; var _iteratorError6 = undefined; try { for (var _iterator6 = ops[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) { var op = _step6.value; switch (op | 0) { case _util.OPS.rectangle: x = args[j++]; y = args[j++]; var width = args[j++]; var height = args[j++]; var xw = x + width; var yh = y + height; d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z'); break; case _util.OPS.moveTo: x = args[j++]; y = args[j++]; d.push('M', pf(x), pf(y)); break; case _util.OPS.lineTo: x = args[j++]; y = args[j++]; d.push('L', pf(x), pf(y)); break; case _util.OPS.curveTo: x = args[j + 4]; y = args[j + 5]; d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y)); j += 6; break; case _util.OPS.curveTo2: x = args[j + 2]; y = args[j + 3]; d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3])); j += 4; break; case _util.OPS.curveTo3: x = args[j + 2]; y = args[j + 3]; d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y)); j += 4; break; case _util.OPS.closePath: d.push('Z'); break; } } } catch (err) { _didIteratorError6 = true; _iteratorError6 = err; } finally { try { if (!_iteratorNormalCompletion6 && _iterator6["return"] != null) { _iterator6["return"](); } } finally { if (_didIteratorError6) { throw _iteratorError6; } } } d = d.join(' '); if (current.path && ops.length > 0 && ops[0] !== _util.OPS.rectangle && ops[0] !== _util.OPS.moveTo) { d = current.path.getAttributeNS(null, 'd') + d; } else { current.path = this.svgFactory.createElement('svg:path'); this._ensureTransformGroup().appendChild(current.path); } current.path.setAttributeNS(null, 'd', d); current.path.setAttributeNS(null, 'fill', 'none'); current.element = current.path; current.setCurrentPoint(x, y); } }, { key: "endPath", value: function endPath() { var current = this.current; current.path = null; if (!this.pendingClip) { return; } if (!current.element) { this.pendingClip = null; return; } var clipId = "clippath".concat(clipCount++); var clipPath = this.svgFactory.createElement('svg:clipPath'); clipPath.setAttributeNS(null, 'id', clipId); clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix)); var clipElement = current.element.cloneNode(true); if (this.pendingClip === 'evenodd') { clipElement.setAttributeNS(null, 'clip-rule', 'evenodd'); } else { clipElement.setAttributeNS(null, 'clip-rule', 'nonzero'); } this.pendingClip = null; clipPath.appendChild(clipElement); this.defs.appendChild(clipPath); if (current.activeClipUrl) { current.clipGroup = null; this.extraStack.forEach(function (prev) { prev.clipGroup = null; }); clipPath.setAttributeNS(null, 'clip-path', current.activeClipUrl); } current.activeClipUrl = "url(#".concat(clipId, ")"); this.tgrp = null; } }, { key: "clip", value: function clip(type) { this.pendingClip = type; } }, { key: "closePath", value: function closePath() { var current = this.current; if (current.path) { var d = "".concat(current.path.getAttributeNS(null, 'd'), "Z"); current.path.setAttributeNS(null, 'd', d); } } }, { key: "setLeading", value: function setLeading(leading) { this.current.leading = -leading; } }, { key: "setTextRise", value: function setTextRise(textRise) { this.current.textRise = textRise; } }, { key: "setTextRenderingMode", value: function setTextRenderingMode(textRenderingMode) { this.current.textRenderingMode = textRenderingMode; } }, { key: "setHScale", value: function setHScale(scale) { this.current.textHScale = scale / 100; } }, { key: "setRenderingIntent", value: function setRenderingIntent(intent) {} }, { key: "setFlatness", value: function setFlatness(flatness) {} }, { key: "setGState", value: function setGState(states) { var _iteratorNormalCompletion7 = true; var _didIteratorError7 = false; var _iteratorError7 = undefined; try { for (var _iterator7 = states[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) { var _step7$value = _slicedToArray(_step7.value, 2), key = _step7$value[0], value = _step7$value[1]; switch (key) { case 'LW': this.setLineWidth(value); break; case 'LC': this.setLineCap(value); break; case 'LJ': this.setLineJoin(value); break; case 'ML': this.setMiterLimit(value); break; case 'D': this.setDash(value[0], value[1]); break; case 'RI': this.setRenderingIntent(value); break; case 'FL': this.setFlatness(value); break; case 'Font': this.setFont(value); break; case 'CA': this.setStrokeAlpha(value); break; case 'ca': this.setFillAlpha(value); break; default: (0, _util.warn)("Unimplemented graphic state operator ".concat(key)); break; } } } catch (err) { _didIteratorError7 = true; _iteratorError7 = err; } finally { try { if (!_iteratorNormalCompletion7 && _iterator7["return"] != null) { _iterator7["return"](); } } finally { if (_didIteratorError7) { throw _iteratorError7; } } } } }, { key: "fill", value: function fill() { var current = this.current; if (current.element) { current.element.setAttributeNS(null, 'fill', current.fillColor); current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha); this.endPath(); } } }, { key: "stroke", value: function stroke() { var current = this.current; if (current.element) { this._setStrokeAttributes(current.element); current.element.setAttributeNS(null, 'fill', 'none'); this.endPath(); } } }, { key: "_setStrokeAttributes", value: function _setStrokeAttributes(element) { var lineWidthScale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; var current = this.current; var dashArray = current.dashArray; if (lineWidthScale !== 1 && dashArray.length > 0) { dashArray = dashArray.map(function (value) { return lineWidthScale * value; }); } element.setAttributeNS(null, 'stroke', current.strokeColor); element.setAttributeNS(null, 'stroke-opacity', current.strokeAlpha); element.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit)); element.setAttributeNS(null, 'stroke-linecap', current.lineCap); element.setAttributeNS(null, 'stroke-linejoin', current.lineJoin); element.setAttributeNS(null, 'stroke-width', pf(lineWidthScale * current.lineWidth) + 'px'); element.setAttributeNS(null, 'stroke-dasharray', dashArray.map(pf).join(' ')); element.setAttributeNS(null, 'stroke-dashoffset', pf(lineWidthScale * current.dashPhase) + 'px'); } }, { key: "eoFill", value: function eoFill() { if (this.current.element) { this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd'); } this.fill(); } }, { key: "fillStroke", value: function fillStroke() { this.stroke(); this.fill(); } }, { key: "eoFillStroke", value: function eoFillStroke() { if (this.current.element) { this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd'); } this.fillStroke(); } }, { key: "closeStroke", value: function closeStroke() { this.closePath(); this.stroke(); } }, { key: "closeFillStroke", value: function closeFillStroke() { this.closePath(); this.fillStroke(); } }, { key: "closeEOFillStroke", value: function closeEOFillStroke() { this.closePath(); this.eoFillStroke(); } }, { key: "paintSolidColorImageMask", value: function paintSolidColorImageMask() { var rect = this.svgFactory.createElement('svg:rect'); rect.setAttributeNS(null, 'x', '0'); rect.setAttributeNS(null, 'y', '0'); rect.setAttributeNS(null, 'width', '1px'); rect.setAttributeNS(null, 'height', '1px'); rect.setAttributeNS(null, 'fill', this.current.fillColor); this._ensureTransformGroup().appendChild(rect); } }, { key: "paintJpegXObject", value: function paintJpegXObject(objId, w, h) { var imgObj = this.objs.get(objId); var imgEl = this.svgFactory.createElement('svg:image'); imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src); imgEl.setAttributeNS(null, 'width', pf(w)); imgEl.setAttributeNS(null, 'height', pf(h)); imgEl.setAttributeNS(null, 'x', '0'); imgEl.setAttributeNS(null, 'y', pf(-h)); imgEl.setAttributeNS(null, 'transform', "scale(".concat(pf(1 / w), " ").concat(pf(-1 / h), ")")); this._ensureTransformGroup().appendChild(imgEl); } }, { key: "paintImageXObject", value: function paintImageXObject(objId) { var imgData = this.objs.get(objId); if (!imgData) { (0, _util.warn)("Dependent image with object ID ".concat(objId, " is not ready yet")); return; } this.paintInlineImageXObject(imgData); } }, { key: "paintInlineImageXObject", value: function paintInlineImageXObject(imgData, mask) { var width = imgData.width; var height = imgData.height; var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask); var cliprect = this.svgFactory.createElement('svg:rect'); cliprect.setAttributeNS(null, 'x', '0'); cliprect.setAttributeNS(null, 'y', '0'); cliprect.setAttributeNS(null, 'width', pf(width)); cliprect.setAttributeNS(null, 'height', pf(height)); this.current.element = cliprect; this.clip('nonzero'); var imgEl = this.svgFactory.createElement('svg:image'); imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc); imgEl.setAttributeNS(null, 'x', '0'); imgEl.setAttributeNS(null, 'y', pf(-height)); imgEl.setAttributeNS(null, 'width', pf(width) + 'px'); imgEl.setAttributeNS(null, 'height', pf(height) + 'px'); imgEl.setAttributeNS(null, 'transform', "scale(".concat(pf(1 / width), " ").concat(pf(-1 / height), ")")); if (mask) { mask.appendChild(imgEl); } else { this._ensureTransformGroup().appendChild(imgEl); } } }, { key: "paintImageMaskXObject", value: function paintImageMaskXObject(imgData) { var current = this.current; var width = imgData.width; var height = imgData.height; var fillColor = current.fillColor; current.maskId = "mask".concat(maskCount++); var mask = this.svgFactory.createElement('svg:mask'); mask.setAttributeNS(null, 'id', current.maskId); var rect = this.svgFactory.createElement('svg:rect'); rect.setAttributeNS(null, 'x', '0'); rect.setAttributeNS(null, 'y', '0'); rect.setAttributeNS(null, 'width', pf(width)); rect.setAttributeNS(null, 'height', pf(height)); rect.setAttributeNS(null, 'fill', fillColor); rect.setAttributeNS(null, 'mask', "url(#".concat(current.maskId, ")")); this.defs.appendChild(mask); this._ensureTransformGroup().appendChild(rect); this.paintInlineImageXObject(imgData, mask); } }, { key: "paintFormXObjectBegin", value: function paintFormXObjectBegin(matrix, bbox) { if (Array.isArray(matrix) && matrix.length === 6) { this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } if (bbox) { var width = bbox[2] - bbox[0]; var height = bbox[3] - bbox[1]; var cliprect = this.svgFactory.createElement('svg:rect'); cliprect.setAttributeNS(null, 'x', bbox[0]); cliprect.setAttributeNS(null, 'y', bbox[1]); cliprect.setAttributeNS(null, 'width', pf(width)); cliprect.setAttributeNS(null, 'height', pf(height)); this.current.element = cliprect; this.clip('nonzero'); this.endPath(); } } }, { key: "paintFormXObjectEnd", value: function paintFormXObjectEnd() {} }, { key: "_initialize", value: function _initialize(viewport) { var svg = this.svgFactory.create(viewport.width, viewport.height); var definitions = this.svgFactory.createElement('svg:defs'); svg.appendChild(definitions); this.defs = definitions; var rootGroup = this.svgFactory.createElement('svg:g'); rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform)); svg.appendChild(rootGroup); this.svg = rootGroup; return svg; } }, { key: "_ensureClipGroup", value: function _ensureClipGroup() { if (!this.current.clipGroup) { var clipGroup = this.svgFactory.createElement('svg:g'); clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl); this.svg.appendChild(clipGroup); this.current.clipGroup = clipGroup; } return this.current.clipGroup; } }, { key: "_ensureTransformGroup", value: function _ensureTransformGroup() { if (!this.tgrp) { this.tgrp = this.svgFactory.createElement('svg:g'); this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix)); if (this.current.activeClipUrl) { this._ensureClipGroup().appendChild(this.tgrp); } else { this.svg.appendChild(this.tgrp); } } return this.tgrp; } }]); return SVGGraphics; }(); }