Skip to main content
Known Participant
August 31, 2021
Answered

[PDF Embed API] replace loaded pdf file

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?

    This topic is closed to new replies. Start a new post to keep the conversation going.
    Joel Geraci
    Joel GeraciCorrect answer
    Community Expert
    August 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.

    4 replies

    Joel Geraci
    Community Expert
    Community Expert
    August 31, 2021

    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.

    Translate
    Alon5FCDAuthor
    Known Participant
    August 31, 2021

    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?

    Translate
    Joel Geraci
    Community Expert
    Joel GeraciCommunity ExpertCorrect answer
    Community Expert
    August 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.

    Translate