Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/acroforms/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ function renderPage(div, pdf, pageNumber, callback) {

// In production, the bundled pdf.js shall be used instead of RequireJS.
require.config({paths: {'pdfjs': '../../src'}});
require(['pdfjs/display/api'], function (api) {
require(['pdfjs/display/api', 'pdfjs/display/global'], function (api, global) {
// In production, change this to point to the built `pdf.worker.js` file.
PDFJS.workerSrc = '../../src/worker_loader.js';
global.PDFJS.workerSrc = '../../src/worker_loader.js';

// Fetch the PDF document from the URL using promises.
api.getDocument(pdfWithFormsPath).then(function getPdfForm(pdf) {
Expand Down
4 changes: 2 additions & 2 deletions examples/helloworld/hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

// In production, the bundled pdf.js shall be used instead of RequireJS.
require.config({paths: {'pdfjs': '../../src'}});
require(['pdfjs/display/api'], function (api) {
require(['pdfjs/display/api', 'pdfjs/display/global'], function (api, global) {
// In production, change this to point to the built `pdf.worker.js` file.
PDFJS.workerSrc = '../../src/worker_loader.js';
global.PDFJS.workerSrc = '../../src/worker_loader.js';

// Fetch the PDF document from the URL using promises.
api.getDocument('helloworld.pdf').then(function (pdf) {
Expand Down
4 changes: 0 additions & 4 deletions examples/node/domstubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,6 @@ DOMElement.prototype = {
},
}

global.window = global;

global.navigator = { userAgent: 'node' };

global.document = {
childNodes : [],

Expand Down
4 changes: 2 additions & 2 deletions examples/node/getinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ var fs = require('fs');
global.DOMParser = require('./domparsermock.js').DOMParserMock;

// Run `gulp dist` to generate 'pdfjs-dist' npm package files.
require('../../build/dist');
var pdfjsLib = require('../../build/dist');

// Loading file from file system into typed array
var pdfPath = process.argv[2] || '../../web/compressed.tracemonkey-pldi-09.pdf';
var data = new Uint8Array(fs.readFileSync(pdfPath));

// Will be using promises to load document, pages and misc data instead of
// callback.
PDFJS.getDocument(data).then(function (doc) {
pdfjsLib.getDocument(data).then(function (doc) {
var numPages = doc.numPages;
console.log('# Document Loaded');
console.log('Number of Pages: ' + numPages);
Expand Down
6 changes: 3 additions & 3 deletions examples/node/pdf2svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var fs = require('fs');
require('./domstubs.js');

// Run `gulp dist` to generate 'pdfjs-dist' npm package files.
require('../../build/dist');
var pdfjsLib = require('../../build/dist');

// Loading file from file system into typed array
var pdfPath = process.argv[2] || '../../web/compressed.tracemonkey-pldi-09.pdf';
Expand Down Expand Up @@ -44,7 +44,7 @@ function getFileNameFromPath(path) {

// Will be using promises to load document, pages and misc data instead of
// callback.
PDFJS.getDocument(data).then(function (doc) {
pdfjsLib.getDocument(data).then(function (doc) {
var numPages = doc.numPages;
console.log('# Document Loaded');
console.log('Number of Pages: ' + numPages);
Expand All @@ -59,7 +59,7 @@ PDFJS.getDocument(data).then(function (doc) {
console.log();

return page.getOperatorList().then(function (opList) {
var svgGfx = new PDFJS.SVGGraphics(page.commonObjs, page.objs);
var svgGfx = new pdfjsLib.SVGGraphics(page.commonObjs, page.objs);
svgGfx.embedFonts = true;
return svgGfx.getSVG(opList, viewport).then(function (svg) {
var svgDump = svg.toString();
Expand Down
17 changes: 10 additions & 7 deletions examples/svgviewer/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var queryParams = query ? JSON.parse('{' + query.split('&').map(function (a) {
var url = queryParams.file || '../../test/pdfs/liveprogramming.pdf';
var scale = +queryParams.scale || 1.5;

function renderDocument(pdf) {
function renderDocument(pdf, svgLib) {
var numPages = pdf.numPages;
// Using promise to fetch the page

Expand Down Expand Up @@ -37,7 +37,7 @@ function renderDocument(pdf) {
anchor.appendChild(container);

return page.getOperatorList().then(function (opList) {
var svgGfx = new PDFJS.SVGGraphics(page.commonObjs, page.objs);
var svgGfx = new svgLib.SVGGraphics(page.commonObjs, page.objs);
return svgGfx.getSVG(opList, viewport).then(function (svg) {
container.appendChild(svg);
});
Expand All @@ -49,14 +49,17 @@ function renderDocument(pdf) {

// In production, the bundled pdf.js shall be used instead of RequireJS.
require.config({paths: {'pdfjs': '../../src'}});
require(['pdfjs/display/api', 'pdfjs/display/svg'], function (api, svg) {
require(['pdfjs/display/api', 'pdfjs/display/svg', 'pdfjs/display/global'],
function (api, svg, global) {
// In production, change this to point to the built `pdf.worker.js` file.
PDFJS.workerSrc = '../../src/worker_loader.js';
global.PDFJS.workerSrc = '../../src/worker_loader.js';

// In production, change this to point to where the cMaps are placed.
PDFJS.cMapUrl = '../../external/bcmaps/';
PDFJS.cMapPacked = true;
global.PDFJS.cMapUrl = '../../external/bcmaps/';
global.PDFJS.cMapPacked = true;

// Fetch the PDF document from the URL using promises.
api.getDocument(url).then(renderDocument);
api.getDocument(url).then(function (doc) {
renderDocument(doc, svg);
});
});
4 changes: 2 additions & 2 deletions examples/webpack/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

// Hello world example for webpack.

require('pdfjs-dist');
var pdfjsLib = require('pdfjs-dist');

var pdfPath = '../helloworld/helloworld.pdf';

// It is also possible to disable workers via `PDFJS.disableWorker = true`,
// however that might degrade the UI performance in web browsers.

// Loading a document.
var loadingTask = PDFJS.getDocument(pdfPath);
var loadingTask = pdfjsLib.getDocument(pdfPath);
loadingTask.promise.then(function (pdfDocument) {
// Request a first page
return pdfDocument.getPage(1).then(function (pdfPage) {
Expand Down
8 changes: 3 additions & 5 deletions make.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ target.jsdoc = function() {
var JSDOC_FILES = [
'src/doc_helper.js',
'src/display/api.js',
'src/display/global.js',
'src/shared/util.js',
'src/core/annotation.js'
];
Expand Down Expand Up @@ -526,9 +527,7 @@ target.bundle = function(args) {

var umd = require('./external/umdutils/verifier.js');
var MAIN_SRC_FILES = [
SRC_DIR + 'display/annotation_layer.js',
SRC_DIR + 'display/text_layer.js',
SRC_DIR + 'display/api.js'
SRC_DIR + 'display/global.js'
];

var WORKER_SRC_FILES = [
Expand All @@ -538,9 +537,8 @@ target.bundle = function(args) {
var mainFileName = 'pdf.js';
var workerFileName = 'pdf.worker.js';

// Extension does not need svg.js and network.js files.
// Extension does not need network.js file.
if (!defines.FIREFOX && !defines.MOZCENTRAL) {
MAIN_SRC_FILES.push(SRC_DIR + 'display/svg.js');
WORKER_SRC_FILES.push(SRC_DIR + 'core/network.js');
}

Expand Down
12 changes: 7 additions & 5 deletions src/display/annotation_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals PDFJS */

'use strict';

Expand All @@ -35,6 +34,7 @@ var addLinkAttributes = displayDOMUtils.addLinkAttributes;
var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
var warn = sharedUtil.warn;
var CustomStyle = displayDOMUtils.CustomStyle;
var getDefaultSetting = displayDOMUtils.getDefaultSetting;

/**
* @typedef {Object} AnnotationElementParameters
Expand Down Expand Up @@ -107,6 +107,7 @@ var AnnotationElement = (function AnnotationElementClosure() {
this.viewport = parameters.viewport;
this.linkService = parameters.linkService;
this.downloadManager = parameters.downloadManager;
this.imageResourcesPath = parameters.imageResourcesPath;

if (isRenderable) {
this.container = this._createContainer();
Expand Down Expand Up @@ -363,7 +364,7 @@ var TextAnnotationElement = (function TextAnnotationElementClosure() {
var image = document.createElement('img');
image.style.height = this.container.style.height;
image.style.width = this.container.style.width;
image.src = PDFJS.imageResourcesPath + 'annotation-' +
image.src = this.imageResourcesPath + 'annotation-' +
this.data.name.toLowerCase() + '.svg';
image.alt = '[{{type}} Annotation]';
image.dataset.l10nId = 'text_annotation_type';
Expand Down Expand Up @@ -838,6 +839,7 @@ var FileAttachmentAnnotationElement = (
* @property {Array} annotations
* @property {PDFPage} page
* @property {IPDFLinkService} linkService
* @property {string} imageResourcesPath
*/

/**
Expand Down Expand Up @@ -868,7 +870,9 @@ var AnnotationLayer = (function AnnotationLayerClosure() {
page: parameters.page,
viewport: parameters.viewport,
linkService: parameters.linkService,
downloadManager: parameters.downloadManager
downloadManager: parameters.downloadManager,
imageResourcesPath: parameters.imageResourcesPath ||
getDefaultSetting('imageResourcesPath')
};
var element = annotationElementFactory.create(properties);
if (element.isRenderable) {
Expand Down Expand Up @@ -899,7 +903,5 @@ var AnnotationLayer = (function AnnotationLayerClosure() {
};
})();

PDFJS.AnnotationLayer = AnnotationLayer;

exports.AnnotationLayer = AnnotationLayer;
}));
Loading