本文介紹了帶有PDFBox的PDF中指向頁(yè)面的Java Create鏈接的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我的程序?qū)DF文件中的位置鏈接到同一文件中的另一個(gè)頁(yè)面。因此,您可以單擊文件中定義的位置,您將被鏈接到另一個(gè)頁(yè)面。
我使用PDRectangle
來(lái)定義位置。遺憾的是,該矩形在文檔中可見(jiàn)。我希望創(chuàng)建不帶可見(jiàn)邊框的鏈接。
我的代碼:
PDActionGoTo action = new PDActionGoTo();
action.setDestination(destination);
PDAnnotationLink annotationLink = new PDAnnotationLink();
annotationLink.setAction(action);
PDRectangle position = new PDRectangle();
position.setLowerLeftX(bookmarkLinkPositionEntry.getLowerLeftX());
position.setLowerLeftY(bookmarkLinkPositionEntry.getLowerLeftY());
position.setUpperRightX(bookmarkLinkPositionEntry.getUpperRightX());
position.setUpperRightY(bookmarkLinkPositionEntry.getUpperRightY());
annotationLink.setRectangle(position);
destinationPDF.getPage(0).getAnnotations().add(annotationLink);
我嘗試使用annotationLink.setHidden(true);
和annotationLink.setNoView(true);
。文檔只說(shuō)”設(shè)置隱藏標(biāo)志”。和”設(shè)置noview標(biāo)志。”我不知道那里到底發(fā)生了什么。
如何更改矩形的可見(jiàn)性或完全刪除邊框?
推薦答案
您需要設(shè)置邊框樣式:
PDBorderStyleDictionary borderULine = new PDBorderStyleDictionary();
borderULine.setStyle(PDBorderStyleDictionary.STYLE_UNDERLINE);
borderULine.setWidth(0);
annotationLink.setBorderStyle(borderULine);
有關(guān)此主題的更多信息,請(qǐng)參閱源代碼下載中的AddAnnotations.java example。
這篇關(guān)于帶有PDFBox的PDF中指向頁(yè)面的Java Create鏈接的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,