Apache PDFBox - 触发器和渲染 PDF 的嵌入 JavaScript

发布于 2025-01-13 01:52:36 字数 724 浏览 2 评论 0原文

我使用 PDFBox 库制作了一个类似于增强型 PDF 查看器的应用程序。 是否有可能与文档进行交互,特别是,我有一个用 LaTeX 自制的 PDF 文档,其中包含动画包 + JavaScript 代码,它创建了一些可以滚动某些内容的按钮。因此,我需要检查文档是否具有此类按钮(我用 LaTeX 创建)并“单击”它们,这意味着使用 PDFBox 触发操作,如果我在 Adob​​e Reader 中打开 PDF 并单击,则会触发该操作将鼠标放在该按钮上,PDFBox 会再次渲染 PDF,内容会稍微滚动。这可能吗?

这是我的 LaTeX 代码片段:

\newcommand\botScrollButton[1]{%
    \mediabutton[
    jsaction={
        if(event.shift){anim['#1'].pause();anim['#1'].frameNum=anim['#1'].numFrames-1;}
        else try{anim['#1'].frameNum+=10}catch(e){}
    }
    ]{\fboxsep=0pt\framebox[\widthof{\xusebox{#1}}][c]{%
            \tiny\strut\raisebox{0.1\height}{$\underline{\vee\vee\vee}$}}%
    }%
}  

也许,Tilman Hausherr 知道这一点,他在这里用 PDFBox 帮助了我很多次哈哈。

I made an application like an enhanced PDF viewer using PDFBox library.
Is there a possibility to interact with a document, in particular, I have a self crafted PDF document in LaTeX with animate package + JavaScript code, that creates kinda buttons that enable to scroll some content. So, I would need to check if the document has these kind of buttons (I created with LaTeX) and to "click" them, meaning to trigger the action using PDFBox that would be triggered if I opened the PDF in Adobe Reader and clicked with the mouse on this button, such that PDFBox then renders the PDF again with the content being scrolled a bit. Is this possible?

Here is my LaTeX code fragment:

\newcommand\botScrollButton[1]{%
    \mediabutton[
    jsaction={
        if(event.shift){anim['#1'].pause();anim['#1'].frameNum=anim['#1'].numFrames-1;}
        else try{anim['#1'].frameNum+=10}catch(e){}
    }
    ]{\fboxsep=0pt\framebox[\widthof{\xusebox{#1}}][c]{%
            \tiny\strut\raisebox{0.1\height}{$\underline{\vee\vee\vee}$}}%
    }%
}  

Maybe, Tilman Hausherr knows this, he helped me quite a few times with PDFBox on here haha.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文