Dumb text WIP, more UI for test.html
This commit is contained in:
parent
d2c96d420a
commit
198a3f1a1b
24
pdf.js
24
pdf.js
@ -817,8 +817,8 @@ var EchoGraphics = (function() {
|
|||||||
this.dedent();
|
this.dedent();
|
||||||
this.printdentln("ET");
|
this.printdentln("ET");
|
||||||
},
|
},
|
||||||
setFont: function(font, sizePt) {
|
setFont: function(font, size) {
|
||||||
this.printdentln("/"+ font +" "+ sizePt +" Tf");
|
this.printdentln("/"+ font +" "+ size +" Tf");
|
||||||
},
|
},
|
||||||
moveText: function (x, y) {
|
moveText: function (x, y) {
|
||||||
this.printdentln(""+ x +" "+ y +" Td");
|
this.printdentln(""+ x +" "+ y +" Td");
|
||||||
@ -963,7 +963,25 @@ var CanvasGraphics = (function() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Clipping
|
// Clipping
|
||||||
|
|
||||||
// Text
|
// Text
|
||||||
|
beginText: function() {
|
||||||
|
|
||||||
|
},
|
||||||
|
endText: function() {
|
||||||
|
|
||||||
|
},
|
||||||
|
setFont: function(font, size) {
|
||||||
|
// NYI
|
||||||
|
this.ctx.font = size +'px Helvetica';
|
||||||
|
},
|
||||||
|
moveText: function (x, y) {
|
||||||
|
this.moveTo(x, y);
|
||||||
|
},
|
||||||
|
showText: function(text) {
|
||||||
|
this.ctx.fillText(text, 100, 100);
|
||||||
|
},
|
||||||
|
|
||||||
// Type3 fonts
|
// Type3 fonts
|
||||||
|
|
||||||
// Color
|
// Color
|
||||||
@ -1001,7 +1019,7 @@ try {
|
|||||||
|
|
||||||
var MockParser = (function() {
|
var MockParser = (function() {
|
||||||
function constructor(objs) {
|
function constructor(objs) {
|
||||||
this.objs = objs;
|
this.objs = objs.slice(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor.prototype = {
|
constructor.prototype = {
|
||||||
|
31
test.html
31
test.html
@ -13,27 +13,44 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script type="application/javascript;version=1.8">
|
<script type="application/javascript;version=1.8">
|
||||||
var canvas;
|
var canvas, numPages, pageDisplay, pageNum;
|
||||||
function load() {
|
function load() {
|
||||||
canvas = document.getElementById("canvas");
|
canvas = document.getElementById("canvas");
|
||||||
displayPage();
|
pageDisplay = document.getElementById("pageNumber");
|
||||||
|
numPages = tests.length;
|
||||||
|
displayPage(pageNum = 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayPage() {
|
function displayPage(number) {
|
||||||
var page = tests[1].objs;
|
var page = tests[number].objs;
|
||||||
|
pageDisplay.value = number;
|
||||||
|
|
||||||
var gfx = new CanvasGraphics(canvas.getContext("2d"), 96.0, 96.0, null);
|
var ctx = canvas.getContext("2d");
|
||||||
|
ctx.save();
|
||||||
|
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||||
|
var gfx = new CanvasGraphics(ctx, 96.0, 96.0, null);
|
||||||
var interp = new Interpreter(null, null, null, gfx);
|
var interp = new Interpreter(null, null, null, gfx);
|
||||||
interp.interpretHelper(new MockParser(page));
|
interp.interpretHelper(new MockParser(page));
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextPage() {
|
||||||
|
pageNum = (pageNum + 1) % numPages;
|
||||||
|
displayPage(pageNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
function prevPage() {
|
||||||
|
pageNum = (pageNum - 1 + numPages) % numPages;
|
||||||
|
displayPage(pageNum);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onload="load();">
|
<body onload="load();">
|
||||||
<div>
|
<div>
|
||||||
<button>Previous</button>
|
<button onclick="prevPage();">Previous</button>
|
||||||
<input type="text" id="pageNumber" value="0"></input>
|
<input type="text" id="pageNumber" value="0"></input>
|
||||||
<button>Next</button>
|
<button onclick="nextPage();">Next</button>
|
||||||
<div id="viewer">
|
<div id="viewer">
|
||||||
<!-- Canvas dimensions must be specified in CSS pixels. CSS pixels
|
<!-- Canvas dimensions must be specified in CSS pixels. CSS pixels
|
||||||
-- are always 96 dpi. These dimensions are 8.5x11in at 96dpi. -->
|
-- are always 96 dpi. These dimensions are 8.5x11in at 96dpi. -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user