mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 09:38:06 +02:00
Allow relative URLs in getDocument
This commit is contained in:
parent
b3a603c199
commit
af4bd10c70
3 changed files with 12 additions and 3 deletions
12
src/api.js
12
src/api.js
|
@ -32,11 +32,21 @@ PDFJS.getDocument = function getDocument(source) {
|
|||
if (!source.url && !source.data)
|
||||
error('Invalid parameter array, need either .data or .url');
|
||||
|
||||
// copy/use all keys as is except 'url' -- full path is required
|
||||
var params = {};
|
||||
for (var key in source) {
|
||||
if (key === 'url' && typeof window !== 'undefined') {
|
||||
params[key] = combineUrl(window.location.href, source[key]);
|
||||
continue;
|
||||
}
|
||||
params[key] = source[key];
|
||||
}
|
||||
|
||||
workerInitializedPromise = new PDFJS.Promise();
|
||||
workerReadyPromise = new PDFJS.Promise();
|
||||
transport = new WorkerTransport(workerInitializedPromise, workerReadyPromise);
|
||||
workerInitializedPromise.then(function transportInitialized() {
|
||||
transport.fetchDocument(source);
|
||||
transport.fetchDocument(params);
|
||||
});
|
||||
return workerReadyPromise;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue