翻譯|使用教程|編輯:李顯亮|2021-07-26 10:24:48.303|閱讀 300 次
概述:本文演示了如何使用 Spire.PDF for Java 刪除或更新 PDF 文檔中的超鏈接。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Spire.PDF for Java 是一款專門對 PDF 文檔進行操作的 Java 類庫。該類庫的主要功能在于幫助開發人員在 Java 應用程序(J2SE和J2EE)中生成 PDF 文檔和操作現有 PDF 文檔,并且運行環境無需安裝 Adobe Acrobat。
本文演示了如何使用 Spire.PDF for Java 刪除或更新 PDF 文檔中的超鏈接。當您使用本文所述的方法刪除超鏈接時,超鏈接的外觀將保持不變,但后面的鏈接將被刪除。
可點擊此處下載最新版測試。
import com.spire.pdf.PdfDocument; import com.spire.pdf.PdfPageBase; import com.spire.pdf.annotations.PdfAnnotationCollection; import com.spire.pdf.annotations.PdfUriAnnotationWidget; public class RemoveHyperlinks { public static void main(String[] args) throws Exception { //Create a PdfDocument object PdfDocument document = new PdfDocument(); //Load the sample PDF file document.loadFromFile("C:\\Users\\Administrator\\Desktop\\Hyperlinks.pdf"); //Get the first page PdfPageBase page = document.getPages().get(0); //Get annotation collection PdfAnnotationCollection widgetCollection = page.getAnnotationsWidget(); //Remove the second annotation which is a hyperlink in the document widgetCollection.removeAt(1); //Get the first url annotation widget PdfUriAnnotationWidget uriWidget = (PdfUriAnnotationWidget)widgetCollection.get(0); //Reset the url uriWidget.setUri("http://www.e-iceblue.com/Introduce/pdf-for-java.html"); //Save to file document.saveToFile("Result.pdf"); } }
輸出結果
整合所有格式API處理套包Spire.office for Java正在慧都網火熱銷售中!立馬1分鐘了解全部咨詢!
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn