Hello,
Scenario:
I'm looking for some code example to return a PDF file promise from the entryPoint=pdf url. This is to use a pdf viewer from adobeSDK. I guess I need to return a filePromise somehow? The below code is not working, (error is Ajax could not parse response) I suspect because what is returned from ?entryPoint=pdf is not the type of file promise adobe SDK is looking for. They give an example code for a file upload here but not an existing file sitting on server somewhere.
Does entryPoint=pdf return blob or arrayBuffer?
What I've Tried
Scenario:
I'm looking for some code example to return a PDF file promise from the entryPoint=pdf url. This is to use a pdf viewer from adobeSDK. I guess I need to return a filePromise somehow? The below code is not working, (error is Ajax could not parse response) I suspect because what is returned from ?entryPoint=pdf is not the type of file promise adobe SDK is looking for. They give an example code for a file upload here but not an existing file sitting on server somewhere.
Does entryPoint=pdf return blob or arrayBuffer?
What I've Tried
Code:
let pdfUrl = ?entryPoint=pdf&entityType={MyEntityType}&entityId={MyEntityId}&templateId={MyTemplateId }; Espo.Ajax.getRequest(pdfUrl, null, { dataType: 'arraybuffer' }) .then(data => { let blob = new Blob([data]); let reader = new FileReader(); reader.onloadend = function(e) { console.log({ adobeDCView: adobeDCView }); let filePromise = Promise.resolve(e.target.result); // Pass the filePromise and name of the file to the previewFile API adobeDCView.previewFile({ content: { promise: filePromise }, metaData: { fileName: "File.pdf" } }) }; reader.readAsArrayBuffer(blob); });
Comment