Hello, I have a perhaps unusual use case where I'm loading a document into a page view adjacent to some of my own content that's discussing the document. Further down the page I have more discussion content about the same PDF and would like to be able to reposition that embed viewer to be closer to the later content when the user clicks a button down there.
Thanks for any help!
You can use the event callbacks in the Embed API to scroll your content to the right location and also use scroll events in your HTML to cause Embed API to scroll to a page in the PDF. Creating bi-directional communication is really pretty easy.
Hi Joel, thanks for your response.
I'm already using the gotoLocation function to scroll the PDF within the viewer to the location I want. Works great, and a code sample is below (pretty much the same as in the documentation).
Some additional info: when I originally tried moving the adobe-dc-view1 div itself, the viewer would go completely blank and the browser dev tools console would show errors as given below the code sample. So I took a different approach and moved the other page content instead; that made the embed viewer continue to work but with the unwanted scroll-to-top on the containing page.
Maybe a weird approach but it's very close to working the way I want -- just this one glitch!
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://documentcloud.adobe.com') does not match the recipient window's origin ('https://www.vaned.com').
sendMessage @ ViewSDKInterface.js:1
_sendMessageHelper @ ViewSDKInterface.js:1
sendMessage @ ViewSDKInterface.js:1
sendCommand @ ViewSDKInterface.js:1
CommandManager.executeCommand @ ViewSDKInterface.js:1
CommandManager.gotoLocation @ ViewSDKInterface.js:1
If your web site is public, please send the link so I can take a look. I'm not quite understanding the behavior based on your description. If not, can you share a short video showing me what you mean?
Hi Joel, the normal use of this is behind a login, but here's a stripped-down version that illustrates the behavior.
Each "View PDF" link opens the viewer above itself so that you can see the relevant contract text adjacent to the discussion on the page. But something always scrolls the page back to top, so if you were looking at one further down the page, you have to scroll all the way down again after opening the viewer.
Maybe the simple answer is to embed a viewer at each location rather than share a single viewer and move it around, but I thought it would be more efficient to do it this way.
I can't quickly account for the behavior you're seeing but if it were me creating an experience where you have a contract and you want to call attention to different parts of your commentary, I'd set them up where the contract is always visible and that the commentary and the document are side by side. I'd then use events to create an experience such that as you scroll through the commentary, the document automatically scrolls to the right location and as you scroll the contract, the commentary also scrolls to the right area. This is relatively easy to set up and would avoid the problem you are experiencing.
If that's not appealing, you can work around the issue by capturing the scroll position of the window prior to showing the PDF, move the embedded view and then programmatically scroll to the same location.
Thanks Joel, I finally identified the problem and it's nothing to do with the Adobe libraries. So you're welcome to delete this thread if appropriate -- I doubt it'll be useful to other users.
Your scrolling scenario sounds fun but would probably require a wider screen than I can count on our users having.
Thanks again for your time!