Copy link to clipboard
Copied
Hi,
We are trying to use Adobe PDF Embed API to open PDF file in our web application. We have code like this:
this.adobeDCView = new window.AdobeDC.View(config);
/* Invoke the file preview API on Adobe DC View object */
this.adobeDCView.previewFile({
/* Pass information on how to access the file */
content: {
/* Location of file where it is hosted */
promise: Promise.resolve(buffer),
...
buffer is the ArrayBuffer for the PDF file, we used to use PSPDFKit which takes the same arrayBuffer and load the file without problem.
But when we swtiched to Adobe PDF Embed API, the screen first load with spinning wheel "Opening document 100%", after quite time, it shows error:
"File preview error". On the console, it shows:
core.js:6241 ERROR Error: Uncaught (in promise): Object: {"code":"PREVIEW_RENDERING_FAILED"}
at resolvePromise (zone-evergreen.js:798) [angular]
at resolvePromise (zone-evergreen.js:750) [angular]
at polyfills.js:11394:21 [angular]
at Object.onInvokeTask (core.js:41675) [angular]
at drainMicroTaskQueue (zone-evergreen.js:569) [<root>]
at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:484) [<root>]
at invokeTask (zone-evergreen.js:1621) [<root>]
at globalZoneAwareCallback (zone-evergreen.js:1647) [<root>]
Copy link to clipboard
Copied
Can you share the PDF in question?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
The PDF seems to be fine. Can I see the rest of the code, specifically where you are reading the PDF into the ArrayBuffer.
Copy link to clipboard
Copied
The file content is retrieved from server API call, the content is encrypted on server and returned as InputStream, web client gets it and decrypted. The code is complicated, not sure if it helps if I post the code. One thing I want to point is that, before we use the PSPDFKit API to open the file, it works OK with the same ArrayBuffer.
https://pspdfkit.com/guides/web/open-a-document/from-arraybuffer/
So I assume the ArrayBuffer has no problem.
Copy link to clipboard
Copied
I actually found out an interesting thing about this issue. When the PDF file is only one page, I don't get the error. But when the PDF file is over one page, it has the error to render the preview. This means the ArrayBuffer I passed in the Adobe PDF Embed API is correct, it is just an issue for the API to render file content when it is over one page.
Copy link to clipboard
Copied
Are you creatingthe ArrayBuffer by converting it from something else? Maybe it's not complete when you try toload it when the file is larger.
Copy link to clipboard
Copied
I'm not converting the ArrayBuffer from something else, the arrayBuffer is from the API call to server, it should have no problem because we pass it to PSPDFKit and it can render the PDF file without problem.
Copy link to clipboard
Copied
Very strange, now all the files rendered without error, I didn't make any code change, very strange.