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 added Examples/Resources/SampleFiles/sampleNew.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class Constants {
public static String ANNOTATED_IMPORT = getSampleFilePath("annotated_import.pdf");

public static String INPUT_DOC = getSampleFilePath("sample.docx");
public static String INPUT_NEW = getSampleFilePath("sampleNew.pdf");

private static String getSampleFilePath(String fileName) {
return PROJECT_PATH + SamplesPath + fileName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
import com.groupdocs.annotation.Annotator;
import com.groupdocs.annotation.examples.Constants;
import com.groupdocs.annotation.exception.GroupDocsException;
import com.groupdocs.annotation.options.pagepreview.PreviewFormats;
import com.groupdocs.annotation.options.pagepreview.CreatePageStream;
import com.groupdocs.annotation.options.pagepreview.PreviewFormats;
import com.groupdocs.annotation.options.pagepreview.PreviewOptions;
import com.groupdocs.annotation.options.pagepreview.PageStreamFactory;
import java.io.File;
import java.io.FileNotFoundException;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
Expand All @@ -21,7 +18,7 @@
public class GenerateDocumentPagesPreview {

public static void run() {
final Annotator annotator = new Annotator(Constants.INPUT);
final Annotator annotator = new Annotator(Constants.INPUT_NEW);

PreviewOptions previewOptions = new PreviewOptions(new CreatePageStream() {
@Override
Expand All @@ -37,6 +34,8 @@ public OutputStream invoke(int pageNumber) {
}
});

previewOptions.setResolution(50);

previewOptions.setPreviewFormat(PreviewFormats.PNG);

previewOptions.setPageNumbers(new int[]{1, 2});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

public class MinimalAnnotation {
public static void run() {
final Annotator annotator = new Annotator(Constants.INPUT_DOC);
String outputPath = Constants.getOutputFilePath("MinimalAnnotation", FilenameUtils.getExtension(Constants.INPUT_DOC));
final ArrowAnnotation arrowAnnotation = new ArrowAnnotation();
arrowAnnotation.setBox(new Rectangle(100, 100, 200, 200));
annotator.add(arrowAnnotation);
annotator.save(outputPath);
try(final Annotator annotator = new Annotator(Constants.INPUT_DOC)){
String outputPath = Constants.getOutputFilePath("MinimalAnnotation", FilenameUtils.getExtension(Constants.INPUT_DOC));
final ArrowAnnotation arrowAnnotation = new ArrowAnnotation();
arrowAnnotation.setBox(new Rectangle(100, 100, 200, 200));
annotator.add(arrowAnnotation);
annotator.save(outputPath);
}
}
}
45 changes: 11 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![GitHub release (latest by date)](https://img.shields.io/github/v/release/groupdocs-annotation/GroupDocs.Annotation-for-Java) ![GitHub all releases](https://img.shields.io/github/downloads/groupdocs-annotation/GroupDocs.Annotation-for-Java/total) ![GitHub](https://img.shields.io/github/license/groupdocs-annotation/GroupDocs.Annotation-for-Java)
![GitHub](https://img.shields.io/github/license/groupdocs-annotation/GroupDocs.Annotation-for-Java)

# Java Library for Document Annotation

Expand All @@ -22,7 +22,7 @@ Directory | Description
- Add or remove comments.
- Export annotated documents.
- [Generate document previews & thumbnails](https://docs.groupdocs.com/annotation/java/generate-document-pages-preview/).
- Load password protected documents.
- Load password-protected documents.
- Save annotated pages or pages by range.

## Annotation Objects
Expand All @@ -33,43 +33,20 @@ Directory | Description

## Get Started with GroupDocs.Annotation for Java

GroupDocs.Annotation for Java requires J2SE 7.0 (1.7), J2SE 8.0 (1.8) or above. Please install Java first if you do not have it already.
GroupDocs.Annotation for Java requires J2SE 8.0 (1.8) or above. Please install Java first if you do not have it already.

GroupDocs hosts all Java APIs on [GroupDocs Artifact Repository](https://artifact.groupdocs.com/webapp/#/artifacts/browse/tree/General/repo/com/groupdocs/groupdocs-annotation), so simply [configure](https://docs.groupdocs.com/annotation/java/installation/) your Maven project to fetch the dependencies automatically.

## Add Watermark Annotation
## Add Arrow Annotation

```java
String outputPath = Constants.getOutputFilePath("AddWatermarkAnnotation", FilenameUtils.getExtension(Constants.INPUT));
final Annotator annotator = new Annotator(Constants.INPUT);
try {
Reply reply1 = new Reply();
reply1.setComment("First comment");
reply1.setRepliedOn(Calendar.getInstance().getTime());
Reply reply2 = new Reply();
reply2.setComment("Second comment");
reply2.setRepliedOn(Calendar.getInstance().getTime());
java.util.List<Reply> replies = new ArrayList<Reply>();
replies.add(reply1);
replies.add(reply2);
WatermarkAnnotation watermark = new WatermarkAnnotation();
watermark.setAngle((double) 75);
watermark.setBox(new Rectangle(200, 200, 100, 50));
watermark.setCreatedOn(Calendar.getInstance().getTime());
watermark.setText("Watermark");
watermark.setFontColor(65535);
watermark.setFontSize((double) 12);
watermark.setMessage("This is watermark annotation");
watermark.setOpacity(0.7);
watermark.setPageNumber(0);
watermark.setReplies(replies);
annotator.add(watermark);
annotator.save(outputPath);
} finally {
if (annotator != null) {
annotator.dispose();
}
}
try(final Annotator annotator = new Annotator(Constants.INPUT_DOC)){
String outputPath = Constants.getOutputFilePath("MinimalAnnotation", FilenameUtils.getExtension(Constants.INPUT_DOC));
final ArrowAnnotation arrowAnnotation = new ArrowAnnotation();
arrowAnnotation.setBox(new Rectangle(100, 100, 200, 200));
annotator.add(arrowAnnotation);
annotator.save(outputPath);
}
```

[Home](https://www.groupdocs.com/) | [Product Page](https://products.groupdocs.com/annotation/java) | [Documentation](https://docs.groupdocs.com/annotation/java/) | [Demos](https://products.groupdocs.app/annotation/family) | [API Reference](https://apireference.groupdocs.com/java/annotation) | [Examples](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java/tree/master/Examples) | [Blog](https://blog.groupdocs.com/category/annotation/) | [Search](https://search.groupdocs.com/) | [Free Support](https://forum.groupdocs.com/c/annotation) | [Temporary License](https://purchase.groupdocs.com/temporary-license)