Merge pull request #173 from cgjones/issue-169
fix another binary-mode issue
This commit is contained in:
commit
67baa86c60
1
pdf.js
1
pdf.js
@ -2971,6 +2971,7 @@ var Catalog = (function() {
|
||||
|
||||
var PDFDoc = (function() {
|
||||
function constructor(stream) {
|
||||
assertWellFormed(stream.length > 0, "stream must have data");
|
||||
this.stream = stream;
|
||||
this.setup();
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ class PDFTestHandler(BaseHTTPRequestHandler):
|
||||
self.send_header("Content-Type", MIMEs[ext])
|
||||
self.send_header("Content-Length", os.path.getsize(path))
|
||||
self.end_headers()
|
||||
with open(path) as f:
|
||||
with open(path, "rb") as f:
|
||||
self.wfile.write(f.read())
|
||||
|
||||
def do_GET(self):
|
||||
@ -275,7 +275,7 @@ def downloadLinkedPDFs(manifestList):
|
||||
sys.stdout.flush()
|
||||
response = urllib2.urlopen(link)
|
||||
|
||||
with open(f, 'w') as out:
|
||||
with open(f, 'wb') as out:
|
||||
out.write(response.read())
|
||||
|
||||
print 'done'
|
||||
|
@ -88,31 +88,35 @@ function nextPage() {
|
||||
}
|
||||
}
|
||||
|
||||
failure = '';
|
||||
log(" loading page "+ currentTask.pageNum +"... ");
|
||||
var ctx, fonts, gfx;
|
||||
if (!failure) {
|
||||
log(" loading page "+ currentTask.pageNum +"... ");
|
||||
|
||||
var ctx = canvas.getContext("2d");
|
||||
ctx = canvas.getContext("2d");
|
||||
|
||||
var fonts = [];
|
||||
var gfx = null;
|
||||
try {
|
||||
gfx = new CanvasGraphics(ctx);
|
||||
currentPage = pdfDoc.getPage(currentTask.pageNum);
|
||||
currentPage.compile(gfx, fonts);
|
||||
} catch(e) {
|
||||
failure = 'compile: '+ e.toString();
|
||||
fonts = [];
|
||||
gfx = null;
|
||||
try {
|
||||
gfx = new CanvasGraphics(ctx);
|
||||
currentPage = pdfDoc.getPage(currentTask.pageNum);
|
||||
currentPage.compile(gfx, fonts);
|
||||
} catch(e) {
|
||||
failure = 'compile: '+ e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
var pdfToCssUnitsCoef = 96.0 / 72.0;
|
||||
// using mediaBox for the canvas size
|
||||
var pageWidth = (currentPage.mediaBox[2] - currentPage.mediaBox[0]);
|
||||
var pageHeight = (currentPage.mediaBox[3] - currentPage.mediaBox[1]);
|
||||
canvas.width = pageWidth * pdfToCssUnitsCoef;
|
||||
canvas.height = pageHeight * pdfToCssUnitsCoef;
|
||||
clear(ctx);
|
||||
} catch(e) {
|
||||
failure = 'page setup: '+ e.toString();
|
||||
if (!failure) {
|
||||
try {
|
||||
var pdfToCssUnitsCoef = 96.0 / 72.0;
|
||||
// using mediaBox for the canvas size
|
||||
var pageWidth = (currentPage.mediaBox[2] - currentPage.mediaBox[0]);
|
||||
var pageHeight = (currentPage.mediaBox[3] - currentPage.mediaBox[1]);
|
||||
canvas.width = pageWidth * pdfToCssUnitsCoef;
|
||||
canvas.height = pageHeight * pdfToCssUnitsCoef;
|
||||
clear(ctx);
|
||||
} catch(e) {
|
||||
failure = 'page setup: '+ e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (!failure) {
|
||||
@ -145,6 +149,7 @@ function snapshotCurrentPage(gfx) {
|
||||
log("done"+ (failure ? " (failed!)" : "") +"\n");
|
||||
|
||||
// Set up the next request
|
||||
failure = '';
|
||||
backoff = (inFlightRequests > 0) ? inFlightRequests * 10 : 0;
|
||||
setTimeout(function() {
|
||||
++currentTask.pageNum, nextPage();
|
||||
|
Loading…
x
Reference in New Issue
Block a user