Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add comments to PDF by Java

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "Java how to add comments in PDF", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "Java how to add comments in PDF" bar!

Process flow

1. Use the Document class to load the PDF document.

2. Create a TextAnnotation object and add text comments.

3. Set the title, theme and other annotation attributes.

4. Use the Border class to set the Border of the annotation.

Use the Document.getPages () .get_Item (int) .getAnnotations () .add (Annotation) method to add comments to the document.

5. Save the updated PDF with Document.save.

Example

/ / Open the source PDF documentDocument pdfDocument = new Document ("input.pdf"); / / Create annotationTextAnnotation textAnnotation = new TextAnnotation (pdfDocument.getPages (). Get_Item (1), new com.aspose.pdf.Rectangle (200,400,400,600); / / Set annotation titletextAnnotation.setTitle ("Sample Annotation Title"); / / Set annotation subjecttextAnnotation.setSubject ("Sample Subject"); textAnnotation.setState (AnnotationState.Accepted); / / Specify the annotation contentstextAnnotation.setContents ("Sample contents for the annotation"); textAnnotation.setOpen (true) TextAnnotation.setIcon (TextIcon.Key); Border border = new Border (textAnnotation); border.setWidth (5); border.setDash (new Dash (1,1)); textAnnotation.setBorder (border); textAnnotation.setRect (new com.aspose.pdf.Rectangle (200,400,400,600); / / Add annotation in the annotations collection of the pagepdfDocument.getPages (). Get_Item (1). GetAnnotations (textAnnotation); / / Save the output filepdfDocument.save (output.pdf) Thank you for your reading, the above is the content of "Java how to add comments in PDF", after the study of this article, I believe you have a deeper understanding of how Java adds comments in PDF, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report