From f199a8b19e412667cef49eaa64ca033c441cb560 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Thu, 28 Jun 2012 05:33:32 -0500 Subject: [PATCH] Fixes merge with 1849 --- src/api.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/api.js b/src/api.js index 9acacb331..b24867222 100644 --- a/src/api.js +++ b/src/api.js @@ -20,6 +20,15 @@ PDFJS.getDocument = function getDocument(source) { var workerInitializedPromise, workerReadyPromise, transport; + if (typeof source === 'string') { + source = { url: source }; + } else if (isArrayBuffer(source)) { + source = { data: source }; + } else if (typeof source !== 'object') { + error('Invalid parameter in getDocument, need either Uint8Array, ' + + 'string or a parameter object'); + } + if (!source.url && !source.data) error('Invalid parameter array, need either .data or .url');