@@ -117,6 +117,10 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
117117 * } TypedArray
118118 */
119119
120+ /**
121+ * @typedef { TypedArray | ArrayBuffer | Array<number> | string } BinaryData
122+ */
123+
120124/**
121125 * @typedef {Object } RefProxy
122126 * @property {number } num
@@ -127,10 +131,10 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
127131 * Document initialization / loading parameters object.
128132 *
129133 * @typedef {Object } DocumentInitParameters
130- * @property {string| URL } [url] - The URL of the PDF.
131- * @property {TypedArray|Array<number>|string } [data] - Binary PDF data. Use
132- * typed arrays (Uint8Array) to improve the memory usage. If PDF data is
133- * BASE64-encoded, use `atob()` to convert it to a binary string first.
134+ * @property {string | URL } [url] - The URL of the PDF.
135+ * @property {BinaryData } [data] - Binary PDF data.
136+ * Use typed arrays (Uint8Array) to improve the memory usage. If PDF data is
137+ * BASE64-encoded, use `atob()` to convert it to a binary string first.
134138 * @property {Object } [httpHeaders] - Basic authentication headers.
135139 * @property {boolean } [withCredentials] - Indicates whether or not
136140 * cross-site Access-Control requests should be made using credentials such
@@ -217,14 +221,20 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
217221 * (see `web/debugger.js`). The default value is `false`.
218222 */
219223
224+ /**
225+ * @typedef { string | URL | TypedArray | ArrayBuffer |
226+ * PDFDataRangeTransport | DocumentInitParameters
227+ * } GetDocumentParameters
228+ */
229+
220230/**
221231 * This is the main entry point for loading a PDF and interacting with it.
222232 *
223233 * NOTE: If a URL is used to fetch the PDF data a standard Fetch API call (or
224234 * XHR as fallback) is used, which means it must follow same origin rules,
225235 * e.g. no cross-domain requests without CORS.
226236 *
227- * @param {string|URL|TypedArray|PDFDataRangeTransport|DocumentInitParameters }
237+ * @param {GetDocumentParameters }
228238 * src - Can be a URL where a PDF file is located, a typed array (Uint8Array)
229239 * already populated with data, or a parameter object.
230240 * @returns {PDFDocumentLoadingTask }
@@ -243,7 +253,7 @@ function getDocument(src) {
243253 if ( typeof src !== "object" ) {
244254 throw new Error (
245255 "Invalid parameter in getDocument, " +
246- "need either string, URL, Uint8Array , or parameter object."
256+ "need either string, URL, TypedArray , or parameter object."
247257 ) ;
248258 }
249259 if ( ! src . url && ! src . data && ! src . range ) {
@@ -308,7 +318,7 @@ function getDocument(src) {
308318 params [ key ] = new Uint8Array ( value ) ;
309319 } else {
310320 throw new Error (
311- "Invalid PDF binary data: either typed array , " +
321+ "Invalid PDF binary data: either TypedArray , " +
312322 "string, or array-like object is expected in the data property."
313323 ) ;
314324 }
0 commit comments