We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to Pass Headers With PDF Viewer

Hi, we use token authentication for requests to our APIs. How can one pass headers from the Angular PDF Viewer control?


3 Replies

AA Akshaya Arivoli Syncfusion Team August 6, 2019 12:27 PM UTC

Hi Ervin, 

Thank you for contacting Syncfusion support. 

We can add Authorization header to the PDF Viewer control’s Ajax request in the sample level.  Kindly include the below code in ngOnInit() of TS file, 

ngOnInit(): void {             
             (<any> XMLHttpRequest).prototype.realSend = XMLHttpRequest.prototype.send; 
        var newSend = function (vData)  {       
                this.setRequestHeader('Authorization', 'Bearer 64565dfgfdsjweiuvbiuyhiueygf');           
        XMLHttpRequest.prototype.send = newSend; 

The XMLHttpRequest’s method setRequestHeader(), adds custom HTTP headers to the request.  

We have created the sample for the same and shared in the following location, 

Please find the below KB link for reference, 

Please try this and let us know if you have any concerns on this. 


EV Ervin van der Merwe March 11, 2020 06:55 AM UTC

Thanks this worked well.

AA Akshaya Arivoli Syncfusion Team March 11, 2020 09:51 AM UTC

Hi Ervin, 

Thank you for your update. Please feel free to contact us if you have any other concerns. 


Live Chat Icon For mobile
Up arrow icon