Browse Source

Use data directly in PDFDoc.

And create the Stream inside the PDFDoc constructor for a cleaner interface.
Also encapsulate unnecessary details from the user.
Kalervo Kujala 14 years ago
parent
commit
2094c29169
  1. 3
      pdf.js
  2. 2
      test/driver.js
  3. 2
      web/viewer.js
  4. 2
      worker/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();

2
test/driver.js

@ -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();
} }

2
web/viewer.js

@ -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;

2
worker/pdf.js

@ -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…
Cancel
Save