java - 在 pdfbox 中添加对评论的回复
问题描述
我想将回复添加到我为注释输入的评论中。但是我写的代码没有回复,只有注释和评论。我错过了什么?我正在分享我的代码。另外我想添加注释的创建日期,我应该怎么做?提前致谢。
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
// Loading an existing document
File file = new File("ABC.pdf");
PDDocument document = PDDocument.load(file);
System.out.println("PDF loaded.");
PDPage page = document.getPage(0);
List<PDAnnotation> annotations = page.getAnnotations();
PDColor color = new PDColor(new float[] {255f, 0, 0}, PDDeviceRGB.INSTANCE);
PDBorderStyleDictionary thickness = new PDBorderStyleDictionary();
thickness.setWidth((float)2);
PDAnnotationSquareCircle rectangle = new PDAnnotationSquareCircle(PDAnnotationSquareCircle.SUB_TYPE_SQUARE);
rectangle.setColor(color);
rectangle.setBorderStyle(thickness);
PDRectangle points = new PDRectangle();
points.setLowerLeftX((float) 100);
points.setLowerLeftY((float) 100);
points.setUpperRightX((float) 300);
points.setUpperRightY((float) 300);
rectangle.setContents("Rectangle");
rectangle.setRectangle(points);
rectangle.getCOSObject().setString(COSName.T, "XYZ");
PDAnnotationMarkup reply = new PDAnnotationMarkup();
reply.getCOSObject().setName(COSName.SUBTYPE, PDAnnotationMarkup.RT_REPLY);
reply.setContents("Hello 2");
reply.setReplyType("R");
reply.setInReplyTo(rectangle);
annotations.add(rectangle);
System.out.println("Rectangle is added.");
// Save the file
document.save(file);
// Close the document
document.close();
}
解决方案
推荐阅读
- database - 我使用 spring data jpa 的本机查询有问题
- python - 这些 Python 代码有什么区别?
- python - Vs 代码远程容器不在断点处停止
- javascript - 如何在 Google Sheet Chart 的横轴上显示不同的数据类型
- winapi - 透明背景上的圆形矩形?
- reactjs - 当有一个带问号的 URL 并且等于 react nginx 时运行另一个应用程序
- python - stackoverflow 数据的 API
- spring - 通过表单获取数据并传递给控制器
- android - 将接口回调添加到 Bundle 后出现 BadParcelableException(非常罕见且随机发生)?
- java - java中同步块中'this'的作用是什么