Spire.Pdf.jar
Free Spire.PDF for Java | 100% 免费 Java PDF 组件
public static void linkReplace(String url) throws Exception {//加载PDF示例文档PdfDocument document = new PdfDocument();document.loadFromFile(url);//循环页码PdfPageCollection pages = document.getPages();for (Object page09 : pages) {PdfPageBase page= (PdfPageBase) page09;//获取所有的PDF 超链接集合PdfAnnotationCollection widgetCollection = page.getAnnotationsWidget();List<PdfUriAnnotationWidget> list = widgetCollection.getList();for (PdfUriAnnotationWidget uri : list) {String uri1 = uri.getUri();uri1= uri1.replace("https://oss-cn-beijing.aliyuncs.com/files", "https://oss-cn-qingdao.aliyuncs.com/files");uri.setUri(uri1);}}//保存文档document.saveToFile(url);}