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.printdentln("ET");
|
||||
},
|
||||
setFont: function(font, sizePt) {
|
||||
this.printdentln("/"+ font +" "+ sizePt +" Tf");
|
||||
setFont: function(font, size) {
|
||||
this.printdentln("/"+ font +" "+ size +" Tf");
|
||||
},
|
||||
moveText: function (x, y) {
|
||||
this.printdentln(""+ x +" "+ y +" Td");
|
||||
@ -963,7 +963,25 @@ var CanvasGraphics = (function() {
|
||||
},
|
||||
|
||||
// Clipping
|
||||
|
||||
// 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
|
||||
|
||||
// Color
|
||||
@ -1001,7 +1019,7 @@ try {
|
||||
|
||||
var MockParser = (function() {
|
||||
function constructor(objs) {
|
||||
this.objs = objs;
|
||||
this.objs = objs.slice(0);
|
||||
}
|
||||
|
||||
constructor.prototype = {
|
||||
|
31
test.html
31
test.html
@ -13,27 +13,44 @@
|
||||
</style>
|
||||
|
||||
<script type="application/javascript;version=1.8">
|
||||
var canvas;
|
||||
var canvas, numPages, pageDisplay, pageNum;
|
||||
function load() {
|
||||
canvas = document.getElementById("canvas");
|
||||
displayPage();
|
||||
pageDisplay = document.getElementById("pageNumber");
|
||||
numPages = tests.length;
|
||||
displayPage(pageNum = 0);
|
||||
}
|
||||
|
||||
function displayPage() {
|
||||
var page = tests[1].objs;
|
||||
function displayPage(number) {
|
||||
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);
|
||||
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>
|
||||
</head>
|
||||
|
||||
<body onload="load();">
|
||||
<div>
|
||||
<button>Previous</button>
|
||||
<button onclick="prevPage();">Previous</button>
|
||||
<input type="text" id="pageNumber" value="0"></input>
|
||||
<button>Next</button>
|
||||
<button onclick="nextPage();">Next</button>
|
||||
<div id="viewer">
|
||||
<!-- Canvas dimensions must be specified in CSS pixels. CSS pixels
|
||||
-- are always 96 dpi. These dimensions are 8.5x11in at 96dpi. -->
|
||||
|
Loading…
Reference in New Issue
Block a user