PDFViewer and onBeforeAjax

Greetings!

Using the PDFVIewer’s url property does NOT call the onBeforeAjax callback.

Looking at the code, Webix does not allow for the PDF.js ‘httpHeaders’ property to be included in the getDocument call, so there’s no real way to provide headers to the server.

The only work-around I can think of is to fetch the Base64 data from the server, then call the PDF.js API with the PDF data bytes.

Could you recommend any other advice?

Many Thanks,

Bruce

PDFViewer uses PDF.js lib, which uses its own logic to fetch data. So the onBeforeAjax event really doesn’t occur.

We will check how it can be improved

Base64 data from the server, then call the PDF.js API with the PDF data bytes.

Yep, it sounds as a valid solution. webix.ajax can be used to load raw data files, so you need not to encode data to base64

webix.ajax().response("blob").get("patch.zip", function(text, data){
  //data - is a data blob
});

Faced the same problem: w/o setting request header (Access-Control-Allow-Origin: *) before calling “load”, the PDFViewer returns CORS error.
Even Webix example fails to work: https://snippet.webix.com/b0980dc6

“We will check how it can be improved”
Any changes since 2016?