Not able to preview PDF document

Community Beginner ,
Oct 18, 2021 Oct 18, 2021

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>]

tracy5DC7_0-1634581670574.pngtracy5DC7_1-1634581717712.png

 



 

TOPICS
PDF Embed API

Views

253

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2021 Oct 18, 2021

Copy link to clipboard

Copied

Can you share the PDF in question?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 18, 2021 Oct 18, 2021

Copy link to clipboard

Copied

OK, here is the PDF file. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2021 Oct 18, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 18, 2021 Oct 18, 2021

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. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 18, 2021 Oct 18, 2021

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. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 18, 2021 Oct 18, 2021

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. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 19, 2021 Oct 19, 2021

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. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 19, 2021 Oct 19, 2021

Copy link to clipboard

Copied

LATEST

Very strange, now all the files rendered without error, I didn't make any code change, very strange. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

Make content for your business needs with Adobe Express.

Get started easily with free templates: