【问题标题】:Adobe PDF Embed apis.gotoLocation() forces pdf to refreshAdobe PDF Embed apis.gotoLocation() 强制 pdf 刷新
【发布时间】:2022-01-05 01:54:35
【问题描述】:

Adobes PDF Embed 似乎总是重新加载 pdf,而不是仅仅导航到正确的页面(就像更改 iframe 中的页码一样)。有没有办法解决这个问题?

正在使用的代码: previewFilePromise.then(adobeViewer => {

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

});

【问题讨论】:

    标签: api pdf adobe embed


    【解决方案1】:

    我没有看到这种行为,但我处理问题的方式有点不同。我只获得一次 API,然后重用该对象,如下所示。在代码 sn-p 之后是一个运行示例的链接。

     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

    【讨论】:

    • 非常感谢!正是我需要的!
    猜你喜欢
    • 1970-01-01
    • 2021-09-01
    • 1970-01-01
    • 2022-11-11
    • 1970-01-01
    • 2010-10-06
    • 1970-01-01
    • 1970-01-01
    • 2016-12-23
    相关资源
    最近更新 更多