繁体   English   中英

PDF 注释/注释是否可以包含指向 PDF 中其他页面的链接?

[英]Can PDF notes/annotations include links to other pages in the PDF?

我想向 PDF 页面添加注释(即会显示为弹出式注释或出现在当前页面的注释列表中的内容)。

在那篇笔记中,我想说“见第 93 页”,点击它会将用户带到第 93 页。

那可能吗? 这似乎是一个有用的功能,但我找不到任何示例。

如果是这样,可以使用 Apache PDF Box 完成吗?

是(有可能)和是(可以用 PdfBox 完成)。 这个问题以前有人问过,回答过好几次。 阅读follwing答案在这里和看到完整的代码在这里

try (   InputStream resource = getClass().getResourceAsStream("some.pdf")) {
            PDDocument document = Loader.loadPDF(resource);

            PDPage page = document.getPage(1);

            PDAnnotationLink link         = new PDAnnotationLink();
            PDPageDestination destination = new PDPageFitWidthDestination();
            PDActionGoTo action           = new PDActionGoTo();

            //destination.setPageNumber(2);
            destination.setPage(document.getPage(2));
            action.setDestination(destination);
            link.setAction(action);
            link.setPage(page);

            link.setRectangle(page.getMediaBox());
            page.getAnnotations().add(link);

            document.save(new File("RESULT_FOLDER", "output-with-link.pdf"));
        }

其他答案在这里这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM