翻譯|使用教程|編輯:李顯亮|2021-07-26 10:24:48.303|閱讀 309 次
概述:本文演示了如何使用 Spire.PDF for Java 刪除或更新 PDF 文檔中的超鏈接。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
Spire.PDF for Java 是一款專門對(duì) PDF 文檔進(jìn)行操作的 Java 類庫(kù)。該類庫(kù)的主要功能在于幫助開發(fā)人員在 Java 應(yīng)用程序(J2SE和J2EE)中生成 PDF 文檔和操作現(xiàn)有 PDF 文檔,并且運(yùn)行環(huán)境無需安裝 Adobe Acrobat。
本文演示了如何使用 Spire.PDF for Java 刪除或更新 PDF 文檔中的超鏈接。當(dāng)您使用本文所述的方法刪除超鏈接時(shí),超鏈接的外觀將保持不變,但后面的鏈接將被刪除。
可點(diǎn)擊此處下載最新版測(cè)試。
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"); } }
輸出結(jié)果
整合所有格式API處理套包Spire.office for Java正在慧都網(wǎng)火熱銷售中!立馬1分鐘了解全部咨詢!
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn