• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

[PDF Embed API] replace loaded pdf file

Explorer ,
Aug 31, 2021 Aug 31, 2021

Copy link to clipboard

Copied

Hi all,

Let's say i loaded a PDF file successfully.

I want to load another file with the same viewer & config. how can i do it?

Views

139

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

correct answers 1 Correct answer

Community Expert , Aug 31, 2021 Aug 31, 2021

I don't work with React enough to advise you on the specifics there. However, before loading a new PDF, you are going to need to set the adobeDCView object to null. You also might need to empty the container element prior to doing so before ComponentUnmount triggers.

Likes

Translate

Translate
Community Expert ,
Aug 31, 2021 Aug 31, 2021

Copy link to clipboard

Copied

Set the DCView object to null and then just load the second PDF as you did the first. I have a working example at this CodePen.

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
Explorer ,
Aug 31, 2021 Aug 31, 2021

Copy link to clipboard

Copied

Thank you for your reply.

I think I should let you in some more details.

i have a thumbnail list in react and when i navigate between one pdf to another, i loose the  adobeDCView state and while navigating the ComponentUnmount does not trigger. saving this in local state also not a good idea...

 

Any advise?

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 ,
Aug 31, 2021 Aug 31, 2021

Copy link to clipboard

Copied

I don't work with React enough to advise you on the specifics there. However, before loading a new PDF, you are going to need to set the adobeDCView object to null. You also might need to empty the container element prior to doing so before ComponentUnmount triggers.

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
Explorer ,
Sep 01, 2021 Sep 01, 2021

Copy link to clipboard

Copied

LATEST

Thank you!

"empty the container element" worked for me

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
Resources