mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge branch 'master' of https://github.com/andreasgal/pdf.js.git into invalidpdf-1
Conflicts: test/test_manifest.json
This commit is contained in:
commit
39ba5324a7
7 changed files with 260 additions and 58 deletions
|
@ -39,7 +39,7 @@ function load() {
|
|||
|
||||
var r = new XMLHttpRequest();
|
||||
r.open('GET', manifestFile, false);
|
||||
r.onreadystatechange = function(e) {
|
||||
r.onreadystatechange = function loadOnreadystatechange(e) {
|
||||
if (r.readyState == 4) {
|
||||
log('done\n');
|
||||
manifest = JSON.parse(r.responseText);
|
||||
|
@ -50,7 +50,21 @@ function load() {
|
|||
r.send(null);
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
var styleSheet = document.styleSheets[0];
|
||||
if (styleSheet) {
|
||||
while (styleSheet.cssRules.length > 0)
|
||||
styleSheet.deleteRule(0);
|
||||
}
|
||||
var guard = document.getElementById('content-end');
|
||||
var body = document.body;
|
||||
while (body.lastChild !== guard)
|
||||
body.removeChild(body.lastChild);
|
||||
}
|
||||
|
||||
function nextTask() {
|
||||
cleanup();
|
||||
|
||||
if (currentTaskIdx == manifest.length) {
|
||||
return done();
|
||||
}
|
||||
|
@ -62,7 +76,7 @@ function nextTask() {
|
|||
var r = new XMLHttpRequest();
|
||||
r.open('GET', task.file);
|
||||
r.mozResponseType = r.responseType = 'arraybuffer';
|
||||
r.onreadystatechange = function() {
|
||||
r.onreadystatechange = function nextTaskOnreadystatechange() {
|
||||
var failure;
|
||||
if (r.readyState == 4) {
|
||||
var data = r.mozResponseArrayBuffer || r.mozResponse ||
|
||||
|
@ -85,11 +99,15 @@ function isLastPage(task) {
|
|||
return (task.pageNum > task.pdfDoc.numPages);
|
||||
}
|
||||
|
||||
function canvasToDataURL() {
|
||||
return canvas.toDataURL('image/png');
|
||||
}
|
||||
|
||||
function nextPage(task, loadError) {
|
||||
var failure = loadError || '';
|
||||
|
||||
if (!task.pdfDoc) {
|
||||
sendTaskResult(canvas.toDataURL('image/png'), task, failure);
|
||||
sendTaskResult(canvasToDataURL(), task, failure);
|
||||
log('done' + (failure ? ' (failed !: ' + failure + ')' : '') + '\n');
|
||||
++currentTaskIdx;
|
||||
nextTask();
|
||||
|
@ -133,7 +151,7 @@ function nextPage(task, loadError) {
|
|||
|
||||
page.startRendering(
|
||||
ctx,
|
||||
function(e) {
|
||||
function nextPageStartRendering(e) {
|
||||
snapshotCurrentPage(task, (!failure && e) ?
|
||||
('render : ' + e) : failure);
|
||||
}
|
||||
|
@ -153,13 +171,13 @@ function nextPage(task, loadError) {
|
|||
function snapshotCurrentPage(task, failure) {
|
||||
log('done, snapshotting... ');
|
||||
|
||||
sendTaskResult(canvas.toDataURL('image/png'), task, failure);
|
||||
sendTaskResult(canvasToDataURL(), task, failure);
|
||||
log('done' + (failure ? ' (failed !: ' + failure + ')' : '') + '\n');
|
||||
|
||||
// Set up the next request
|
||||
var backoff = (inFlightRequests > 0) ? inFlightRequests * 10 : 0;
|
||||
setTimeout(
|
||||
function() {
|
||||
function snapshotCurrentPageSetTimeout() {
|
||||
++task.pageNum;
|
||||
nextPage(task);
|
||||
},
|
||||
|
@ -208,7 +226,7 @@ function sendTaskResult(snapshot, task, failure) {
|
|||
// (The POST URI is ignored atm.)
|
||||
r.open('POST', '/submit_task_results', true);
|
||||
r.setRequestHeader('Content-Type', 'application/json');
|
||||
r.onreadystatechange = function(e) {
|
||||
r.onreadystatechange = function sendTaskResultOnreadystatechange(e) {
|
||||
if (r.readyState == 4) {
|
||||
inFlightRequests--;
|
||||
}
|
||||
|
|
105
test/pdfs/extgstate.pdf
Normal file
105
test/pdfs/extgstate.pdf
Normal file
|
@ -0,0 +1,105 @@
|
|||
%PDF-1.4
|
||||
%öäüß
|
||||
1 0 obj
|
||||
<<
|
||||
/Type /Catalog
|
||||
/Version /1.4
|
||||
/Pages 2 0 R
|
||||
>>
|
||||
endobj
|
||||
2 0 obj
|
||||
<<
|
||||
/Type /Pages
|
||||
/Kids [3 0 R]
|
||||
/Count 1
|
||||
>>
|
||||
endobj
|
||||
3 0 obj
|
||||
<<
|
||||
/Type /Page
|
||||
/MediaBox [0 0 612 792]
|
||||
/Resources 4 0 R
|
||||
/Parent 2 0 R
|
||||
/Contents 5 0 R
|
||||
>>
|
||||
endobj
|
||||
4 0 obj
|
||||
<<
|
||||
/ExtGState 6 0 R
|
||||
/Font 7 0 R
|
||||
/XObject <<
|
||||
>>
|
||||
>>
|
||||
endobj
|
||||
5 0 obj
|
||||
<<
|
||||
/Length 8 0 R
|
||||
>>
|
||||
stream
|
||||
/GS1 gs
|
||||
/F0 12 Tf
|
||||
BT
|
||||
100 700 Td
|
||||
(I should be courier!) Tj
|
||||
ET
|
||||
50 600 m
|
||||
400 600 l
|
||||
S
|
||||
|
||||
endstream
|
||||
endobj
|
||||
6 0 obj
|
||||
<<
|
||||
/GS1 9 0 R
|
||||
>>
|
||||
endobj
|
||||
7 0 obj
|
||||
<<
|
||||
/F0 10 0 R
|
||||
>>
|
||||
endobj
|
||||
8 0 obj
|
||||
82
|
||||
endobj
|
||||
9 0 obj
|
||||
<<
|
||||
/Type /ExtGState
|
||||
/LW 10
|
||||
/LC 1
|
||||
/LJ 2
|
||||
/ML 0.3000000119
|
||||
/D [[0.0917000026 183.3300018311]
|
||||
0]
|
||||
/Font [10 0 R 36]
|
||||
>>
|
||||
endobj
|
||||
10 0 obj
|
||||
<<
|
||||
/Type /Font
|
||||
/Subtype /Type1
|
||||
/BaseFont /Courier
|
||||
/Encoding /WinAnsiEncoding
|
||||
>>
|
||||
endobj
|
||||
xref
|
||||
0 11
|
||||
0000000000 65535 f
|
||||
0000000015 00000 n
|
||||
0000000078 00000 n
|
||||
0000000135 00000 n
|
||||
0000000239 00000 n
|
||||
0000000304 00000 n
|
||||
0000000441 00000 n
|
||||
0000000473 00000 n
|
||||
0000000505 00000 n
|
||||
0000000523 00000 n
|
||||
0000000653 00000 n
|
||||
trailer
|
||||
<<
|
||||
/Root 1 0 R
|
||||
/ID [<BFFF29B7D1C75EC69AC080682C2AFC5B> <BFFF29B7D1C75EC69AC080682C2AFC5B>]
|
||||
/Size 11
|
||||
>>
|
||||
startxref
|
||||
749
|
||||
%%EOF
|
|
@ -152,6 +152,12 @@
|
|||
"rounds": 1,
|
||||
"type": "load"
|
||||
},
|
||||
{ "id": "extgstate",
|
||||
"file": "pdfs/extgstate.pdf",
|
||||
"link": false,
|
||||
"rounds": 1,
|
||||
"type": "load"
|
||||
},
|
||||
{ "id": "ibwa-bad",
|
||||
"file": "pdfs/ibwa-bad.pdf",
|
||||
"link": true,
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<body onload="load();">
|
||||
<pre style="width:800; height:800; overflow: scroll;"id="stdout"></pre>
|
||||
<p>Inflight requests: <span id="inFlightCount"></span></p>
|
||||
<div id="content-end"><!-- cleanup() guard --></div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue