mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Move the cMapUrl
and cMapPacked
options from the global PDFJS
object and into getDocument
instead
This commit is contained in:
parent
b674409397
commit
3c2fbdffe6
13 changed files with 72 additions and 63 deletions
|
@ -142,6 +142,10 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
|
|||
* with limited image support through stubs (useful for SVG conversion),
|
||||
* and 'none' where JPEG images will be decoded entirely by PDF.js.
|
||||
* The default value is 'decode'.
|
||||
* @property {string} cMapUrl - (optional) The URL where the predefined
|
||||
* Adobe CMaps are located. Include trailing slash.
|
||||
* @property {boolean} cMapPacked - (optional) Specifies if the Adobe CMaps are
|
||||
* binary packed.
|
||||
* @property {Object} CMapReaderFactory - (optional) The factory that will be
|
||||
* used when reading built-in CMap files. Providing a custom factory is useful
|
||||
* for environments without `XMLHttpRequest` support, such as e.g. Node.js.
|
||||
|
@ -201,7 +205,7 @@ function getDocument(src) {
|
|||
let params = Object.create(null);
|
||||
var rangeTransport = null;
|
||||
let worker = null;
|
||||
var CMapReaderFactory = DOMCMapReaderFactory;
|
||||
let CMapReaderFactory = DOMCMapReaderFactory;
|
||||
|
||||
for (var key in source) {
|
||||
if (key === 'url' && typeof window !== 'undefined') {
|
||||
|
@ -289,7 +293,7 @@ function getDocument(src) {
|
|||
var messageHandler = new MessageHandler(docId, workerId, worker.port);
|
||||
messageHandler.postMessageTransfers = worker.postMessageTransfers;
|
||||
var transport = new WorkerTransport(messageHandler, task, networkStream,
|
||||
CMapReaderFactory);
|
||||
params, CMapReaderFactory);
|
||||
task._transport = transport;
|
||||
messageHandler.send('Ready', null);
|
||||
});
|
||||
|
@ -1550,14 +1554,15 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||
*/
|
||||
var WorkerTransport = (function WorkerTransportClosure() {
|
||||
function WorkerTransport(messageHandler, loadingTask, networkStream,
|
||||
CMapReaderFactory) {
|
||||
params, CMapReaderFactory) {
|
||||
this.messageHandler = messageHandler;
|
||||
this.loadingTask = loadingTask;
|
||||
this.commonObjs = new PDFObjects();
|
||||
this.fontLoader = new FontLoader(loadingTask.docId);
|
||||
this._params = params;
|
||||
this.CMapReaderFactory = new CMapReaderFactory({
|
||||
baseUrl: getDefaultSetting('cMapUrl'),
|
||||
isCompressed: getDefaultSetting('cMapPacked'),
|
||||
baseUrl: params.cMapUrl,
|
||||
isCompressed: params.cMapPacked,
|
||||
});
|
||||
|
||||
this.destroyed = false;
|
||||
|
|
|
@ -69,8 +69,9 @@ class DOMCMapReaderFactory {
|
|||
|
||||
fetch({ name, }) {
|
||||
if (!this.baseUrl) {
|
||||
return Promise.reject(new Error('CMap baseUrl must be specified, ' +
|
||||
'see "PDFJS.cMapUrl" (and also "PDFJS.cMapPacked").'));
|
||||
return Promise.reject(new Error(
|
||||
'The CMap "baseUrl" parameter must be specified, ensure that ' +
|
||||
'the "cMapUrl" and "cMapPacked" API parameters are provided.'));
|
||||
}
|
||||
if (!name) {
|
||||
return Promise.reject(new Error('CMap name must be specified.'));
|
||||
|
@ -345,10 +346,6 @@ function getDefaultSetting(id) {
|
|||
return globalSettings ? globalSettings.disableFontFace : false;
|
||||
case 'disableCreateObjectURL':
|
||||
return globalSettings ? globalSettings.disableCreateObjectURL : false;
|
||||
case 'cMapUrl':
|
||||
return globalSettings ? globalSettings.cMapUrl : null;
|
||||
case 'cMapPacked':
|
||||
return globalSettings ? globalSettings.cMapPacked : false;
|
||||
case 'isEvalSupported':
|
||||
return globalSettings ? globalSettings.isEvalSupported : true;
|
||||
default:
|
||||
|
|
|
@ -65,19 +65,6 @@ PDFJS.Util = Util;
|
|||
PDFJS.PageViewport = PageViewport;
|
||||
PDFJS.createPromiseCapability = createPromiseCapability;
|
||||
|
||||
/**
|
||||
* The url of where the predefined Adobe CMaps are located. Include trailing
|
||||
* slash.
|
||||
* @var {string}
|
||||
*/
|
||||
PDFJS.cMapUrl = (PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl);
|
||||
|
||||
/**
|
||||
* Specifies if CMaps are binary packed.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
|
||||
|
||||
/**
|
||||
* By default fonts are converted to OpenType fonts and loaded via font face
|
||||
* rules. If disabled, the font will be rendered using a built in font
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue