Added endPath, endText. fixes extra <g> elements
This commit is contained in:
parent
2380b38b27
commit
6e4dd83a4d
@ -192,7 +192,6 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
|
|||||||
this.tgrp = document.createElementNS(NS, 'svg:g');
|
this.tgrp = document.createElementNS(NS, 'svg:g');
|
||||||
this.tgrp.setAttributeNS(null, 'transform',
|
this.tgrp.setAttributeNS(null, 'transform',
|
||||||
'matrix(' + this.transformMatrix + ')');
|
'matrix(' + this.transformMatrix + ')');
|
||||||
this.pgrp.appendChild(this.tgrp);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
beginDrawing: function SVGGraphics_beginDrawing(viewport, pageNum,
|
beginDrawing: function SVGGraphics_beginDrawing(viewport, pageNum,
|
||||||
@ -266,7 +265,7 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
|
|||||||
this.showText(args[0]);
|
this.showText(args[0]);
|
||||||
break;
|
break;
|
||||||
case OPS.endText:
|
case OPS.endText:
|
||||||
this.endText(args);
|
this.endText();
|
||||||
break;
|
break;
|
||||||
case OPS.moveText:
|
case OPS.moveText:
|
||||||
this.moveText(args[0], args[1]);
|
this.moveText(args[0], args[1]);
|
||||||
@ -351,6 +350,9 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
|
|||||||
case OPS.constructPath:
|
case OPS.constructPath:
|
||||||
this.constructPath(args[0], args[1]);
|
this.constructPath(args[0], args[1]);
|
||||||
break;
|
break;
|
||||||
|
case OPS.endPath:
|
||||||
|
this.endPath();
|
||||||
|
break;
|
||||||
case 92:
|
case 92:
|
||||||
this.group(opTree[x].items);
|
this.group(opTree[x].items);
|
||||||
break;
|
break;
|
||||||
@ -477,7 +479,7 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
|
|||||||
this.tgrp.appendChild(current.txtElement);
|
this.tgrp.appendChild(current.txtElement);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
|
setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
|
||||||
this.setLeading(-y);
|
this.setLeading(-y);
|
||||||
this.moveText(x, y);
|
this.moveText(x, y);
|
||||||
@ -515,7 +517,14 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
endText: function SVGGraphics_endText(args) {
|
endText: function SVGGraphics_endText(args) {
|
||||||
// Empty for now. Not sure how to break showText into this.
|
if (this.current.pendingClip) {
|
||||||
|
this.pgrp.appendChild(this.cgrp);
|
||||||
|
} else {
|
||||||
|
this.pgrp.appendChild(this.tgrp);
|
||||||
|
}
|
||||||
|
this.tgrp = document.createElementNS(NS, 'svg:g');
|
||||||
|
this.tgrp.setAttributeNS(null, 'transform',
|
||||||
|
'matrix(' + this.transformMatrix + ')');
|
||||||
},
|
},
|
||||||
|
|
||||||
// Path properties
|
// Path properties
|
||||||
@ -608,17 +617,33 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
|
|||||||
current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray);
|
current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray);
|
||||||
current.path.setAttributeNS(null, 'stroke-dashoffset',
|
current.path.setAttributeNS(null, 'stroke-dashoffset',
|
||||||
current.dashPhase + 'px');
|
current.dashPhase + 'px');
|
||||||
|
current.path.setAttributeNS(null, 'fill', 'none');
|
||||||
|
|
||||||
|
this.tgrp.appendChild(current.path);
|
||||||
if (current.pendingClip) {
|
if (current.pendingClip) {
|
||||||
this.cgrp.appendChild(this.tgrp);
|
this.cgrp.appendChild(this.tgrp);
|
||||||
|
this.pgrp.appendChild(this.cgrp);
|
||||||
|
} else {
|
||||||
|
this.pgrp.appendChild(this.tgrp);
|
||||||
}
|
}
|
||||||
current.path.setAttributeNS(null, 'fill', 'none');
|
|
||||||
this.tgrp.appendChild(current.path);
|
|
||||||
// Saving a reference in current.element so that it can be addressed
|
// Saving a reference in current.element so that it can be addressed
|
||||||
// in 'fill' and 'stroke'
|
// in 'fill' and 'stroke'
|
||||||
current.element = current.path;
|
current.element = current.path;
|
||||||
current.setCurrentPoint(x, y);
|
current.setCurrentPoint(x, y);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
endPath: function SVGGraphics_endPath() {
|
||||||
|
var current = this.current;
|
||||||
|
if (current.pendingClip) {
|
||||||
|
this.pgrp.appendChild(this.cgrp);
|
||||||
|
} else {
|
||||||
|
this.pgrp.appendChild(this.tgrp);
|
||||||
|
}
|
||||||
|
this.tgrp = document.createElementNS(NS, 'svg:g');
|
||||||
|
this.tgrp.setAttributeNS(null, 'transform',
|
||||||
|
'matrix(' + this.transformMatrix + ')');
|
||||||
|
},
|
||||||
|
|
||||||
clip: function SVGGraphics_clip(type) {
|
clip: function SVGGraphics_clip(type) {
|
||||||
var current = this.current;
|
var current = this.current;
|
||||||
// Add current path to clipping path
|
// Add current path to clipping path
|
||||||
@ -766,10 +791,14 @@ var SVGGraphics = (function SVGGraphicsClosure(ctx) {
|
|||||||
imgEl.setAttributeNS(null, 'y', -h);
|
imgEl.setAttributeNS(null, 'y', -h);
|
||||||
imgEl.setAttributeNS(null, 'transform', 'scale(' + 1 / w +
|
imgEl.setAttributeNS(null, 'transform', 'scale(' + 1 / w +
|
||||||
' ' + -1 / h + ')');
|
' ' + -1 / h + ')');
|
||||||
|
|
||||||
|
this.tgrp.appendChild(imgEl);
|
||||||
if (current.pendingClip) {
|
if (current.pendingClip) {
|
||||||
this.cgrp.appendChild(this.tgrp);
|
this.cgrp.appendChild(this.tgrp);
|
||||||
|
this.pgrp.appendChild(this.cgrp);
|
||||||
|
} else {
|
||||||
|
this.pgrp.appendChild(this.tgrp);
|
||||||
}
|
}
|
||||||
this.tgrp.appendChild(imgEl);
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
return SVGGraphics;
|
return SVGGraphics;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user