diff --git a/src/index.d.ts b/src/index.d.ts index d52f589..94e873c 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -31,6 +31,7 @@ declare namespace printJS { onPrintDialogClose?: () => void; onIncompatibleBrowser?: () => void; base64?: boolean; + httpHeaders?: { [key: string]: string }; // Deprecated onPdfOpen?: () => void; diff --git a/src/js/init.js b/src/js/init.js index bfda427..4332ab1 100644 --- a/src/js/init.js +++ b/src/js/init.js @@ -40,6 +40,7 @@ export default { style: null, scanStyles: true, base64: false, + httpHeaders: {}, // Deprecated onPdfOpen: null, diff --git a/src/js/pdf.js b/src/js/pdf.js index c4c5d72..3346989 100644 --- a/src/js/pdf.js +++ b/src/js/pdf.js @@ -41,6 +41,11 @@ export default { }) req.open('GET', params.printable, true) + if (params.httpHeaders) { + for (const [header, value] of Object.entries(params.httpHeaders)) { + req.setRequestHeader(header, value) + } + } req.send() } }