Working with Annotations - facades
Contents
[
Hide
]Add Annotation in an Existing PDF File (facades)
PdfContentEditor allows you to add annotations of different types in an existing PDF file. You can use the respective method to add a particular annotation. For example, in the following code snippet, we have used createFreeText method to add FreeText type annotation. Any type of annotations can be added to the PDF file in the same way. First of all, you need to create an object of type PdfContentEditor and bind input PDF file using bindPdf method. Secondly, you have to create a Rectangle object to specify the area of the annotation. After that, you can call createFreeText method to add FreeText annotation, and then use save method to save the updated PDF file.
Add FreeText Annotation
The following code snippet shows you how to add an annotation in a PDF file.
Delete All Annotations by Specified Type (facades)
You can use PdfAnnotationEditor class to delete all the annotations, by a specified annotation type, from the existing PDF file. In order to do that you need to create a PdfAnnotationEditor object and bind input PDF file using bindPdf method. After that, call deleteAnnotations method, with the string parameter, to delete all the annotations from the file; the string parameter represents the annotation type to be deleted. Finally, use save method to save the updated PDF file.
The following code snippet shows you how to delete all annotations by specified annotation type.
Export Annotations from PDF File to XFDF (facades)
The exportAnnotationXfdf method allows you to export annotations from a PDF file. In order to export annotations, you need to create PdfAnnotationEditor object and bind PDF file using bindPdf method. After that, you need to create an int[] array of annotation types which you want to export from PDF file. You can then use exportAnnotationXfdf method to import the annotations. And finally, close the objects.
The following code snippet shows you how to export annotations to XFDF file.