implement some operators and add TODOs for remaining undefined ones
This commit is contained in:
parent
6a9f7def45
commit
07c81a624e
127
pdf.js
127
pdf.js
@ -1596,6 +1596,7 @@ var CanvasGraphics = (function() {
|
|||||||
w: "setLineWidth",
|
w: "setLineWidth",
|
||||||
J: "setLineCap",
|
J: "setLineCap",
|
||||||
j: "setLineJoin",
|
j: "setLineJoin",
|
||||||
|
M: "setMiterLimit",
|
||||||
d: "setDash",
|
d: "setDash",
|
||||||
ri: "setRenderingIntent",
|
ri: "setRenderingIntent",
|
||||||
i: "setFlatness",
|
i: "setFlatness",
|
||||||
@ -1608,13 +1609,18 @@ var CanvasGraphics = (function() {
|
|||||||
m: "moveTo",
|
m: "moveTo",
|
||||||
l: "lineTo",
|
l: "lineTo",
|
||||||
c: "curveTo",
|
c: "curveTo",
|
||||||
|
v: "curveTo2",
|
||||||
|
y: "curveTo3",
|
||||||
h: "closePath",
|
h: "closePath",
|
||||||
re: "rectangle",
|
re: "rectangle",
|
||||||
S: "stroke",
|
S: "stroke",
|
||||||
|
s: "closeStroke",
|
||||||
f: "fill",
|
f: "fill",
|
||||||
"f*": "eoFill",
|
"f*": "eoFill",
|
||||||
B: "fillStroke",
|
B: "fillStroke",
|
||||||
|
"B*": "eoFillStroke",
|
||||||
b: "closeFillStroke",
|
b: "closeFillStroke",
|
||||||
|
"b*": "closeEOFillStroke",
|
||||||
n: "endPath",
|
n: "endPath",
|
||||||
|
|
||||||
// Clipping
|
// Clipping
|
||||||
@ -1624,15 +1630,25 @@ var CanvasGraphics = (function() {
|
|||||||
// Text
|
// Text
|
||||||
BT: "beginText",
|
BT: "beginText",
|
||||||
ET: "endText",
|
ET: "endText",
|
||||||
|
Tc: "setCharSpacing",
|
||||||
|
Tw: "setWordSpacing",
|
||||||
|
Tz: "setHScale",
|
||||||
TL: "setLeading",
|
TL: "setLeading",
|
||||||
Tf: "setFont",
|
Tf: "setFont",
|
||||||
|
Tr: "setTextRenderingMode",
|
||||||
|
Ts: "setTextRise",
|
||||||
Td: "moveText",
|
Td: "moveText",
|
||||||
|
TD: "setLeadingMoveText",
|
||||||
Tm: "setTextMatrix",
|
Tm: "setTextMatrix",
|
||||||
"T*": "nextLine",
|
"T*": "nextLine",
|
||||||
Tj: "showText",
|
Tj: "showText",
|
||||||
TJ: "showSpacedText",
|
TJ: "showSpacedText",
|
||||||
|
"'": "nextLineShowText",
|
||||||
|
'"': "nextLineSetSpacingShowText",
|
||||||
|
|
||||||
// Type3 fonts
|
// Type3 fonts
|
||||||
|
d0: "setCharWidth",
|
||||||
|
d1: "setCharWidthAndBounds",
|
||||||
|
|
||||||
// Color
|
// Color
|
||||||
CS: "setStrokeColorSpace",
|
CS: "setStrokeColorSpace",
|
||||||
@ -1645,16 +1661,28 @@ var CanvasGraphics = (function() {
|
|||||||
g: "setFillGray",
|
g: "setFillGray",
|
||||||
RG: "setStrokeRGBColor",
|
RG: "setStrokeRGBColor",
|
||||||
rg: "setFillRGBColor",
|
rg: "setFillRGBColor",
|
||||||
|
K: "setStrokeCMYKColor",
|
||||||
|
k: "setFillCMYKColor",
|
||||||
|
|
||||||
// Shading
|
// Shading
|
||||||
sh: "shadingFill",
|
sh: "shadingFill",
|
||||||
|
|
||||||
// Images
|
// Images
|
||||||
|
BI: "beginInlineImage",
|
||||||
|
|
||||||
// XObjects
|
// XObjects
|
||||||
Do: "paintXObject",
|
Do: "paintXObject",
|
||||||
|
|
||||||
// Marked content
|
// Marked content
|
||||||
|
MP: "markPoint",
|
||||||
|
DP: "markPointProps",
|
||||||
|
BMC: "beginMarkedContent",
|
||||||
|
BDC: "beginMarkedContentProps",
|
||||||
|
EMC: "endMarkedContent",
|
||||||
|
|
||||||
// Compatibility
|
// Compatibility
|
||||||
|
BX: "beginCompat",
|
||||||
|
EX: "endCompat",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1780,6 +1808,9 @@ var CanvasGraphics = (function() {
|
|||||||
setLineJoin: function(style) {
|
setLineJoin: function(style) {
|
||||||
this.ctx.lineJoin = LINE_JOIN_STYLES[style];
|
this.ctx.lineJoin = LINE_JOIN_STYLES[style];
|
||||||
},
|
},
|
||||||
|
setMiterLimit: function(limit) {
|
||||||
|
this.ctx.miterLimit = limit;
|
||||||
|
},
|
||||||
setDash: function(dashArray, dashPhase) {
|
setDash: function(dashArray, dashPhase) {
|
||||||
TODO("set dash");
|
TODO("set dash");
|
||||||
},
|
},
|
||||||
@ -1818,6 +1849,12 @@ var CanvasGraphics = (function() {
|
|||||||
curveTo: function(x1, y1, x2, y2, x3, y3) {
|
curveTo: function(x1, y1, x2, y2, x3, y3) {
|
||||||
this.ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
|
this.ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
|
||||||
},
|
},
|
||||||
|
curveTo2: function(x2, y2, x3, y3) {
|
||||||
|
TODO("'v' operator: need current point in gfx context");
|
||||||
|
},
|
||||||
|
curveTo3: function(x1, y1, x3, y3) {
|
||||||
|
this.curveTo(x1, y1, x3, y3, x3, y3);
|
||||||
|
},
|
||||||
closePath: function() {
|
closePath: function() {
|
||||||
this.ctx.closePath();
|
this.ctx.closePath();
|
||||||
},
|
},
|
||||||
@ -1828,6 +1865,10 @@ var CanvasGraphics = (function() {
|
|||||||
this.ctx.stroke();
|
this.ctx.stroke();
|
||||||
this.consumePath();
|
this.consumePath();
|
||||||
},
|
},
|
||||||
|
closeStroke: function() {
|
||||||
|
this.closePath();
|
||||||
|
this.stroke();
|
||||||
|
},
|
||||||
fill: function() {
|
fill: function() {
|
||||||
this.ctx.fill();
|
this.ctx.fill();
|
||||||
this.consumePath();
|
this.consumePath();
|
||||||
@ -1842,9 +1883,19 @@ var CanvasGraphics = (function() {
|
|||||||
this.ctx.stroke();
|
this.ctx.stroke();
|
||||||
this.consumePath();
|
this.consumePath();
|
||||||
},
|
},
|
||||||
|
eoFillStroke: function() {
|
||||||
|
var savedFillRule = this.setEOFillRule();
|
||||||
|
this.fillStroke();
|
||||||
|
this.restoreFillRule(savedFillRule);
|
||||||
|
},
|
||||||
closeFillStroke: function() {
|
closeFillStroke: function() {
|
||||||
return this.fillStroke();
|
return this.fillStroke();
|
||||||
},
|
},
|
||||||
|
closeEOFillStroke: function() {
|
||||||
|
var savedFillRule = this.setEOFillRule();
|
||||||
|
this.fillStroke();
|
||||||
|
this.restoreFillRule(savedFillRule);
|
||||||
|
},
|
||||||
endPath: function() {
|
endPath: function() {
|
||||||
this.consumePath();
|
this.consumePath();
|
||||||
},
|
},
|
||||||
@ -1865,6 +1916,15 @@ var CanvasGraphics = (function() {
|
|||||||
},
|
},
|
||||||
endText: function() {
|
endText: function() {
|
||||||
},
|
},
|
||||||
|
setCharSpacing: function(spacing) {
|
||||||
|
TODO("character (glyph?) spacing");
|
||||||
|
},
|
||||||
|
setWordSpacing: function(spacing) {
|
||||||
|
TODO("word spacing");
|
||||||
|
},
|
||||||
|
setHSpacing: function(scale) {
|
||||||
|
TODO("horizontal text scale");
|
||||||
|
},
|
||||||
setLeading: function(leading) {
|
setLeading: function(leading) {
|
||||||
this.current.leading = leading;
|
this.current.leading = leading;
|
||||||
},
|
},
|
||||||
@ -1880,10 +1940,20 @@ var CanvasGraphics = (function() {
|
|||||||
TODO("using hard-coded font for testing");
|
TODO("using hard-coded font for testing");
|
||||||
this.ctx.font = this.current.fontSize +'px "Nimbus Roman No9 L"';
|
this.ctx.font = this.current.fontSize +'px "Nimbus Roman No9 L"';
|
||||||
},
|
},
|
||||||
|
setTextRenderingMode: function(mode) {
|
||||||
|
TODO("text rendering mode");
|
||||||
|
},
|
||||||
|
setTextRise: function(rise) {
|
||||||
|
TODO("text rise");
|
||||||
|
},
|
||||||
moveText: function (x, y) {
|
moveText: function (x, y) {
|
||||||
this.current.x = this.current.lineX += x;
|
this.current.x = this.current.lineX += x;
|
||||||
this.current.y = this.current.lineY += y;
|
this.current.y = this.current.lineY += y;
|
||||||
},
|
},
|
||||||
|
setLeadingMoveText: function(x, y) {
|
||||||
|
this.setLeading(-y);
|
||||||
|
this.moveText(x, y);
|
||||||
|
},
|
||||||
setTextMatrix: function(a, b, c, d, e, f) {
|
setTextMatrix: function(a, b, c, d, e, f) {
|
||||||
this.current.textMatrix = [ a, b, c, d, e, f ];
|
this.current.textMatrix = [ a, b, c, d, e, f ];
|
||||||
this.current.x = this.current.lineX = 0;
|
this.current.x = this.current.lineX = 0;
|
||||||
@ -1915,8 +1985,23 @@ var CanvasGraphics = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
nextLineShowText: function(text) {
|
||||||
|
this.nextLine();
|
||||||
|
this.showText(text);
|
||||||
|
},
|
||||||
|
nextLineSetSpacingShowText: function(wordSpacing, charSpacing, text) {
|
||||||
|
this.setWordSpacing(wordSpacing);
|
||||||
|
this.setCharSpacing(charSpacing);
|
||||||
|
this.nextLineShowText(text);
|
||||||
|
},
|
||||||
|
|
||||||
// Type3 fonts
|
// Type3 fonts
|
||||||
|
setCharWidth: function(xWidth, yWidth) {
|
||||||
|
TODO("type 3 fonts ('d0' operator)");
|
||||||
|
},
|
||||||
|
setCharWidthAndBounds: function(xWidth, yWidth, llx, lly, urx, ury) {
|
||||||
|
TODO("type 3 fonts ('d1' operator)");
|
||||||
|
},
|
||||||
|
|
||||||
// Color
|
// Color
|
||||||
setStrokeColorSpace: function(space) {
|
setStrokeColorSpace: function(space) {
|
||||||
@ -1961,6 +2046,12 @@ var CanvasGraphics = (function() {
|
|||||||
setFillRGBColor: function(r, g, b) {
|
setFillRGBColor: function(r, g, b) {
|
||||||
this.ctx.fillStyle = this.makeCssRgb(r, g, b);
|
this.ctx.fillStyle = this.makeCssRgb(r, g, b);
|
||||||
},
|
},
|
||||||
|
setStrokeCMYKColor: function(c, m, y, k) {
|
||||||
|
TODO("CMYK space");
|
||||||
|
},
|
||||||
|
setFillCMYKColor: function(c, m, y, k) {
|
||||||
|
TODO("CMYK space");
|
||||||
|
},
|
||||||
|
|
||||||
// Shading
|
// Shading
|
||||||
shadingFill: function(entryRef) {
|
shadingFill: function(entryRef) {
|
||||||
@ -2035,6 +2126,15 @@ var CanvasGraphics = (function() {
|
|||||||
this.consumePath();
|
this.consumePath();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Images
|
||||||
|
beginInlineImage: function() {
|
||||||
|
TODO("inline images");
|
||||||
|
error("(Stream will not be parsed properly, bailing now)");
|
||||||
|
// Like an inline stream:
|
||||||
|
// - key/value pairs up to Cmd(ID)
|
||||||
|
// - then image data up to Cmd(EI)
|
||||||
|
},
|
||||||
|
|
||||||
// XObjects
|
// XObjects
|
||||||
paintXObject: function(obj) {
|
paintXObject: function(obj) {
|
||||||
var xobj = this.xobjs.get(obj.name);
|
var xobj = this.xobjs.get(obj.name);
|
||||||
@ -2262,6 +2362,33 @@ var CanvasGraphics = (function() {
|
|||||||
this.restore();
|
this.restore();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Marked content
|
||||||
|
|
||||||
|
markPoint: function(tag) {
|
||||||
|
TODO("Marked content");
|
||||||
|
},
|
||||||
|
markPointProps: function(tag, properties) {
|
||||||
|
TODO("Marked content");
|
||||||
|
},
|
||||||
|
beginMarkedContent: function(tag) {
|
||||||
|
TODO("Marked content");
|
||||||
|
},
|
||||||
|
beginMarkedContentProps: function(tag, properties) {
|
||||||
|
TODO("Marked content");
|
||||||
|
},
|
||||||
|
endMarkedContent: function() {
|
||||||
|
TODO("Marked content");
|
||||||
|
},
|
||||||
|
|
||||||
|
// Compatibility
|
||||||
|
|
||||||
|
beginCompat: function() {
|
||||||
|
TODO("ignore undefined operators (should we do that anyway?)");
|
||||||
|
},
|
||||||
|
endCompat: function() {
|
||||||
|
TODO("stop ignoring undefined operators");
|
||||||
|
},
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
||||||
consumePath: function() {
|
consumePath: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user