1
0
Fork 0
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:
Yury Delendik 2012-07-26 12:11:28 -05:00
parent b3a603c199
commit af4bd10c70
3 changed files with 12 additions and 3 deletions

View file

@ -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;
};