• <menu id="w2i4a"></menu>
  • logo Aspose.PDF使用教程

    文檔首頁>>Aspose.PDF使用教程>>Spire.PDF功能演示:在 Java 中刪除或更新 PDF 中的超鏈接

    Spire.PDF功能演示:在 Java 中刪除或更新 PDF 中的超鏈接


    Spire.PDF for Java 是一款專門對(duì) PDF 文檔進(jìn)行操作的 Java 類庫。該類庫的主要功能在于幫助開發(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("https://www.e-iceblue.com/Introduce/pdf-for-java.html");
    
            //Save to file
            document.saveToFile("Result.pdf");
        }
    }

    輸出結(jié)果

    國(guó)產(chǎn)PDF格式處理控件Spire.PDF功能演示:在 Java 中刪除或更新 PDF 中的超鏈接



    整合所有格式API處理套包Spire.office for Java正在慧都網(wǎng)火熱銷售中!聯(lián)系慧都客服立馬1分鐘了解全部咨詢!

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();