Add header values in the Vue PDF Viewer
28 Feb 20261 minute to read
Use the ajaxHeaders property inside the PDF Viewer’s ajaxRequestSettings to send custom HTTP headers with each request made by the viewer.
Example: Add a custom Authorization header using ajaxRequestSettings in an Vue component
<template>
<div>
<ejs-pdfviewer
ref="viewer"
:serviceUrl="serviceUrl"
:documentPath="documentPath"
:ajaxRequestSettings="ajaxRequestSettings">
</ejs-pdfviewer>
</div>
</template>
<script>
import { PdfViewerComponent } from '@syncfusion/ej2-vue-pdfviewer';
export default {
name: 'PdfViewerWithHeaders',
components: { 'ejs-pdfviewer': PdfViewerComponent },
data() {
return {
serviceUrl: 'https://ej2services.syncfusion.com/production/web-services/api/pdfviewer',
documentPath: 'https://cdn.syncfusion.com/content/pdf/form-filling-document.pdf',
ajaxRequestSettings: {
ajaxHeaders: [
{
headerName: 'Authorization',
headerValue: 'Bearer 64565dfgfdsjweiuvbiuyhiueygf'
}
],
withCredentials: false
}
};
}
};
</script>