]> git.parisson.com Git - pdf.js.git/commitdiff
Use data directly in PDFDoc.
authorKalervo Kujala <kkujala@>
Mon, 26 Sep 2011 17:58:18 +0000 (20:58 +0300)
committerKalervo Kujala <kkujala@>
Mon, 26 Sep 2011 17:58:18 +0000 (20:58 +0300)
And create the Stream inside the PDFDoc constructor for a cleaner interface.
Also encapsulate unnecessary details from the user.

pdf.js
test/driver.js
web/viewer.js
worker/pdf.js

diff --git a/pdf.js b/pdf.js
index b58cbbc03a13c5bc71f7e14ef382823b61bf5224..449fd9c16f858e29b69517d51efadb10c4eb8aa0 100644 (file)
--- a/pdf.js
+++ b/pdf.js
@@ -3800,7 +3800,8 @@ var Catalog = (function catalogCatalog() {
 })();
 
 var PDFDoc = (function pdfDoc() {
-  function constructor(stream) {
+  function constructor(data) {
+    var stream = new Stream(data);
     assertWellFormed(stream.length > 0, 'stream must have data');
     this.stream = stream;
     this.setup();
index 8f873fc4619ee19cea011ef9de523b80e830d417..144b97589eeb199563fb081cd0b033a934d2c94a 100644 (file)
@@ -83,7 +83,7 @@ function nextTask() {
         r.responseArrayBuffer || r.response;
 
       try {
-        task.pdfDoc = new PDFDoc(new Stream(data));
+        task.pdfDoc = new PDFDoc(data);
       } catch (e) {
         failure = 'load PDF doc : ' + e.toString();
       }
index 89d83fe6bec6d58bd0628700c28833caad2a861d..482ac95e09c11007b8dca4dd8e92f4c2c9e6d31b 100644 (file)
@@ -159,7 +159,7 @@ var PDFView = {
     while (container.hasChildNodes())
       container.removeChild(container.lastChild);
 
-    var pdf = new PDFDoc(new Stream(data));
+    var pdf = new PDFDoc(data);
     var pagesCount = pdf.numPages;
     document.getElementById('numPages').innerHTML = pagesCount;
 
index f205547abecfc1401fc52bb829f5ece1f40e85ec..aee0e374d825a83e8fd562bec1deb5d32d864572 100644 (file)
@@ -48,7 +48,7 @@ addEventListener('message', function(event) {
   var data = event.data;
   // If there is no pdfDocument yet, then the sent data is the PDFDocument.
   if (!pdfDocument) {
-    pdfDocument = new PDFDoc(new Stream(data));
+    pdfDocument = new PDFDoc(data);
     postMessage({
       action: 'pdf_num_pages',
       data: pdfDocument.numPages