Expose Ajax response headers

Hi! i'm working with the pdf viewer and i has a use case that needs intercept a response header at load document.

Why i need it?: I has a form, with the values i call the api service pdfviewer load to get a pdf from the values. The issue is that i dont have the filename generated by backend (and i need it to download), so backend can send me in response header the file name in content-disposition or other header. 

So i need intercept the response header of load pdf.  How i can do this?




4 Replies

VS Vasugi Sivajothi Syncfusion Team June 28, 2021 10:22 AM UTC

Hi Benjamin, 
  
Thank you for contacting Syncfusion support. 
  
We can include the Authorization token in the PDF Viewer AJAX request using the properties of ajaxRequest headers available in AjaxRequestSettings and it will be included in every AJAX request send from PDF Viewer. We have shared the simple sample for your reference. Please refer to the below documentation and sample. 
  
  
  
Kindly try this and let us know if you have any concerns about this. 
  
Regards, 
Vasugi. 



BE Benjamin June 28, 2021 04:23 PM UTC

Hi Vasugi, yes, i'm ok with autorization header and works fine. In my case, i need intercept Response Header​, not Request Header. 

 I need intercept Response Header because in one of them backend send to me important info.





VS Vasugi Sivajothi Syncfusion Team June 29, 2021 12:30 PM UTC

Hi Benjamin, 
  
Thank you for the update. 
  
Currently, there is no support to intercept the response headers in our PDF Viewer. We will analyze further on this and update you with more details on July 1, 2021. 
  
Regards, 
Vasugi. 



VS Vasugi Sivajothi Syncfusion Team June 30, 2021 11:13 AM UTC

Hi Benjamin,  
  
Thank you for your patience. 
  
We have checked further on this and found that we can achieve your requirement by adding the document data in JSON object  using  ajaxRequestInitiate event. Please refer to the below code snippet and sample, 
  
Code Snippet: 
  
public ajaxInitiate(e: AjaxRequestInitiateEventArgs): void { 
    if (e.JsonData.action == "Load") { 
      e.JsonData["id"] = "PDFViewer"; 
      var pdfviewer = (<any>document.getElementById("pdfViewer")) 
        .ej2_instances[0]; 
      pdfviewer.setJsonData(e.JsonData); 
    } 
  } 
  
  
  
  
Kindly try this and let us know the provided details will achieve your requirement. 
  
Regards, 
Vasugi. 


Loader.
Up arrow icon