public final class PdfAnnotationEditor extends SaveableFacade
Represents a class for work with PDF document annotations (comments).
Constructor and Description |
---|
PdfAnnotationEditor()
Initializes new
PdfAnnotationEditor object. |
PdfAnnotationEditor(IDocument document)
Initializes new
PdfAnnotationEditor object on base of the document . |
Modifier and Type | Method and Description |
---|---|
void |
deleteAnnotation(String annotName)
Deletes the annotation with specified annotation name.
|
void |
deleteAnnotations()
Deletes all annotations in the document.
|
void |
deleteAnnotations(String annotType)
Deletes all annotations of the specified type in the document.
|
void |
exportAnnotationsToXfdf(OutputStream xmlOutputStream)
Exports
|
void |
exportAnnotationsXfdf(OutputStream xmlOutputStream,
int start,
int end,
int[] annotTypes)
Exports the content of the specified annotation types into XFDF
PdfAnnotationEditor editor = new PdfAnnotationEditor();
editor.bindPdf("example.pdf");
int[] annotTypes = new int[] {AnnotationType.Text, AnnotationType.Highlight};
OutputStream stream = new FileOutputStream("example.xfdf");
editor.exportAnnotationsXfdf(stream, 1, 2, annotTypes);
stream.close();
|
void |
exportAnnotationsXfdf(OutputStream xmlOutputStream,
int start,
int end,
String[] annotTypes)
Exports the content of the specified annotations types into XFDF
PdfAnnotationEditor editor = new PdfAnnotationEditor();
editor.bindPdf("example.pdf");
String[] annotTypes = new String[] {"Text", "Highlight"};
OutputStream stream = new FileOutputStream("example.xfdf");
editor.exportAnnotationsXfdf(stream, 1, 2, annotTypes);
stream.close();
|
List<Annotation> |
extractAnnotations(int start,
int end,
int[] annotTypes)
Gets the list of annotations of the specified types.
|
List<Annotation> |
extractAnnotations(int start,
int end,
String[] annotTypes)
Gets the list of annotations of the specified types.
|
void |
flatteningAnnotations()
Flattens all annotations in the document.
|
void |
flatteningAnnotations(int start,
int end,
int[] annotType)
Flattens the annotations of the specified types.
|
void |
importAnnotationFromXfdf(InputStream xfdfStream)
Deprecated.
|
void |
importAnnotationFromXfdf(String xfdfFile)
Deprecated.
Method is obsolete, please use ImportAnnotationsFromXfdf instead
|
void |
importAnnotations(InputStream[] annotFileInputStream)
Imports annotations into document from array of another PDF document streams.
|
void |
importAnnotations(InputStream[] annotFileInputStream,
int[] annotType)
Imports the specified annotations into document from array of another PDF document streams.
|
void |
importAnnotations(String[] annotFile)
Imports annotations into document from array of another PDF documents.
|
void |
importAnnotations(String[] annotFile,
int[] annotType)
Imports the specified annotations into document from array of another PDF documents.
|
void |
importAnnotationsFromXfdf(InputStream xfdfSteam)
Imports all annotations from XFDF data stream.
|
void |
importAnnotationsFromXfdf(InputStream xfdfStream,
int[] annotType)
Imports the specified annotations from XFDF data stream.
|
void |
importAnnotationsFromXfdf(String xfdfFile)
Imports all annotations from XFDF file.
|
void |
importAnnotationsFromXfdf(String xfdfFile,
int[] annotType)
Imports the specified annotations from XFDF file.
|
void |
modifyAnnotations(int start,
int end,
Annotation annotation)
Modifies the annotations of the specifed type on the specified page range.
|
void |
modifyAnnotations(int start,
int end,
int annotType,
Annotation annotation)
Deprecated.
|
void |
modifyAnnotationsAuthor(int start,
int end,
String srcAuthor,
String desAuthor)
Modifies the author of annotations on the specified page range.
|
void |
redactArea(int pageIndex,
Rectangle rect,
Color color)
Redacts area on the specified page.
|
void |
redactExactArea(int pageIndex,
Rectangle rect,
Color color)
Redacts area on the specified page.
|
void |
save(OutputStream outputStream)
Saves the result PDF to stream.
|
void |
save(String outputFile)
Saves the result PDF to file.
|
bindPdf, bindPdf, bindPdf, bindPdf, bindPdf, close, dispose, getDocument
public PdfAnnotationEditor()
Initializes new PdfAnnotationEditor
object.
public PdfAnnotationEditor(IDocument document)
Initializes new PdfAnnotationEditor
object on base of the document
.
document
- Pdf document.public void importAnnotationsFromXfdf(String xfdfFile)
Imports all annotations from XFDF file.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); editor.importAnnotationsFromXfdf("annots.xfdf"); editor.save("example_out.pdf");
xfdfFile
- The input XFDF file.@Deprecated public final void importAnnotationFromXfdf(String xfdfFile)
Imports all annotations from XFDF file.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); editor.importAnnotationFromXfdf("annots.xfdf"); editor.save("example_out.pdf");
xfdfFile
- The input XFDF file.public void importAnnotationsFromXfdf(String xfdfFile, int[] annotType)
Imports the specified annotations from XFDF file.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); int[] annotTypes = {AnnotationType.Highlight, AnnotationType.Text}; editor.importAnnotationFromXfdf("annots.xfdf", annotTypes); editor.save("example_out.pdf");
xfdfFile
- The input XFDF file.annotType
- The annotations array to be imported.public void importAnnotationsFromXfdf(InputStream xfdfStream, int[] annotType)
Imports the specified annotations from XFDF data stream.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); int[] annotTypes ={ AnnotationType.Highlight, AnnotationType.Line }; editor.importAnnotationFromXfdf(new FileInputStream("annots.xfdf"), annotTypes); editor.save("example_out.pdf");
xfdfStream
- The input XFDF data stream.annotType
- The array of annotation types to be imported.public void importAnnotationsFromXfdf(InputStream xfdfSteam)
Imports all annotations from XFDF data stream.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); editor.importAnnotationsFromXfdf(new FileInputStream("annots.xfdf")); editor.save("example_out.pdf");
xfdfSteam
- The input XFDF data stream.@Deprecated public final void importAnnotationFromXfdf(InputStream xfdfStream)
Imports all annotations from XFDF data stream.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); editor.importAnnotationFromXfdf(new FileInputStream("annots.xfdf")); editor.save("example_out.pdf");
xfdfStream
- The input XFDF data stream.public void importAnnotations(String[] annotFile, int[] annotType)
Imports the specified annotations into document from array of another PDF documents.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); string[] paths = new string[2] {"with_annots1.pdf", "with_annots2.pdf"}; int[] annotTypes = {AnnotationType.Highlight, AnnotationType.Text}; editor.importAnnotations(paths, annotTypes); editor.save("example_out.pdf");
annotFile
- The array of paths of PDF documents that contain source annotations.annotType
- The array of annotation types to be imported.public void importAnnotations(String[] annotFile)
Imports annotations into document from array of another PDF documents.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); string[] paths = new string[2] {"with_annots1.pdf", "with_annots2.pdf"}; editor.importAnnotations(paths); editor.save("example_out.pdf");
annotFile
- The array of paths of PDF documents that contain source annotations.public void importAnnotations(InputStream[] annotFileInputStream, int[] annotType)
Imports the specified annotations into document from array of another PDF document streams.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); InputStream[] streams = new FileInputStream[2]; streams[0]= new FileInputStream("with_annots1.pdf"); streams[1]= new FileInputStream("with_annots2.pdf"); int[] annotTypes = {AnnotationType.Highlight, AnnotationType.Text}; editor.importAnnotations(streams, annotTypes); editor.save("example_out.pdf"); streams[0].close(); streams[1].close();
annotFileInputStream
- The array of streams of PDF documents that contain source annotations.annotType
- The annotation types to be imported.public void importAnnotations(InputStream[] annotFileInputStream)
Imports annotations into document from array of another PDF document streams.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); InputStream[] streams = new FileInputStream[2]; streams[0]= new FileInputStream("with_annots1.pdf"); streams[1]= new FileInputStream("with_annots2.pdf"); editor.importAnnotations(streams); editor.save("example_out.pdf"); streams[0].Close(); streams[1].Close();
annotFileInputStream
- The array of streams of PDF documents that contain source annotations.@Deprecated public void modifyAnnotations(int start, int end, int annotType, Annotation annotation)
Modifies the annotations of the specifed type on the specified page range. It supports to modify next annotation properties: Modified, Title, Contents, Color, Subject and Open.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); com.aspose.pdf.TextAnnotation annot = new com.aspose.pdf.TextAnnotation(); annot.setModified ( new java.util.Date()); annot.setTitle ( "NEW AUTHOR"); annot.setContents ( "NEW CONTENTS"); annot.setColor (com.aspose.pdf.Color.getRed()); annot.setSubject ( "NEW SUBJECT"); annot.setOpen ( true); editor.modifyAnnotations(1, 2, com.aspose.pdf.AnnotationType.Text, annot); editor.save("example_out.pdf");
start
- The start page number.end
- The end page number.annotType
- The annotation type.annotation
- The annotation object contains new properties.public void modifyAnnotationsAuthor(int start, int end, String srcAuthor, String desAuthor)
Modifies the author of annotations on the specified page range.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); editor.modifyAnnotationsAuthor(1, 2, "PREV AUTHOR", "NEW AUTHOR"); editor.save("example_out.pdf");
start
- The start page number.end
- The end page number.srcAuthor
- The author that must be modified.desAuthor
- The new author.public void flatteningAnnotations()
Flattens all annotations in the document.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); editor.flatteningAnnotations(); editor.save(example_out.pdf");
public void flatteningAnnotations(int start, int end, int[] annotType)
Flattens the annotations of the specified types.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); int[] annotTypes ={AnnotationType.Line, AnnotationType.FreeText}; editor.flatteningAnnotations(1, 2, annotTypes); editor.save("example_out.pdf");
start
- The start page.end
- Then end page.annotType
- The annotation types should be flattened.public void deleteAnnotations()
Deletes all annotations in the document.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); editor.deleteAnnotations(); editor.save("example_out.pdf");
public void deleteAnnotations(String annotType)
Deletes all annotations of the specified type in the document.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); editor.deleteAnnotations("Text"); editor.save("example_out.pdf");
annotType
- The type of annotation will be deleted.public void deleteAnnotation(String annotName)
Deletes the annotation with specified annotation name.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); editor.deleteAnnotation("4cfa69cd-9bff-49e0-9005-e22a77cebf38"); editor.save("example_out.pdf");
annotName
- The annotation namepublic void exportAnnotationsXfdf(OutputStream xmlOutputStream, int start, int end, String[] annotTypes)
Exports the content of the specified annotations types into XFDF
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); String[] annotTypes = new String[] {"Text", "Highlight"}; OutputStream stream = new FileOutputStream("example.xfdf"); editor.exportAnnotationsXfdf(stream, 1, 2, annotTypes); stream.close();
xmlOutputStream
- The output XFDF stream.start
- Start page from which the annotations of the document will be exported.end
- End page to which the annotations of the document will be exported.annotTypes
- The array of annotation types need be exported.public final void exportAnnotationsToXfdf(OutputStream xmlOutputStream)
Exports
xmlOutputStream
- OutputStream instancepublic void exportAnnotationsXfdf(OutputStream xmlOutputStream, int start, int end, int[] annotTypes)
Exports the content of the specified annotation types into XFDF
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); int[] annotTypes = new int[] {AnnotationType.Text, AnnotationType.Highlight}; OutputStream stream = new FileOutputStream("example.xfdf"); editor.exportAnnotationsXfdf(stream, 1, 2, annotTypes); stream.close();
xmlOutputStream
- The output XFDF stream.start
- Start page from which the annotations of the document will be exported.end
- End page to which the annotations of the document will be exported.annotTypes
- The array of annotation types need be exported.public List<Annotation> extractAnnotations(int start, int end, String[] annotTypes)
Gets the list of annotations of the specified types.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); String[] annotTypes = new String[] {"Text", "Highlight"}; List annotList = (List)editor.extractAnnotations(1, 2 , annotTypes);
start
- Start page from which the annotations will be selected.end
- End page to which the annotations will be selected.annotTypes
- The array of needed annotation types.public List<Annotation> extractAnnotations(int start, int end, int[] annotTypes)
Gets the list of annotations of the specified types.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); int[] annotTypes = new int[] {AnnotationType.Text, AnnotationType.Highlight}; List annotList = (List)editor.extractAnnotations(1, 2 , annotTypes);
start
- Start page from which the annotations will be selected.end
- End page to which the annotations will be selected.annotTypes
- The array of needed annotation types.public void save(String outputFile)
Saves the result PDF to file.
save
in interface ISaveableFacade
save
in class SaveableFacade
outputFile
- Output PDF filepublic void save(OutputStream outputStream)
Saves the result PDF to stream.
save
in interface ISaveableFacade
save
in class SaveableFacade
outputStream
- Output PDF streampublic void modifyAnnotations(int start, int end, Annotation annotation)
Modifies the annotations of the specifed type on the specified page range. It supports to modify next annotation properties: Modified, Title, Contents, Color, Subject and Open.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); TextAnnotation annot = new TextAnnotation(); annot.setModified ( new Date()); annot.setTitle ( "NEW AUTHOR"); annot.setContents ( "NEW CONTENTS"); annot.setColor ( Color.RED); annot.setSubject ( "NEW SUBJECT"); annot.setOpen ( true); editor.modifyAnnotations(1, 2, annot); editor.save("example_out.pdf");
start
- The start page number.end
- The end page number.annotation
- The annotation object contains new properties.public void redactArea(int pageIndex, Rectangle rect, Color color)
Redacts area on the specified page. All contents is removed.
pageIndex
- Index of the page.rect
- Area rectangle.color
- Filling color.