1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Move the cMapUrl and cMapPacked options from the global PDFJS object and into getDocument instead

This commit is contained in:
Jonas Jenwald 2018-02-17 16:57:24 +01:00
parent b674409397
commit 3c2fbdffe6
13 changed files with 72 additions and 63 deletions

View file

@ -38,29 +38,31 @@ function renderDocument(pdf, svgLib) {
Promise.all([System.import('pdfjs/display/api'),
System.import('pdfjs/display/svg'),
System.import('pdfjs/display/global'),
System.import('pdfjs/display/worker_options'),
System.import('pdfjs/display/network'),
System.resolve('pdfjs/worker_loader')])
.then(function (modules) {
var api = modules[0];
var svg = modules[1];
var global = modules[2];
var GlobalWorkerOptions = modules[3].GlobalWorkerOptions;
var network = modules[4];
var GlobalWorkerOptions = modules[2].GlobalWorkerOptions;
var network = modules[3];
api.setPDFNetworkStreamFactory((params) => {
return new network.PDFNetworkStream(params);
});
// In production, change this to point to the built `pdf.worker.js` file.
GlobalWorkerOptions.workerSrc = modules[5];
GlobalWorkerOptions.workerSrc = modules[4];
// In production, change this to point to where the cMaps are placed.
global.PDFJS.cMapUrl = '../../external/bcmaps/';
global.PDFJS.cMapPacked = true;
var CMAP_URL = '../../external/bcmaps/';
var CMAP_PACKED = true;
// Fetch the PDF document from the URL using promises.
api.getDocument(url).then(function (doc) {
api.getDocument({
url: url,
cMapUrl: CMAP_URL,
cMapPacked: CMAP_PACKED,
}).then(function(doc) {
renderDocument(doc, svg);
});
});