Merge pull request #532 from kkujala/master

Use data directly in PDFDoc.
This commit is contained in:
vingtetun 2011-09-26 11:14:11 -07:00
commit 65cad1caf8
4 changed files with 5 additions and 4 deletions

3
pdf.js
View File

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

View File

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

View File

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

View File

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