<script type="text/javascript" src="/fonts.js"></script>
<script type="text/javascript" src="/glyphlist.js"></script>
<script type="application/javascript">
-var browser, canvas, currentTask, currentTaskIdx, failure, manifest, pdfDoc, stdout;
+var browser, canvas, currentTask, currentTaskIdx, failure, manifest, numPages, pdfDoc, stdout;
function queryParams() {
var qs = window.location.search.substring(1);
try {
pdfDoc = new PDFDoc(new Stream(data));
+ numPages = pdfDoc.numPages;
} catch(e) {
- pdfDoc.numPages = 1;
+ numPages = 1;
failure = 'load PDF doc: '+ e.toString();
}
}
function nextPage() {
- if (currentTask.pageNum > pdfDoc.numPages) {
+ if (currentTask.pageNum > numPages) {
if (++currentTask.round < currentTask.rounds) {
log(" Round "+ (1 + currentTask.round) +"\n");
currentTask.pageNum = 1;
clear(ctx);
var fonts = [];
- var gfx = new CanvasGraphics(ctx);
+ var gfx = null;
try {
+ gfx = new CanvasGraphics(ctx);
currentPage = pdfDoc.getPage(currentTask.pageNum);
currentPage.compile(gfx, fonts);
} catch(e) {
var fontLoaderTimer = null;
function checkFontsLoaded() {
- if (!FontLoader.bind(fonts)) {
- fontLoaderTimer = window.setTimeout(checkFontsLoaded, 10);
- return;
+ try {
+ if (!FontLoader.bind(fonts)) {
+ fontLoaderTimer = window.setTimeout(checkFontsLoaded, 10);
+ return;
+ }
+ } catch(e) {
+ failure = 'fonts: '+ e.toString();
}
snapshotCurrentPage(gfx);
}
function sendTaskResult(snapshot) {
var result = { browser: browser,
id: currentTask.id,
- numPages: pdfDoc.numPages,
+ numPages: numPages,
failure: failure,
file: currentTask.file,
round: currentTask.round,