diff --git a/Examples/Resources/SampleFiles/sampleNew.pdf b/Examples/Resources/SampleFiles/sampleNew.pdf new file mode 100644 index 0000000..ef4cae4 Binary files /dev/null and b/Examples/Resources/SampleFiles/sampleNew.pdf differ diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/Constants.java b/Examples/src/main/java/com/groupdocs/annotation/examples/Constants.java index 1ce50b5..34e6eb7 100644 --- a/Examples/src/main/java/com/groupdocs/annotation/examples/Constants.java +++ b/Examples/src/main/java/com/groupdocs/annotation/examples/Constants.java @@ -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; diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/GenerateDocumentPagesPreview.java b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/GenerateDocumentPagesPreview.java index 27cd456..1e42530 100644 --- a/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/GenerateDocumentPagesPreview.java +++ b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/GenerateDocumentPagesPreview.java @@ -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; /** @@ -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 @@ -37,6 +34,8 @@ public OutputStream invoke(int pageNumber) { } }); + previewOptions.setResolution(50); + previewOptions.setPreviewFormat(PreviewFormats.PNG); previewOptions.setPageNumbers(new int[]{1, 2}); diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/MinimalAnnotation.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/MinimalAnnotation.java index dd946db..0b79f76 100644 --- a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/MinimalAnnotation.java +++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/MinimalAnnotation.java @@ -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); + } } } diff --git a/README.md b/README.md index c13ef2e..8057bdd 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 replies = new ArrayList(); - 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)