var staticUrl = 'http://www.syncfusion.com/downloads/support/directtrac/general/pd/HTTP_Succinctly-1719682472';
var xhr = new XMLHttpRequest();
xhr.open('GET', staticUrl, true);
xhr.responseType = 'blob';
xhr.onload = function (e) {
if (this.status == 200) {
var myBlob = this.response;
var reader = new window.FileReader();
//read the blob data
reader.readAsDataURL(myBlob);
reader.onloadend = function () {
base64data = reader.result;
var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0];
//load the base64 string
pdfviewer.load(base64data, null);
}
}
};
xhr.send(); |
Hi Matt,Thank you for using Syncfusion products.PDF Viewer do not have support to load the PDF document from the Blob object directly. However, you can load the Blob object of PDF document by converting the Blob to base64 string using the client-side load() API in the sample level.Please find the code snippet for the same from the below,
var staticUrl = 'http://www.syncfusion.com/downloads/support/directtrac/general/pd/HTTP_Succinctly-1719682472';var xhr = new XMLHttpRequest();xhr.open('GET', staticUrl, true);xhr.responseType = 'blob';xhr.onload = function (e) {if (this.status == 200) {var myBlob = this.response;var reader = new window.FileReader();//read the blob datareader.readAsDataURL(myBlob);reader.onloadend = function () {base64data = reader.result;var pdfviewer = document.getElementById('pdfviewer').ej2_instances[0];//load the base64 stringpdfviewer.load(base64data, null);}}};xhr.send();Regarding “Also, the link to the PDF Viewer documentation appears to be broken.”We are currently working on creating the documentation with high priority and we will update it as soon as possible.Please let us know if you have any concerns on this.Regards,Akshaya
export class AppComponent implements OnInit {
public service = http://localhost:58767/pdfviewer';
public document = 'PDF_Succinctly.pdf';
ngOnInit(): void {
}
}
|
ngOnInit(): void {
XMLHttpRequest.prototype.realSend = XMLHttpRequest.prototype.send;
var newSend = function (vData) {
this.setRequestHeader('Authorization', 'Bearer 64565dfgfdsjweiuvbiuyhiueygf');
this.realSend(vData);
};
XMLHttpRequest.prototype.send = newSend;
} |