Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
2 changes: 1 addition & 1 deletion Examples/GroupDocs.Annotation.Examples.Java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-annotation</artifactId>
<version>18.10</version>
<version>19.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<AnnotationInfo> annotations = new ArrayList<AnnotationInfo>();
// 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<Byte> typesToExport = new ArrayList<Byte>();
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down