Merge pull request #532 from kkujala/master
Use data directly in PDFDoc.
This commit is contained in:
commit
65cad1caf8
3
pdf.js
3
pdf.js
@ -3800,7 +3800,8 @@ var Catalog = (function catalogCatalog() {
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
var PDFDoc = (function pdfDoc() {
|
var PDFDoc = (function pdfDoc() {
|
||||||
function constructor(stream) {
|
function constructor(data) {
|
||||||
|
var stream = new Stream(data);
|
||||||
assertWellFormed(stream.length > 0, 'stream must have data');
|
assertWellFormed(stream.length > 0, 'stream must have data');
|
||||||
this.stream = stream;
|
this.stream = stream;
|
||||||
this.setup();
|
this.setup();
|
||||||
|
@ -83,7 +83,7 @@ function nextTask() {
|
|||||||
r.responseArrayBuffer || r.response;
|
r.responseArrayBuffer || r.response;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
task.pdfDoc = new PDFDoc(new Stream(data));
|
task.pdfDoc = new PDFDoc(data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
failure = 'load PDF doc : ' + e.toString();
|
failure = 'load PDF doc : ' + e.toString();
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ var PDFView = {
|
|||||||
while (container.hasChildNodes())
|
while (container.hasChildNodes())
|
||||||
container.removeChild(container.lastChild);
|
container.removeChild(container.lastChild);
|
||||||
|
|
||||||
var pdf = new PDFDoc(new Stream(data));
|
var pdf = new PDFDoc(data);
|
||||||
var pagesCount = pdf.numPages;
|
var pagesCount = pdf.numPages;
|
||||||
document.getElementById('numPages').innerHTML = pagesCount;
|
document.getElementById('numPages').innerHTML = pagesCount;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ addEventListener('message', function(event) {
|
|||||||
var data = event.data;
|
var data = event.data;
|
||||||
// If there is no pdfDocument yet, then the sent data is the PDFDocument.
|
// If there is no pdfDocument yet, then the sent data is the PDFDocument.
|
||||||
if (!pdfDocument) {
|
if (!pdfDocument) {
|
||||||
pdfDocument = new PDFDoc(new Stream(data));
|
pdfDocument = new PDFDoc(data);
|
||||||
postMessage({
|
postMessage({
|
||||||
action: 'pdf_num_pages',
|
action: 'pdf_num_pages',
|
||||||
data: pdfDocument.numPages
|
data: pdfDocument.numPages
|
||||||
|
Loading…
Reference in New Issue
Block a user