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
2 changes: 1 addition & 1 deletion Demos/Dropwizard/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@angular/platform-browser": "^8.2.4",
"@angular/platform-browser-dynamic": "^8.2.4",
"@angular/router": "^8.2.4",
"@groupdocs.examples.angular/annotation": "^0.8.54",
"@groupdocs.examples.angular/annotation": "^0.8.98",
"@nrwl/angular": "^8.12.11",
"common-components": "^1.0.5",
"core-js": "^2.6.11",
Expand Down
2 changes: 1 addition & 1 deletion Demos/Dropwizard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-annotation</artifactId>
<version>23.2</version>
<version>23.4</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
Expand Down
2 changes: 1 addition & 1 deletion Demos/Spring/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@angular/platform-browser": "^8.2.4",
"@angular/platform-browser-dynamic": "^8.2.4",
"@angular/router": "^8.2.4",
"@groupdocs.examples.angular/annotation": "^0.8.70",
"@groupdocs.examples.angular/annotation": "^0.8.98",
"@nrwl/angular": "^8.12.11",
"common-components": "^1.0.5",
"core-js": "^2.6.11",
Expand Down
2 changes: 1 addition & 1 deletion Demos/Spring/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-annotation</artifactId>
<version>23.2</version>
<version>23.4</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down
Binary file added Examples/Resources/SampleFiles/input.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion Examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-annotation</artifactId>
<version>23.2</version>
<version>23.4</version>
</dependency>
</dependencies>
<repositories>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.groupdocs.annotation.examples;

public class Constants {

public static String PROJECT_PATH = System.getProperty("user.dir");

public static final String LicensePath = "C:\\Conholdate.Total.Product.Family.lic";//GroupDocs.Total.Java.lic";
public static final String SamplesPath = "\\Resources\\SampleFiles\\";
public static final String OutputPath = "\\Resources\\Output\\";

public static String INPUT = getSampleFilePath("input.pdf");
public static String INPUT_PDF = getSampleFilePath("input.pdf");
public static String CLEAR = getSampleFilePath("clear.pdf");
public static String ANNOTATED_BIG = getSampleFilePath("annotated_big.pdf");
public static String ANNOTATED_WITH_REPLIES = getSampleFilePath("annotated_with_replies.pdf");
Expand All @@ -23,6 +22,8 @@ public class Constants {
public static String INPUT_DOC = getSampleFilePath("sample.docx");
public static String INPUT_NEW = getSampleFilePath("sampleNew.pdf");

public static String INPUT_CELL = getSampleFilePath("input.xlsx");

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 @@ -13,7 +13,7 @@
public class RunExamples {

public static void main(String[] args) throws IOException {
System.out.println("Open RunExamples.cs. \nIn Main() method uncomment the example that you want to run.");
System.out.println("Open RunExamples.java. \nIn Main() method uncomment the example that you want to run.");
System.out.println("=====================================================");

//NOTE: Please uncomment the example you want to try out
Expand All @@ -26,25 +26,31 @@ public static void main(String[] args) throws IOException {
GetSupportedFileFormats.run();

// Get file info
GetFileInfo.run();
GetFileInfo.run(Constants.INPUT_PDF);
GetFileInfo.run(Constants.INPUT_DOC);
GetFileInfo.run(Constants.INPUT_CELL);

// Extract annotations from document
// ExtractAnnotationsFromDocument.run();
ExtractAnnotationsFromDocument.run(Constants.INPUT_PDF);
// ExtractAnnotationsFromDocument.run(Constants.INPUT_DOC);
// ExtractAnnotationsFromDocument.run(Constants.INPUT_CELL);

// Remove annotation from document
// RemoveAnnotationFromDocument.run();

// Generate document pages preview
GenerateDocumentPagesPreview.run();
GenerateDocumentPagesPreview.run(Constants.INPUT_PDF);
// GenerateDocumentPagesPreview.run(Constants.INPUT_DOC);
// GenerateDocumentPagesPreview.run(Constants.INPUT_CELL);

// Saving specific page range
SavingSpecificPageRange.run();
SavingSpecificPageRange.run(Constants.INPUT_PDF);

// Saving only pages with annotations
SavingOnlyPagesWithAnnotations.run();
SavingOnlyPagesWithAnnotations.run(Constants.INPUT_PDF);

// Filtering annotation types
// FilteringAnnotationTypes.run();// - Unsupported exception
FilteringAnnotationTypes.run(Constants.INPUT_PDF);

// Add area annotation
AddAreaAnnotation.run();
Expand Down Expand Up @@ -128,6 +134,8 @@ public static void main(String[] args) throws IOException {
// LoadDocumentFromAzure.run();

MinimalAnnotation.run();

AddUserRole.run();

System.out.println();
System.out.println("All done.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,27 @@
*/
public class GenerateDocumentPagesPreview {

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

PreviewOptions previewOptions = new PreviewOptions(new CreatePageStream() {
@Override
public OutputStream invoke(int pageNumber) {
try {
//String OutputPath = "//Resources//Output/";
String fileName = Constants.getOutputFilePath("GenerateDocumentPagesPreview_"+pageNumber, "png");//OutputPath + "GenerateDocumentPagesPreview_"+pageNumber+".png";
OutputStream result = new FileOutputStream(fileName);
return result;
} catch (Exception ex) {
throw new GroupDocsException(ex);
public static void run(String inputFile) {
try(final Annotator annotator = new Annotator(inputFile)) {
PreviewOptions previewOptions = new PreviewOptions(new CreatePageStream() {
@Override
public OutputStream invoke(int pageNumber) {
try {
String fileName = Constants.getOutputFilePath("GenerateDocumentPagesPreview" + "_" + pageNumber, "png");
OutputStream result = new FileOutputStream(fileName);
return result;
} catch (Exception ex) {
throw new GroupDocsException(ex);
}
}
}
});
});

previewOptions.setResolution(50);
previewOptions.setResolution(85);
previewOptions.setPreviewFormat(PreviewFormats.PNG);
previewOptions.setPageNumbers(new int[]{1, 2});
annotator.getDocument().generatePreview(previewOptions);

previewOptions.setPreviewFormat(PreviewFormats.PNG);

previewOptions.setPageNumbers(new int[]{1, 2});
annotator.getDocument().generatePreview(previewOptions);

annotator.dispose();

System.out.println("\nDocument previews generated successfully.\nCheck output in " + Constants.OutputPath);
System.out.println("\nDocument previews generated successfully.\nCheck output in " + Constants.OutputPath);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class LoadPasswordProtectedDocuments {

public static void run() {
String outputPath = Constants.getOutputFilePath("LoadPasswordProtectedDocuments", FilenameUtils.getExtension(Constants.INPUT));
String outputPath = Constants.getOutputFilePath("LoadPasswordProtectedDocuments", FilenameUtils.getExtension(Constants.INPUT_PDF));

LoadOptions loadOptions = new LoadOptions();
loadOptions.setPassword("1234");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class LoadDocumentFromFtp {

public static void run() {
try {
String outputPath = Constants.getOutputFilePath("LoadDocumentFromFtp", FilenameUtils.getExtension(Constants.INPUT));
String outputPath = Constants.getOutputFilePath("LoadDocumentFromFtp", FilenameUtils.getExtension(Constants.INPUT_PDF));

String filePath = "sample.pdf";
String server = "localhost";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
public class LoadDocumentFromLocalDisk {

public static void run() {
String outputPath = Constants.getOutputFilePath("LoadDocumentFromLocalDisk", FilenameUtils.getExtension(Constants.INPUT));
String outputPath = Constants.getOutputFilePath("LoadDocumentFromLocalDisk", FilenameUtils.getExtension(Constants.INPUT_PDF));

final Annotator annotator = new Annotator(Constants.INPUT);
final Annotator annotator = new Annotator(Constants.INPUT_PDF);

AreaAnnotation area = new AreaAnnotation();
area.setBox(new Rectangle(100, 100, 100, 100));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ public class LoadDocumentFromStream {

public static void run() {
try {
String outputPath = Constants.getOutputFilePath("LoadDocumentFromStream", FilenameUtils.getExtension(Constants.INPUT));
String outputPath = Constants.getOutputFilePath("LoadDocumentFromStream", FilenameUtils.getExtension(Constants.INPUT_PDF));

InputStream stream = new FileInputStream(Constants.INPUT);
InputStream stream = new FileInputStream(Constants.INPUT_PDF);
final Annotator annotator = new Annotator(stream);

AreaAnnotation area = new AreaAnnotation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class LoadDocumentFromUrl {

public static void run() {
try {
String outputPath = Constants.getOutputFilePath("LoadDocumentFromUrl", FilenameUtils.getExtension(Constants.INPUT));
String outputPath = Constants.getOutputFilePath("LoadDocumentFromUrl", FilenameUtils.getExtension(Constants.INPUT_PDF));

String url = "https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java/raw/api-v2/Examples/Resources/SampleFiles/input.pdf?raw=true";
final Annotator annotator = new Annotator(new URL(url).openStream());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,29 @@
* </p>
*/
public class FilteringAnnotationTypes {
public static void run(String fileName) {
String outputPath = Constants.getOutputFilePath("FilteringAnnotationTypes", FilenameUtils.getExtension(fileName));

public static void run() {
String outputPath = Constants.getOutputFilePath("FilteringAnnotationTypes", FilenameUtils.getExtension(Constants.INPUT));

final Annotator annotator = new Annotator(Constants.ANNOTATED_BIG);
try {
try(final Annotator annotator = new Annotator(fileName)) {
AreaAnnotation area = new AreaAnnotation();
area.setBox(new Rectangle(100, 100, 100, 100));
area.setBackgroundColor(65535);
area.setPageNumber(1);

EllipseAnnotation ellipse = new EllipseAnnotation();
ellipse.setBox(new Rectangle(100, 100, 100, 100));
ellipse.setBackgroundColor(123456);
ellipse.setPageNumber(4);
List<AnnotationBase> annotations = new ArrayList<AnnotationBase>();
ellipse.setPageNumber(2);

List<AnnotationBase> annotations = new ArrayList<>();
annotations.add(area);
annotations.add(ellipse);
annotator.add(annotations);
SaveOptions saveOptions = new SaveOptions();
saveOptions.setAnnotationTypes(AnnotationType.ELLIPSE);
annotator.save(outputPath, saveOptions);
} finally {
if (annotator != null) {
annotator.dispose();
}

System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
}
System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,27 @@
* </p>
*/
public class SavingOnlyPagesWithAnnotations {
public static void run(String fileName) {
String outputPath = Constants.getOutputFilePath("SavingOnlyPagesWithAnnotations", FilenameUtils.getExtension(fileName));

public static void run() {
String outputPath = Constants.getOutputFilePath("SavingOnlyPagesWithAnnotations", FilenameUtils.getExtension(Constants.INPUT));
try(final Annotator annotator = new Annotator(fileName)) {
AreaAnnotation area = new AreaAnnotation();
area.setBox(new Rectangle(100, 100, 100, 100));
area.setBackgroundColor(65535);
area.setPageNumber(1);
EllipseAnnotation ellipse = new EllipseAnnotation();
ellipse.setBox(new Rectangle(100, 100, 100, 100));
ellipse.setBackgroundColor(123456);
ellipse.setPageNumber(2);
List<AnnotationBase> annotations = new ArrayList<AnnotationBase>();
annotations.add(area);
annotations.add(ellipse);
annotator.add(annotations);
SaveOptions saveOptions = new SaveOptions();
saveOptions.setOnlyAnnotatedPages(true);
annotator.save(outputPath, saveOptions);

final Annotator annotator = new Annotator(Constants.INPUT);

AreaAnnotation area = new AreaAnnotation();
area.setBox(new Rectangle(100, 100, 100, 100));
area.setBackgroundColor(65535);
area.setPageNumber(1);
EllipseAnnotation ellipse = new EllipseAnnotation();
ellipse.setBox(new Rectangle(100, 100, 100, 100));
ellipse.setBackgroundColor(123456);
ellipse.setPageNumber(2);
List<AnnotationBase> annotations = new ArrayList<AnnotationBase>();
annotations.add(area);
annotations.add(ellipse);
annotator.add(annotations);
SaveOptions saveOptions = new SaveOptions();
saveOptions.setOnlyAnnotatedPages(true);
annotator.save(outputPath, saveOptions);

annotator.dispose();

System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@
*/
public class SavingSpecificPageRange {

public static void run() {
String outputPath = Constants.getOutputFilePath("SavingSpecificPageRange", FilenameUtils.getExtension(Constants.INPUT));
public static void run(String inputFile) {
String outputPath = Constants.getOutputFilePath("SavingSpecificPageRange", FilenameUtils.getExtension(inputFile));

final Annotator annotator = new Annotator(Constants.INPUT);
try(final Annotator annotator = new Annotator(inputFile)) {
SaveOptions saveOptions = new SaveOptions();
saveOptions.setFirstPage(2);
saveOptions.setLastPage(4);
annotator.save(outputPath, saveOptions);

SaveOptions saveOptions = new SaveOptions();
saveOptions.setFirstPage(2);
saveOptions.setLastPage(4);
annotator.save(outputPath, saveOptions);

annotator.dispose();

System.out.println("\nDocument saved successfully.\nCheck output in {outputPath}.");
System.out.println("\nDocument saved successfully.\nCheck output in {outputPath}.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
public class AddReplies {

public static void run() {
String outputPath = Constants.getOutputFilePath("AddReplies", FilenameUtils.getExtension(Constants.INPUT));
String outputPath = Constants.getOutputFilePath("AddReplies", FilenameUtils.getExtension(Constants.INPUT_PDF));

final Annotator annotator = new Annotator(Constants.INPUT);
final Annotator annotator = new Annotator(Constants.INPUT_PDF);

User user1 = new User();
user1.setId(1);
Expand Down
Loading