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
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.groupdocs.annotation.examples.basic_usage.add_annotation_to_the_document;

import com.groupdocs.annotation.Annotator;
import com.groupdocs.annotation.examples.Constants;
import com.groupdocs.annotation.models.Rectangle;
import com.groupdocs.annotation.models.annotationmodels.ImageAnnotation;

public class AddImageAnnotation {
public static void run() {
try(final Annotator annotator = new Annotator(Constants.INPUT_PDF)){
ImageAnnotation imageAnnotation = new ImageAnnotation();
imageAnnotation.setBox(new Rectangle(100, 100, 100, 100));
imageAnnotation.setOpacity(0.7);
imageAnnotation.setPageNumber(0);
imageAnnotation.setImagePath("www.google.com.ua/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png");
imageAnnotation.setAngle(100.);
annotator.add(imageAnnotation);
annotator.save("result_image_annotation.pdf");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.groupdocs.annotation.examples.basic_usage.add_annotation_to_the_document;

import com.groupdocs.annotation.Annotator;
import com.groupdocs.annotation.examples.Constants;
import com.groupdocs.annotation.models.annotationmodels.SearchTextFragment;

public class AddSearchTextAnnotation {
public static void run() {
try(final Annotator annotator = new Annotator(Constants.INPUT_PDF)){
SearchTextFragment searchTextFragment = new SearchTextFragment();
searchTextFragment.setText("Welcome to GroupDocs");//If the document does not contain this text, nothing will be highlighted
searchTextFragment.setFontSize(10.);
searchTextFragment.setFontFamily("Calibri");
searchTextFragment.setFontColor(65535);
searchTextFragment.setBackgroundColor(16761035);
annotator.add(searchTextFragment);
annotator.save("result_add_search_text.pdf");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.groupdocs.annotation.examples.basic_usage.add_annotation_to_the_document;

import com.groupdocs.annotation.Annotator;
import com.groupdocs.annotation.examples.Constants;
import com.groupdocs.annotation.models.Point;
import com.groupdocs.annotation.models.Reply;
import com.groupdocs.annotation.models.annotationmodels.SquigglyAnnotation;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class AddSquigglyAnnotation {
public static void run() {
try(final Annotator annotator = new Annotator(Constants.INPUT_PDF)){
SquigglyAnnotation squigglyAnnotation = new SquigglyAnnotation();
squigglyAnnotation.setCreatedOn(new Date());
squigglyAnnotation.setFontColor(65535);
squigglyAnnotation.setBackgroundColor(16761035);
squigglyAnnotation.setMessage("This is squiggly annotation");
squigglyAnnotation.setOpacity(0.7);
squigglyAnnotation.setPageNumber(0);
squigglyAnnotation.setSquigglyColor(1422623);//Supported only Word and PDF
List points = new ArrayList<Point>();
points.add(new Point(80, 730));
points.add(new Point(240, 730));
points.add(new Point(80, 650));
points.add(new Point(240, 650));

Reply reply1 = new Reply();
reply1.setComment("First comment");
reply1.setRepliedOn(new Date());

Reply reply2 = new Reply();
reply2.setComment("Second comment");
reply2.setRepliedOn(new Date());

List<Reply> replies = new ArrayList<>();
replies.add(reply1);
replies.add(reply2);

squigglyAnnotation.setReplies(replies);

annotator.add(squigglyAnnotation);
annotator.save("result_squiggly_annotation.pdf");
}
}
}