diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/OutputFiles/annotated-text.pdf b/Examples/GroupDocs.Annotation.Examples.Java/Data/OutputFiles/annotated-text.pdf
new file mode 100644
index 0000000..f71424e
Binary files /dev/null and b/Examples/GroupDocs.Annotation.Examples.Java/Data/OutputFiles/annotated-text.pdf differ
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/OutputFiles/annotated.pdf b/Examples/GroupDocs.Annotation.Examples.Java/Data/OutputFiles/annotated.pdf
deleted file mode 100644
index b5fff29..0000000
Binary files a/Examples/GroupDocs.Annotation.Examples.Java/Data/OutputFiles/annotated.pdf and /dev/null differ
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/GroupDocs.annotation.documents.xml b/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/GroupDocs.annotation.documents.xml
deleted file mode 100644
index 486f7c4..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/GroupDocs.annotation.documents.xml
+++ /dev/null
@@ -1 +0,0 @@
-- 1sample.pdf062b626fe-8a77-4d97-86ce-c36ca742205d015458828101111
\ No newline at end of file
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/source.pdf b/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/source.pdf
new file mode 100644
index 0000000..7172262
Binary files /dev/null and b/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/source.pdf differ
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/pom.xml b/Examples/GroupDocs.Annotation.Examples.Java/pom.xml
index 96499cc..7c00928 100644
--- a/Examples/GroupDocs.Annotation.Examples.Java/pom.xml
+++ b/Examples/GroupDocs.Annotation.Examples.Java/pom.xml
@@ -18,7 +18,7 @@
com.groupdocs
groupdocs-annotation
- 18.10
+ 19.4
commons-io
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/EmailAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/EmailAnnotation.java
index 89ac389..7dd6d0d 100644
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/EmailAnnotation.java
+++ b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/EmailAnnotation.java
@@ -96,10 +96,11 @@ public static void differentAnnotationsForEmail(String fileName) throws Throwabl
InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
// Save result stream to file.
- try (OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "Annotated.eml")) { // "../../Annotated.eml"
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- }
+
+ OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "Annotated.eml");
+ System.out.println(result.available());
+ IOUtils.copy(result, fileStream);
+
//ExEnd:differentAnnotationsForEmail
}
}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/HtmlAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/HtmlAnnotation.java
index 52aaf45..106408a 100644
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/HtmlAnnotation.java
+++ b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/HtmlAnnotation.java
@@ -96,10 +96,11 @@ public static void createAnnotationForHtml(String fileName) throws Throwable, Th
InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
// Save result stream to file.
- try (OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "Annotated.html")) { // "../../Annotated.html"
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- }
+
+ OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "Annotated.html");
+ System.out.println(result.available());
+ IOUtils.copy(result, fileStream);
+
//ExEnd:createAnnotationForHtml
}
}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/ImagesAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/ImagesAnnotation.java
index 862ef87..02a2320 100644
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/ImagesAnnotation.java
+++ b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/ImagesAnnotation.java
@@ -169,11 +169,10 @@ public static void differentAnnotationsForImages(String fileName) throws Throwab
InputStream result = annotator.exportAnnotationsToDocument(cleanPresentation, annotations, DocumentType.Images);
- try (OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "Image-annotated.png")) {
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- }
+ OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "Image-annotated.png");
+ System.out.println(result.available());
+ IOUtils.copy(result, fileStream);
+
// ExEnd:differentAnnotationsForImages
}
@@ -340,7 +339,7 @@ public static void addWatermarkAnnotationInDiagrams(String fileName) throws Thro
watermarkAnnnotation.setFontColor(16711680);
watermarkAnnnotation.setFontFamily("Microsoft Sans Serif");
watermarkAnnnotation.setFontSize(17);
- watermarkAnnnotation.setOpacity(0.3);
+ //watermarkAnnnotation.setOpacity(0.3);
watermarkAnnnotation.setType(AnnotationType.Watermark);
annotations.add(watermarkAnnnotation);
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/MainClass.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/MainClass.java
index 8e9176e..d559060 100644
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/MainClass.java
+++ b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/MainClass.java
@@ -25,6 +25,9 @@ public static void main(String[] args) throws Throwable {
// PDFAnnotation.addDistanceAnnotationInPDF();
// PDFAnnotation.usersWithDifferentRights();
// PDFAnnotation.gettingTextCoordinates("sample.pdf");
+
+ // PDFAnnotation.exportAnnotationsUsingExportOption();
+
// Annotation in Cells
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/PDFAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/PDFAnnotation.java
index f86e012..e8fc29c 100644
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/PDFAnnotation.java
+++ b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/PDFAnnotation.java
@@ -24,6 +24,7 @@
import com.groupdocs.annotation.domain.RowData;
import com.groupdocs.annotation.domain.config.AnnotationConfig;
import com.groupdocs.annotation.domain.containers.DocumentInfoContainer;
+import com.groupdocs.annotation.domain.options.ExportOptions;
import com.groupdocs.annotation.domain.results.CreateAnnotationResult;
import com.groupdocs.annotation.domain.results.GetCollaboratorsResult;
import com.groupdocs.annotation.domain.results.SetCollaboratorsResult;
@@ -40,7 +41,7 @@ public class PDFAnnotation {
/*
* document name
*/
- public static String fileName = "sample.pdf";
+ public static String fileName = "source.pdf";
// region Working with Annotations in PDF
@@ -109,7 +110,7 @@ public static void addAreaAnnotationInPDF() {
areaAnnnotation.setPenColor(2222222);
areaAnnnotation.setPenStyle((byte) 1);
areaAnnnotation.setPenWidth((byte) 1);
- areaAnnnotation.setOpacity(0.5);
+ //areaAnnnotation.setOpacity(0.5);
areaAnnnotation.setType(AnnotationType.Area);
areaAnnnotation.setCreatorName("Anonym A.");
annotations.add(areaAnnnotation);
@@ -176,7 +177,7 @@ public static void addStrikeOutAnnotationInPDF() {
strikeoutAnnotation.setBox(new Rectangle(68, 154, 102, 9));
strikeoutAnnotation.setPageNumber(0);
strikeoutAnnotation.setPenColor(0);
- strikeoutAnnotation.setOpacity(0.5);
+ //strikeoutAnnotation.setOpacity(0.5);
strikeoutAnnotation.setType(AnnotationType.TextStrikeout);
strikeoutAnnotation.setCreatorName("Anonym A.");
annotations.add(strikeoutAnnotation);
@@ -453,7 +454,7 @@ public static void addUnderlineAnnotationInPDF() {
underlineAnnotation.setBox(new Rectangle(68f, 154f, 102f, 9f));
underlineAnnotation.setPageNumber(0);
underlineAnnotation.setPenColor(1201033);
- underlineAnnotation.setOpacity(0.5);
+ //underlineAnnotation.setOpacity(0.5);
underlineAnnotation.setType(AnnotationType.TextUnderline);
underlineAnnotation.setCreatorName("Anonym A.");
annotations.add(underlineAnnotation);
@@ -627,4 +628,53 @@ public static void gettingTextCoordinates(String fileName){
}
//ExEnd:gettingTextCoordinates
}
+
+ /*
+ * Export Annotations using ExportOptions
+ */
+ public static void exportAnnotationsUsingExportOption() {
+ //ExStart:exportAnnotationsUsingExportOption
+ try {
+ AnnotationConfig cfg = Utilities.getConfiguration();
+ AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
+ annotator.getDocumentDataHandler();
+ InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
+
+ List annotations = new ArrayList();
+ // text annotation
+ AnnotationInfo textAnnotation = new AnnotationInfo();
+ textAnnotation.setBox(new Rectangle(68, 154, 102, 9));
+ textAnnotation.setPageNumber(0);
+ textAnnotation.setType(AnnotationType.Text);
+ textAnnotation.setCreatorName("Anonym A.");
+ annotations.add(textAnnotation);
+
+ // export options
+ ExportOptions options = new ExportOptions();
+ options.setDocumentType(DocumentType.Pdf);
+
+ /** Export specific types of Annotations **/
+ List typesToExport = new ArrayList();
+ typesToExport.add(AnnotationType.Text);
+ options.setAnnotationTypes(typesToExport);
+
+ /** Export only pages with annotations **/
+ options.setAnnotatedPages(true);
+
+ /** Export page range **/
+ options.setFirstPage(0);
+ options.setLastPage(1);
+
+ // Add annotation to the document
+ InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, options);
+ // Save result stream to file.
+ OutputStream fileStream = new FileOutputStream(
+ Utilities.outputPath + File.separator + "annotated-text.pdf");
+ IOUtils.copy(result, fileStream);
+ } catch (Exception e) {
+ System.out.println("Exception :" + e.getMessage());
+ e.printStackTrace();
+ }
+ //ExEnd:exportAnnotationsUsingExportOption
+ }
}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/SlidesAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/SlidesAnnotation.java
index 17de2de..3001115 100644
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/SlidesAnnotation.java
+++ b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/SlidesAnnotation.java
@@ -177,10 +177,11 @@ public static void differentAnnotationsForSlides() throws Throwable{
annotations.add(underlineAnnotation);
InputStream result = annotator.exportAnnotationsToDocument(cleanPresentation, annotations, DocumentType.Slides);
- try (OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "slides-annotated.pptx")) {
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- }
+
+ OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "slides-annotated.pptx");
+ System.out.println(result.available());
+ IOUtils.copy(result, fileStream);
+
//ExEnd:differentAnnotationsForSlides
}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/WordsAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/WordsAnnotation.java
index 1776822..3292ce9 100644
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/WordsAnnotation.java
+++ b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/WordsAnnotation.java
@@ -493,7 +493,7 @@ public static void addWatermarkAnnotationInWords() {
watermarkAnnnotation.setFontColor(16711680);
watermarkAnnnotation.setFontFamily("Microsoft Sans Serif");
watermarkAnnnotation.setFontSize(17);
- watermarkAnnnotation.setOpacity(0.3);
+ //watermarkAnnnotation.setOpacity(0.3);
watermarkAnnnotation.setType(AnnotationType.Watermark);
annotations.add(watermarkAnnnotation);