我想添加一个注解。页(即东西,将显示出作为一个弹注意或出现在该列表的附注当前页)。
在这方面,我想说"见第93页",这里的点击,它的用户向网页93.
这可能吗? 这似乎是一个有用的功能,但我一直没能找到任何实例。
如果可以,可以这样做Apache PDF框?
我想添加一个注解。页(即东西,将显示出作为一个弹注意或出现在该列表的附注当前页)。
在这方面,我想说"见第93页",这里的点击,它的用户向网页93.
这可能吗? 这似乎是一个有用的功能,但我一直没能找到任何实例。
如果可以,可以这样做Apache PDF框?
是的(这是可能的)并且是(这是可以做到与PdfBox). 这个问题已经问过,并回答了几次。 阅读以下的答案 在这里, 并看到完整的代码 这里.
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"));
}