如何使用 pdfbox 库的 PDPageContentStream class 创建自定义 pdf 注释?
How to create custom pdf annotation using PDPageContentStream class of pdfbox library?
我已经实现了使用 PDPageContentStream class 的 addBezier 曲线方法创建云标记的功能。现在,我想将此标记创建为页面注释,以便我可以删除这些标记。我尝试使用 PDAnnotation.createAnnotation 方法创建自定义注释,但它需要 COSBase 变量。那么,如何使用 PDPageContentStream class 创建一个 COSBase 变量来指定注释的形状。
你可以单独做一些事情
PDAnnotation annot = new PDAnnotationMarkup();
PDAppearanceDictionary appearance = new PDAppearanceDictionary();
PDAppearanceStream appearanceStream = new PDAppearanceStream(new COSStream());
appearance.setNormalAppearance(appearanceStream);
annot.setAppearance(appearance);
PDPageContentStream contentStream = new PDPageContentStream(pdfDocument, appearanceStream);
contentStream.addBezier(....);
..... more additions to the content stream
我留下了将注释添加到页面等的代码,因为这可以从示例包中的 AddAnnotations.java
示例中查看。
我已经实现了使用 PDPageContentStream class 的 addBezier 曲线方法创建云标记的功能。现在,我想将此标记创建为页面注释,以便我可以删除这些标记。我尝试使用 PDAnnotation.createAnnotation 方法创建自定义注释,但它需要 COSBase 变量。那么,如何使用 PDPageContentStream class 创建一个 COSBase 变量来指定注释的形状。
你可以单独做一些事情
PDAnnotation annot = new PDAnnotationMarkup();
PDAppearanceDictionary appearance = new PDAppearanceDictionary();
PDAppearanceStream appearanceStream = new PDAppearanceStream(new COSStream());
appearance.setNormalAppearance(appearanceStream);
annot.setAppearance(appearance);
PDPageContentStream contentStream = new PDPageContentStream(pdfDocument, appearanceStream);
contentStream.addBezier(....);
..... more additions to the content stream
我留下了将注释添加到页面等的代码,因为这可以从示例包中的 AddAnnotations.java
示例中查看。