首页 > 解决方案 > 如何在 Adob​​e Embed Api 中打开 pdf 并跳转到特定页面?

问题描述

我使用 Angular 示例在 Angular 中实现了 adobe embed api,现在我想跳转到特定页面

示例:我打开 example.pdf 它有 14 页,我想跳到第 3 页,我该怎么做。

在这个https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDFOpenParameters.pdf中,我看到了我们可以在 pdf URL 之后添加的页面属性,例如 example.pdf#page= 3 所以它会直接跳到那个pdf的第三页。

但是当我实现该属性时,它不会跳转到该页面

对此的任何建议表示赞赏,在此先感谢

标签: javascriptpdfadobeembedembed-api

解决方案


最终能够使用 adobe embed api 中的 goToLocation 函数跳转到特定页面。

如需参考,请查看https://www.adobe.io/apis/documentcloud/dcsdk/docs.html?view=view

const previewFilePromise = this.pdfRef = this.adobeDCView.previewFile({

 content: {

   location: {
     url: fileName, 

    }

  },

 metaData: {

   fileName: 'my file.pdf',

   id: "filed"

 }

},viewerConfig);

previewFilePromise.then((adobeViewer:any) => {

   adobeViewer.getAPIs().then((apis:any) => {
     apis.gotoLocation(<Page_Number>, <X_Coordinate>, <Y_Coordinate>)
        .then(() => console.log("Success"))

        .catch((error:any) => console.log(error));
    });

})

X 和 Y 坐标是可选的,因此使用此功能我们可以使用我们自己的自定义按钮转到 iframe 内的任何页面


推荐阅读