PDF --> PDFJS, global wrapper named
This commit is contained in:
		
							parent
							
								
									135af5df13
								
							
						
					
					
						commit
						1d4e3025b6
					
				@ -7,11 +7,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
'use strict';
 | 
					'use strict';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
PDF.getPdf('helloworld.pdf', function getPdfHelloWorld(data) {
 | 
					PDFJS.getPdf('helloworld.pdf', function getPdfHelloWorld(data) {
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  // Instantiate PDFDoc with PDF data
 | 
					  // Instantiate PDFDoc with PDF data
 | 
				
			||||||
  //
 | 
					  //
 | 
				
			||||||
  var pdf = new PDF.PDFDoc(data);
 | 
					  var pdf = new PDFJS.PDFDoc(data);
 | 
				
			||||||
  var page = pdf.getPage(1);
 | 
					  var page = pdf.getPage(1);
 | 
				
			||||||
  var scale = 1.5;
 | 
					  var scale = 1.5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										10
									
								
								src/core.js
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/core.js
									
									
									
									
									
								
							@ -9,11 +9,11 @@ var ERRORS = 0, WARNINGS = 1, TODOS = 5;
 | 
				
			|||||||
var verbosity = WARNINGS;
 | 
					var verbosity = WARNINGS;
 | 
				
			||||||
var useWorker = false;
 | 
					var useWorker = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// The global PDF object exposes the API
 | 
					// The global PDFJS object exposes the API
 | 
				
			||||||
// In production, it will be declared outside a global wrapper
 | 
					// In production, it will be declared outside a global wrapper
 | 
				
			||||||
// In development, it will be declared here
 | 
					// In development, it will be declared here
 | 
				
			||||||
if (!globalScope.PDF) {
 | 
					if (!globalScope.PDFJS) {
 | 
				
			||||||
  globalScope.PDF = {};
 | 
					  globalScope.PDFJS = {};
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// getPdf()
 | 
					// getPdf()
 | 
				
			||||||
@ -49,7 +49,7 @@ function getPdf(arg, callback) {
 | 
				
			|||||||
  };
 | 
					  };
 | 
				
			||||||
  xhr.send(null);
 | 
					  xhr.send(null);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
globalScope.PDF.getPdf = getPdf;
 | 
					globalScope.PDFJS.getPdf = getPdf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var Page = (function pagePage() {
 | 
					var Page = (function pagePage() {
 | 
				
			||||||
  function constructor(xref, pageNumber, pageDict, ref) {
 | 
					  function constructor(xref, pageNumber, pageDict, ref) {
 | 
				
			||||||
@ -608,4 +608,4 @@ var PDFDoc = (function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  return constructor;
 | 
					  return constructor;
 | 
				
			||||||
})();
 | 
					})();
 | 
				
			||||||
globalScope.PDF.PDFDoc = PDFDoc;
 | 
					globalScope.PDFJS.PDFDoc = PDFDoc;
 | 
				
			||||||
 | 
				
			|||||||
@ -1,9 +1,9 @@
 | 
				
			|||||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 | 
					/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 | 
				
			||||||
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 | 
					/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var PDF = {};
 | 
					var PDFJS = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
(function() {
 | 
					(function pdfjsWrapper() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Use strict in our context only - users might not want it
 | 
					  // Use strict in our context only - users might not want it
 | 
				
			||||||
  'use strict';
 | 
					  'use strict';
 | 
				
			||||||
 | 
				
			|||||||
@ -82,7 +82,7 @@ function nextTask() {
 | 
				
			|||||||
  getPdf(task.file, function nextTaskGetPdf(data) {
 | 
					  getPdf(task.file, function nextTaskGetPdf(data) {
 | 
				
			||||||
    var failure;
 | 
					    var failure;
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      task.pdfDoc = new PDFDoc(data);
 | 
					      task.pdfDoc = new PDFJS.PDFDoc(data);
 | 
				
			||||||
    } catch (e) {
 | 
					    } catch (e) {
 | 
				
			||||||
      failure = 'load PDF doc : ' + e.toString();
 | 
					      failure = 'load PDF doc : ' + e.toString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -122,7 +122,7 @@ var PDFView = {
 | 
				
			|||||||
    document.title = this.url = url;
 | 
					    document.title = this.url = url;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var self = this;
 | 
					    var self = this;
 | 
				
			||||||
    PDF.getPdf(
 | 
					    PDFJS.getPdf(
 | 
				
			||||||
      {
 | 
					      {
 | 
				
			||||||
        url: url,
 | 
					        url: url,
 | 
				
			||||||
        progress: function getPdfProgress(evt) {
 | 
					        progress: function getPdfProgress(evt) {
 | 
				
			||||||
@ -209,7 +209,7 @@ var PDFView = {
 | 
				
			|||||||
    while (container.hasChildNodes())
 | 
					    while (container.hasChildNodes())
 | 
				
			||||||
      container.removeChild(container.lastChild);
 | 
					      container.removeChild(container.lastChild);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var pdf = new PDF.PDFDoc(data);
 | 
					    var pdf = new PDFJS.PDFDoc(data);
 | 
				
			||||||
    var pagesCount = pdf.numPages;
 | 
					    var pagesCount = pdf.numPages;
 | 
				
			||||||
    document.getElementById('numPages').innerHTML = pagesCount;
 | 
					    document.getElementById('numPages').innerHTML = pagesCount;
 | 
				
			||||||
    document.getElementById('pageNumber').max = pagesCount;
 | 
					    document.getElementById('pageNumber').max = pagesCount;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user