[api-minor] Add support for relative URLs, in both annotations and the outline, by adding a docBaseUrl parameter to PDFJS.getDocument (bug 766086)

Note that in `FIREFOX/MOZCENTRAL/CHROME` builds of the standard viewer the `docBaseUrl` parameter will be set by default, since in that case it makes sense to use the current URL as a base.
For the `GENERIC` viewer, or the API itself, it doesn't make sense to try and set the `docBaseUrl` by default. However, custom deployments/implementations may still find the parameter useful.
This commit is contained in:
Jonas Jenwald 2016-10-01 12:05:07 +02:00
parent 71a781ee5c
commit d284cfd5eb
11 changed files with 304 additions and 47 deletions

View file

@ -129,6 +129,9 @@ if (typeof PDFJSDev !== 'undefined' &&
* 2^16 = 65536.
* @property {PDFWorker} worker - The worker that will be used for the loading
* and parsing of the PDF data.
* @property {string} docBaseUrl - (optional) The base URL of the document,
* used when attempting to recover valid absolute URLs for annotations, and
* outline items, that (incorrectly) only specify relative URLs.
*/
/**
@ -301,6 +304,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
postMessageTransfers: getDefaultSetting('postMessageTransfers') &&
!isPostMessageTransfersDisabled,
docBaseUrl: source.docBaseUrl,
}).then(function (workerId) {
if (worker.destroyed) {
throw new Error('Worker was destroyed');