2

Adobe PDF Embed seems to always reload the pdf instead of just navigating to the correct page (as changing the page number within the iframe does). Is there a way around this?

Code being used: previewFilePromise.then(adobeViewer => {

    adobeViewer.getAPIs().then(apis => {
            apis.gotoLocation(n)
                    .then(() => console.log("Success"))
                    .catch(error => console.log(error));
     });

});

Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
winstonth
  • 23
  • 3

1 Answers1

1

I haven't seen that behavior but I'm approaching the problem a bit differently. I get the APIs only once and then reuse the object as shown below. A link to a functioning example is after the code snippet.

 var viewerAPI = null;
 function showPDF(urlToPDF) {
      var adobeDCView = new AdobeDC.View({
           clientId: clientId,
           divId: "embeddedView"
      });
      previewFilePromise = adobeDCView.previewFile(
           {
                content: { promise: fetchPDF(urlToPDF) },
                metaData: { fileName: urlToPDF.split("/").slice(-1)[0] }
           },
           viewerOptions
      );
      previewFilePromise.then((adobeViewer) => {
           adobeViewer.getAPIs().then((apis) => {
                viewerAPI = apis;
           });
      });
 }

 function goToPage(pageNum) {
      viewerAPI.gotoLocation(parseInt(pageNum));
 }

Full Codepen

joelgeraci
  • 4,606
  • 1
  • 12
  • 19