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 |
exportAnnotationsXfdf(com.aspose.ms.System.IO.Stream 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");
Enum[] annotTypes = new Enum[] {AnnotationType.Text, AnnotationType.Highlight};
using (Stream stream = File.Create("example.xfdf"))
{
editor.exportAnnotationsXfdf(stream, 1, 2, annotTypes);
}
|
void |
exportAnnotationsXfdf(com.aspose.ms.System.IO.Stream xmlOutputStream,
int start,
int end,
String[] annotTypes)
Exports the content of the specified annotation types into XFDF
PdfAnnotationEditor editor = new PdfAnnotationEditor();
editor.bindPdf("example.pdf");
string[] annotTypes = new string[] {"Text", "Highlight"};
using (Stream stream = File.Create("example.xfdf"))
{
editor.exportAnnotationsXfdf(stream, 1, 2, annotTypes);
}
|
com.aspose.ms.System.Collections.IList |
extractAnnotations(int start,
int end,
int[] annotTypes)
Gets the list of annotations of the specified types.
|
com.aspose.ms.System.Collections.IList |
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(com.aspose.ms.System.IO.Stream xfdfSteam)
Imports all annotations from XFDF data stream.
|
void |
importAnnotationFromXfdf(com.aspose.ms.System.IO.Stream xfdfSteam,
int[] annotType)
Imports the specified annotations from XFDF data stream.
|
void |
importAnnotationFromXfdf(String xfdfFile)
Imports all annotations from XFDF file.
|
void |
importAnnotationFromXfdf(String xfdfFile,
int[] annotType)
Imports the specified annotations from XFDF file.
|
void |
importAnnotations(com.aspose.ms.System.IO.Stream[] annotFileInputStream)
Imports annotations into document from array of another PDF document streams.
|
void |
importAnnotations(com.aspose.ms.System.IO.Stream[] 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 |
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,
com.aspose.ms.System.Enum 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 |
save(OutputStream outputStream)
Saves the result PDF to stream.
|
void |
save(String outputFile)
Saves the result PDF to file.
|
save
public PdfAnnotationEditor()
Initializes new PdfAnnotationEditor
object.
public PdfAnnotationEditor(IDocument document)
Initializes new PdfAnnotationEditor
object on base of the document
.
document
- Pdf document.public 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 importAnnotationFromXfdf(String xfdfFile, int[] annotType)
Imports the specified annotations from XFDF file.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); Enum[] 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 importAnnotationFromXfdf(com.aspose.ms.System.IO.Stream xfdfSteam, int[] annotType)
Imports the specified annotations from XFDF data stream.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); Enum[] annotTypes ={ AnnotationType.Highlight, AnnotationType.Line }; editor.importAnnotationFromXfdf(File.OpenRead("annots.xfdf"), annotTypes); editor.save("example_out.pdf");
xfdfSteam
- The input XFDF data stream.annotType
- The array of annotation types to be imported.public void importAnnotationFromXfdf(com.aspose.ms.System.IO.Stream xfdfSteam)
Imports all annotations from XFDF data stream.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); editor.importAnnotationFromXfdf(File.OpenRead("annots.xfdf")); editor.save("example_out.pdf");
xfdfSteam
- 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"}; Enum[] 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(com.aspose.ms.System.IO.Stream[] annotFileInputStream, int[] annotType)
Imports the specified annotations into document from array of another PDF document streams.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); Stream[] streams = new FileInputStream[2]; stream[0]= File.OpenRead("with_annots1.pdf"); stream[1]= File.OpenRead("with_annots2.pdf"); Enum[] annotTypes = {AnnotationType.Highlight, AnnotationType.Text}; editor.importAnnotations(streams, annotTypes); editor.save("example_out.pdf"); stream[0].Close(); stream[1].Close();
annotFileInputStream
- The array of streams of PDF documents that contain source annotations.annotType
- The annotation types to be imported.public void importAnnotations(com.aspose.ms.System.IO.Stream[] annotFileInputStream)
Imports annotations into document from array of another PDF document streams.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); Stream[] streams = new FileInputStream[2]; streams[0]= File.OpenRead("with_annots1.pdf"); streams[1]= File.OpenRead("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, com.aspose.ms.System.Enum 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"); TextAnnotation annot = new TextAnnotation(); annot.setModified ( DateTime.Now) annot.setTitle ( "NEW AUTHOR"); annot.setContents ( "NEW CONTENTS)"; annot.setColor (Color.RED); annot.setSubject ( "NEW SUBJECT"); annot.setOpen ( true); editor.modifyAnnotations(1, 2, 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"); Enum[] 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(com.aspose.ms.System.IO.Stream xmlOutputStream, int start, int end, String[] annotTypes)
Exports the content of the specified annotation types into XFDF
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); string[] annotTypes = new string[] {"Text", "Highlight"}; using (Stream stream = File.Create("example.xfdf")) { editor.exportAnnotationsXfdf(stream, 1, 2, annotTypes); }
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 void exportAnnotationsXfdf(com.aspose.ms.System.IO.Stream 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"); Enum[] annotTypes = new Enum[] {AnnotationType.Text, AnnotationType.Highlight}; using (Stream stream = File.Create("example.xfdf")) { editor.exportAnnotationsXfdf(stream, 1, 2, annotTypes); }
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 com.aspose.ms.System.Collections.IList 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"}; IList annotList = 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 com.aspose.ms.System.Collections.IList extractAnnotations(int start, int end, int[] annotTypes)
Gets the list of annotations of the specified types.
PdfAnnotationEditor editor = new PdfAnnotationEditor(); editor.bindPdf("example.pdf"); Enum[] annotTypes = new Enum[] {AnnotationType.Text, AnnotationType.Highlight}; IList annotList = 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.Copyright © 2019 Aspose. All Rights Reserved.