Skip to main content
Participant
January 14, 2021
Answered

How to preload PDF to avoid layered rendering using the DCSDK?

  • January 14, 2021
  • 1 reply
  • 2914 views

The documentation for the DCSDK shows that you can specify a url to load a PDF, but the rendering is very slow and causes 1 layer at a time to be rendered.  We are displaying watermarked documents, so we don't want to have a half second where the watermark is not visible during rendering process.  Is there a way to pre-render before showing the document or potentially load from memory instead of from a url?

 

The documentation say you can use a File blob by specifying a promise, but I see no code examples.  I was hoping I could retrieve the PDF bytes from a server and then pass it to the PDF library to render and perhaps speed up the render process.

 

let adobeDCView = new AdobeDC.View({ clientId: clientId, divId: "adobe-dc-view" });

adobeDCView.previewFile({
    // content: { location: { url: "server.com/my_file.pdf" } }, // works but slow render
    content: { promise: promise }, // does not work when resolving this promise with a Blob of type 'application/pdf'
    metaData: { fileName: "my_file.pdf" }
}, { showAnnotationTools: false, showDownloadPDF: false, showPrintPDF: false });
 
This topic has been closed for replies.
Correct answer Joel Geraci

I have an example of loading a PDF from a Promise and then waiting until APP_RENDERING_DONE fires before displaying the PDF. It also shows how to display your own loading animation during that time. Look at this CodePen.

1 reply

Joel Geraci
Community Expert
Joel GeraciCommunity ExpertCorrect answer
Community Expert
January 15, 2021

I have an example of loading a PDF from a Promise and then waiting until APP_RENDERING_DONE fires before displaying the PDF. It also shows how to display your own loading animation during that time. Look at this CodePen.

Participating Frequently
March 6, 2022

Hi is this suppose to still works? I tried the same exact code in your pen using my brochure, but I can still see the rendering process. Am I missing something? thank you

Joel Geraci
Community Expert
Community Expert
March 8, 2022

Can you share the PDF?