String oldURI = uri.getURI(); String newURI = "http://pdfbox.apache.org"; System.out.println( "Page " + pageNum +": Replacing " + oldURI + " with " + newURI );
System.out.println("Page " + pageNum + ":'" + urlText.trim() + "'=" + uri.getURI());
PDActionURI uri = getActionURI(annotation); if (uri != null) { String link = uri.getURI(); if (link != null && link.trim().length() > 0) { xhtml.startElement("div", "class", "annotation");
System.out.println("uri link:" + uri.getURI()); } else { if (action instanceof PDActionGoTo) {
public static void changeURL(String originalPdf, String targetPdf, Map<String, String> urls ) { try (PDDocument doc = PDDocument.load(originalPdf)) { List<PDPage> allPages = doc.getDocumentCatalog().getAllPages(); for(PDPage page: allPages){ List annotations = page.getAnnotations(); for(PDAnnotation annot : page.getAnnotations()){ if (annot instanceof PDAnnotationLink) { PDAnnotationLink link = (PDAnnotationLink) annot; PDAction action = link.getAction(); if (action instanceof PDActionURI) { PDActionURI uri = (PDActionURI) action; String oldURL = uri.getURI(); for (Map.Entry<String, String> url : urls.entrySet()){ if (url.getKey().equals(oldURL)) { uri.setURI(url.getValue()); } } } } } } doc.save(targetPdf); } catch (IOException | COSVisitorException e) { e.printStackTrace(); } }
String oldURI = uri.getURI(); String newURI = "http://pdfbox.apache.org"; System.out.println( "Page " + pageNum +": Replacing " + oldURI + " with " + newURI );
System.out.println("Page " + pageNum + ":'" + urlText.trim() + "'=" + uri.getURI());
System.out.println( "Page " + pageNum +":'" + urlText.trim() + "'=" + uri.getURI() );
String link = uri.getURI(); if (link != null && link.trim().length() > 0) { xhtml.startElement("div", "class", "annotation");
PDActionURI uri = getActionURI(annotation); if (uri != null) { String link = uri.getURI(); if (link != null && link.trim().length() > 0) { xhtml.startElement("div", "class", "annotation");
String link = uri.getURI(); if (link != null && link.trim().length() > 0) { xhtml.startElement("div", "class", "annotation");