Implement "n" (end path), add stubs for NYI operators
This commit is contained in:
parent
f9839beda8
commit
fcdd7e3845
114
pdf.js
114
pdf.js
@ -1003,6 +1003,8 @@ var Interpreter = (function() {
|
|||||||
J: gfx.setLineCap,
|
J: gfx.setLineCap,
|
||||||
j: gfx.setLineJoin,
|
j: gfx.setLineJoin,
|
||||||
d: gfx.setDash,
|
d: gfx.setDash,
|
||||||
|
ri: gfx.setRenderingIntent,
|
||||||
|
i: gfx.setFlatness,
|
||||||
q: gfx.save,
|
q: gfx.save,
|
||||||
Q: gfx.restore,
|
Q: gfx.restore,
|
||||||
cm: gfx.transform,
|
cm: gfx.transform,
|
||||||
@ -1017,6 +1019,7 @@ var Interpreter = (function() {
|
|||||||
f: gfx.fill,
|
f: gfx.fill,
|
||||||
B: gfx.fillStroke,
|
B: gfx.fillStroke,
|
||||||
b: gfx.closeFillStroke,
|
b: gfx.closeFillStroke,
|
||||||
|
n: gfx.endPath,
|
||||||
|
|
||||||
// Clipping
|
// Clipping
|
||||||
|
|
||||||
@ -1028,12 +1031,17 @@ var Interpreter = (function() {
|
|||||||
gfx.setFont(font, size);
|
gfx.setFont(font, size);
|
||||||
},
|
},
|
||||||
Td: gfx.moveText,
|
Td: gfx.moveText,
|
||||||
|
Tm: gfx.setTextMatrix,
|
||||||
Tj: gfx.showText,
|
Tj: gfx.showText,
|
||||||
TJ: gfx.showSpacedText,
|
TJ: gfx.showSpacedText,
|
||||||
|
|
||||||
// Type3 fonts
|
// Type3 fonts
|
||||||
|
|
||||||
// Color
|
// Color
|
||||||
|
CS: gfx.setStrokeColorSpace,
|
||||||
|
cs: gfx.setFillColorSpace,
|
||||||
|
SC: gfx.setStrokeColor,
|
||||||
|
sc: gfx.setFillColor,
|
||||||
g: gfx.setFillGray,
|
g: gfx.setFillGray,
|
||||||
RG: gfx.setStrokeRGBColor,
|
RG: gfx.setStrokeRGBColor,
|
||||||
rg: gfx.setFillRGBColor,
|
rg: gfx.setFillRGBColor,
|
||||||
@ -1041,6 +1049,8 @@ var Interpreter = (function() {
|
|||||||
// Shading
|
// Shading
|
||||||
// Images
|
// Images
|
||||||
// XObjects
|
// XObjects
|
||||||
|
Do: gfx.paintXObject,
|
||||||
|
|
||||||
// Marked content
|
// Marked content
|
||||||
// Compatibility
|
// Compatibility
|
||||||
};
|
};
|
||||||
@ -1064,11 +1074,10 @@ var Interpreter = (function() {
|
|||||||
if (IsCmd(obj)) {
|
if (IsCmd(obj)) {
|
||||||
var cmd = obj.cmd;
|
var cmd = obj.cmd;
|
||||||
var fn = map[cmd];
|
var fn = map[cmd];
|
||||||
if (fn) {
|
if (fn)
|
||||||
if (fn.length != args.length)
|
// TODO figure out how to type-check vararg functions
|
||||||
this.error("Invalid number of arguments '" + cmd + "'");
|
|
||||||
fn.apply(gfx, args);
|
fn.apply(gfx, args);
|
||||||
} else
|
else
|
||||||
this.error("Unknown command '" + cmd + "'");
|
this.error("Unknown command '" + cmd + "'");
|
||||||
args.length = 0;
|
args.length = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -1116,6 +1125,12 @@ var EchoGraphics = (function() {
|
|||||||
setDash: function(dashArray, dashPhase) {
|
setDash: function(dashArray, dashPhase) {
|
||||||
this.printdentln(""+ dashArray +" "+ dashPhase +" d");
|
this.printdentln(""+ dashArray +" "+ dashPhase +" d");
|
||||||
},
|
},
|
||||||
|
setRenderingIntent: function(intent) {
|
||||||
|
this.printdentln("/"+ intent.name + " ri");
|
||||||
|
},
|
||||||
|
setFlatness: function(flatness) {
|
||||||
|
this.printdentln(""+ flatness +" i");
|
||||||
|
},
|
||||||
save: function() {
|
save: function() {
|
||||||
this.printdentln("q");
|
this.printdentln("q");
|
||||||
},
|
},
|
||||||
@ -1157,6 +1172,9 @@ var EchoGraphics = (function() {
|
|||||||
closeFillStroke: function() {
|
closeFillStroke: function() {
|
||||||
this.printdentln("b");
|
this.printdentln("b");
|
||||||
},
|
},
|
||||||
|
endPath: function() {
|
||||||
|
this.printdentln("n");
|
||||||
|
},
|
||||||
|
|
||||||
// Clipping
|
// Clipping
|
||||||
|
|
||||||
@ -1175,6 +1193,10 @@ var EchoGraphics = (function() {
|
|||||||
moveText: function (x, y) {
|
moveText: function (x, y) {
|
||||||
this.printdentln(""+ x +" "+ y +" Td");
|
this.printdentln(""+ x +" "+ y +" Td");
|
||||||
},
|
},
|
||||||
|
setTextMatrix: function(a, b, c, d, e, f) {
|
||||||
|
this.printdentln(""+ a +" "+ b +" "+ c +
|
||||||
|
" "+d +" "+ e +" "+ f + " Tm");
|
||||||
|
},
|
||||||
showText: function(text) {
|
showText: function(text) {
|
||||||
this.printdentln("( "+ text +" ) Tj");
|
this.printdentln("( "+ text +" ) Tj");
|
||||||
},
|
},
|
||||||
@ -1185,6 +1207,24 @@ var EchoGraphics = (function() {
|
|||||||
// Type3 fonts
|
// Type3 fonts
|
||||||
|
|
||||||
// Color
|
// Color
|
||||||
|
setStrokeColorSpace: function(space) {
|
||||||
|
this.printdentln("/"+ space.name +" CS");
|
||||||
|
},
|
||||||
|
setFillColorSpace: function(space) {
|
||||||
|
this.printdentln("/"+ space.name +" cs");
|
||||||
|
},
|
||||||
|
setStrokeColor: function(/*...*/) {
|
||||||
|
this.printdent("");
|
||||||
|
for (var i = 0; i < arguments.length; ++i)
|
||||||
|
this.print(""+ arguments[i] +" ");
|
||||||
|
this.printdentln("SC");
|
||||||
|
},
|
||||||
|
setFillColor: function(/*...*/) {
|
||||||
|
this.printdent("");
|
||||||
|
for (var i = 0; i < arguments.length; ++i)
|
||||||
|
this.print(""+ arguments[i] +" ");
|
||||||
|
this.printdentln("sc");
|
||||||
|
},
|
||||||
setFillGray: function(gray) {
|
setFillGray: function(gray) {
|
||||||
this.printdentln(""+ gray +" g");
|
this.printdentln(""+ gray +" g");
|
||||||
},
|
},
|
||||||
@ -1198,6 +1238,10 @@ var EchoGraphics = (function() {
|
|||||||
// Shading
|
// Shading
|
||||||
// Images
|
// Images
|
||||||
// XObjects
|
// XObjects
|
||||||
|
paintXObject: function(obj) {
|
||||||
|
this.printdentln("/"+ obj.name +" Do");
|
||||||
|
},
|
||||||
|
|
||||||
// Marked content
|
// Marked content
|
||||||
// Compatibility
|
// Compatibility
|
||||||
|
|
||||||
@ -1209,9 +1253,13 @@ var EchoGraphics = (function() {
|
|||||||
this.print(str);
|
this.print(str);
|
||||||
this.out += "\n";
|
this.out += "\n";
|
||||||
},
|
},
|
||||||
printdentln: function(str) {
|
printdent: function(str) {
|
||||||
this.print(this.indentationStr);
|
this.print(this.indentationStr);
|
||||||
this.println(str);
|
this.print(str);
|
||||||
|
},
|
||||||
|
printdentln: function(str) {
|
||||||
|
this.printdent(str);
|
||||||
|
this.println("");
|
||||||
},
|
},
|
||||||
indent: function() {
|
indent: function() {
|
||||||
this.indentation += 2;
|
this.indentation += 2;
|
||||||
@ -1277,6 +1325,12 @@ var CanvasGraphics = (function() {
|
|||||||
setDash: function(dashArray, dashPhase) {
|
setDash: function(dashArray, dashPhase) {
|
||||||
// TODO
|
// TODO
|
||||||
},
|
},
|
||||||
|
setRenderingIntent: function(intent) {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
|
setFlatness: function(flatness) {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
save: function() {
|
save: function() {
|
||||||
this.ctx.save();
|
this.ctx.save();
|
||||||
this.stateStack.push(this.current);
|
this.stateStack.push(this.current);
|
||||||
@ -1322,6 +1376,9 @@ var CanvasGraphics = (function() {
|
|||||||
closeFillStroke: function() {
|
closeFillStroke: function() {
|
||||||
return this.fillStroke();
|
return this.fillStroke();
|
||||||
},
|
},
|
||||||
|
endPath: function() {
|
||||||
|
this.consumePath();
|
||||||
|
},
|
||||||
|
|
||||||
// Clipping
|
// Clipping
|
||||||
|
|
||||||
@ -1339,10 +1396,13 @@ var CanvasGraphics = (function() {
|
|||||||
moveText: function (x, y) {
|
moveText: function (x, y) {
|
||||||
this.current.lineX += x;
|
this.current.lineX += x;
|
||||||
this.current.lineY += y;
|
this.current.lineY += y;
|
||||||
// XXX transform
|
// TODO transform
|
||||||
this.current.curX = this.current.lineX;
|
this.current.curX = this.current.lineX;
|
||||||
this.current.curY = this.current.lineY;
|
this.current.curY = this.current.lineY;
|
||||||
},
|
},
|
||||||
|
setTextMatrix: function(a, b, c, d, e, f) {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
showText: function(text) {
|
showText: function(text) {
|
||||||
this.ctx.save();
|
this.ctx.save();
|
||||||
this.ctx.translate(0, 2 * this.current.curY);
|
this.ctx.translate(0, 2 * this.current.curY);
|
||||||
@ -1369,6 +1429,18 @@ var CanvasGraphics = (function() {
|
|||||||
// Type3 fonts
|
// Type3 fonts
|
||||||
|
|
||||||
// Color
|
// Color
|
||||||
|
setStrokeColorSpace: function(space) {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
|
setFillColorSpace: function(space) {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
|
setStrokeColor: function(/*...*/) {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
|
setFillColor: function(/*...*/) {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
setFillGray: function(gray) {
|
setFillGray: function(gray) {
|
||||||
this.setFillRGBColor(gray, gray, gray);
|
this.setFillRGBColor(gray, gray, gray);
|
||||||
},
|
},
|
||||||
@ -1379,6 +1451,12 @@ var CanvasGraphics = (function() {
|
|||||||
this.ctx.fillStyle = this.makeCssRgb(r, g, b);
|
this.ctx.fillStyle = this.makeCssRgb(r, g, b);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// XObjects
|
||||||
|
paintXObject: function(obj) {
|
||||||
|
// TODO
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
|
|
||||||
consumePath: function() {
|
consumePath: function() {
|
||||||
@ -1499,6 +1577,13 @@ var tests = [
|
|||||||
int(-72), int(0), cmd("l"),
|
int(-72), int(0), cmd("l"),
|
||||||
int(4), cmd("w"),
|
int(4), cmd("w"),
|
||||||
cmd("h"), cmd("S"),
|
cmd("h"), cmd("S"),
|
||||||
|
int(100), int(72), cmd("m"),
|
||||||
|
int(172), int(0), cmd("l"),
|
||||||
|
int(100), int(-72), cmd("l"),
|
||||||
|
int(-172), int(0), cmd("l"),
|
||||||
|
int(4), cmd("w"),
|
||||||
|
cmd("n"),
|
||||||
|
cmd("S"),
|
||||||
eof()
|
eof()
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -1579,6 +1664,21 @@ var tests = [
|
|||||||
eof()
|
eof()
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{ name: "NYI", // check that NYI commands are no-ops
|
||||||
|
res: { },
|
||||||
|
mediaBox: [ 0, 0, 612, 792 ],
|
||||||
|
objs: [
|
||||||
|
name("Perceptual"), cmd("ri"),
|
||||||
|
int(2), cmd("i"),
|
||||||
|
int(1), int(0), int(0), int(1), int(80), int(80), cmd("Tm"),
|
||||||
|
name("DeviceRGB"), cmd("CS"),
|
||||||
|
name("DeviceGray"), cmd("cs"),
|
||||||
|
int(1), int(0), int(0), cmd("SC"),
|
||||||
|
int(1), cmd("sc"),
|
||||||
|
name("object"), cmd("Do"),
|
||||||
|
eof()
|
||||||
|
],
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user