1 回答

TA貢獻(xiàn)2011條經(jīng)驗(yàn) 獲得超2個(gè)贊
首先,您必須將新值設(shè)置為字典中的URIannotationAction鍵:
if (annotationAction.get(PdfName.S).equals(PdfName.URI)) {
final PdfString destination = annotationAction.getAsString(PdfName.URI);
final String url = destination.toString();
System.out.println(url);
String updatedUrl = [... url changed to match the changed criteria ...];
annotationAction.put(PdfName.URI, new PdfString(updatedUrl));
}
之后,您必須通過(guò)應(yīng)用保存更改而PdfStamper無(wú)需執(zhí)行進(jìn)一步操作:
final byte[] data = ByteStreams.toByteArray(istream);
pdfs.add(data);
final PdfReader reader = new PdfReader(data);
final PdfDictionary pageDictionary = reader.getPageN(36);
final PdfArray annotations = pageDictionary.getAsArray(PdfName.ANNOTS);
if (annotations != null && annotations.size() != 0) {
[...]
}
new PdfStamper(reader, new FileOutputStream(dir + name + "-new.pdf")).close();
添加回答
舉報(bào)