diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..70ac879
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+/Examples/target
+/Examples/Resources/Output
+Examples/.classpath
+Examples/.project
+Examples/.settings/
+deploy_key
+
+#License files
+*.lic
diff --git a/Demos/Dropwizard/.gitignore b/Demos/Dropwizard/.gitignore
new file mode 100644
index 0000000..5fae568
--- /dev/null
+++ b/Demos/Dropwizard/.gitignore
@@ -0,0 +1,21 @@
+.idea/*
+*.iml
+*.ipr
+*.iws
+target/*
+.DS_Store
+vs.bin
+App_Data/*
+node_modules
+src/main/resources/assets/*
+!src/main/resources/assets/.gitkeep
+node/
+etc/
+package-lock.json
+Licenses/*
+!Licenses/.gitkeep
+DocumentSamples/*
+!DocumentSamples/.gitkeep
+
+#License files
+*.lic
diff --git a/Demos/Dropwizard/.travis.yml b/Demos/Dropwizard/.travis.yml
new file mode 100644
index 0000000..d996b1c
--- /dev/null
+++ b/Demos/Dropwizard/.travis.yml
@@ -0,0 +1,40 @@
+dist: trusty
+language: java
+jdk:
+- oraclejdk8
+- oraclejdk9
+- openjdk8
+#- oraclejdk11
+#- openjdk10
+#- openjdk11
+services:
+ - docker
+jobs:
+ include:
+ - stage: Coverage
+ jdk: oraclejdk8
+ script:
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
+ - chmod +x ./cc-test-reporter
+ - ./cc-test-reporter before-build
+ - mvn clean package
+ - JACOCO_SOURCE_PATH=src/main/java ./cc-test-reporter format-coverage target/site/jacoco/jacoco.xml --input-type jacoco
+ - ./cc-test-reporter upload-coverage
+ - stage: Tag Release
+ if: type = push AND branch = master AND commit_message !~ /^Travis bot released/
+ install: skip
+ script: git checkout master && git reset --hard $sha1 && git config --global push.followTags true && git config --global user.email "travis@travis-ci.org" && git config --global user.name "Travis CI" && export current_version=$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec) && echo "current version ${current_version}" && export minor=$(echo $current_version | sed "s/^[0-9]\{1,\}\.[0-9]\{1,\}\.\([0-9]\{1,\}\)/\1/") && export major=$(echo $current_version | sed "s/^\([0-9]\{1,\}\.[0-9]\{1,\}\)\.[0-9]\{1,\}/\1/") && export next_version=$major.$((minor+1)) && echo "next version ${next_version}" && sed -i.bak "s/$current_version/$next_version/g" README.md && rm README.md.bak && sed -i.bak "s/^ $current_version<\\/version>/ $next_version<\\/version>/g" pom.xml && rm pom.xml.bak && git status && git commit -am "Travis bot released $next_version" && git tag -a $next_version -m "Automated release" && git remote add target https://${GH_TOKEN}@github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java-Dropwizard.git > /dev/null 2>&1 && git remote -v && git push --set-upstream target master
+ - stage: Release
+ if: type = push AND branch = master AND commit_message =~ /^Travis bot released/
+ install: skip
+ jdk: oraclejdk8
+ script: mvn -B clean package && mkdir -p target/release/DocumentSamples && mkdir -p target/release/Licenses && cp target/annotation-*.jar target/release && cp configuration.yml target/release && cd target && tar -zcvf release.tar.gz release && cd ..
+ deploy:
+ provider: releases
+ overwrite: true
+ skip_cleanup: true
+ api_key: $GH_TOKEN
+ file: target/release.tar.gz
+ on:
+ repo: groupdocs-annotation/GroupDocs.Annotation-for-Java-Dropwizard
+ branch: master
\ No newline at end of file
diff --git a/Demos/Dropwizard/Dockerfile b/Demos/Dropwizard/Dockerfile
new file mode 100644
index 0000000..7dc548a
--- /dev/null
+++ b/Demos/Dropwizard/Dockerfile
@@ -0,0 +1,15 @@
+FROM openjdk:18-jdk-bullseye
+RUN mkdir -p /app
+
+RUN apt-get update && \
+ apt-get install -y fontconfig && \
+ fc-cache -f
+
+WORKDIR /app
+COPY /DocumentSamples /app
+COPY /Licenses /app
+COPY /target/annotation-*.jar /app/app.jar
+
+EXPOSE 8080
+
+ENTRYPOINT java -jar /app/app.jar configuration.yml
\ No newline at end of file
diff --git a/Demos/Dropwizard/DocumentSamples/.gitkeep b/Demos/Dropwizard/DocumentSamples/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Dropwizard/LICENSE b/Demos/Dropwizard/LICENSE
new file mode 100644
index 0000000..af0a3df
--- /dev/null
+++ b/Demos/Dropwizard/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2001-2018 Aspose Pty Ltd
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Demos/Dropwizard/Licenses/.gitkeep b/Demos/Dropwizard/Licenses/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Dropwizard/README.md b/Demos/Dropwizard/README.md
new file mode 100644
index 0000000..e3373ba
--- /dev/null
+++ b/Demos/Dropwizard/README.md
@@ -0,0 +1,170 @@
+
+# GroupDocs.Annotation for Java Dropwizard Example
+###### version 1.12.26
+
+[](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java-Dropwizard/blob/master/LICENSE)
+
+## System Requirements
+- Java 8 (JDK 1.8)
+- Maven 3
+
+
+## Annotate & write on document with Java Dropwizard
+
+**GroupDocs.Annotations for Java** is a powerful library that provides flexible API which allows you to **annotate PDF**, DOCX, PPT, XLS, and over 90 document formats without external dependencies and/or additional document conversions such us (DOCX to PDF or PPT to PDF). With GroupDocs.Annotation API you can write on documents using various annotation tools such as arrow annotation, text annotation or even draw on a document with help of freehand annotation drawing tool.
+
+With GroupDocs.Annotation for Java Dropwizard application, you can annotate and **write on document** using our modern and responsive web UI interface. Thanks to flexible and highly customizable configuration it can be used as standalone application or can be integrated into your project within few simple steps.
+
+
+**Note:** without a license application will run in trial mode, purchase [GroupDocs.Annotation for Java license](https://purchase.groupdocs.com/buy) or request [GroupDocs.Annotation for Java temporary license](https://purchase.groupdocs.com/temporary-license/).
+
+
+## Demo Video
+
+
+
+
+
+
+
+
+## Features
+
+
+
+ Text annotation
+
Add text annotations in any document. Specify font size, set colors, add comments and collaborate.
+
+
+
+
+
+
+ Freehand Drawing
+
Draw on a document using a freehand drawing tool. Easily highlight specific areas on your document page.
+
+
+
+
+
+
+ Blackout & Redaction
+
Blackout and redact sensitive or personally identifiable information on your document.
+
+
+
+
+
+
+ Comments
+
Collaborate and comment on any annotation. Start a discussion right in a document without database dependency/integration.
+
+
+
+
+### More features
+
+- Clean, modern and intuitive design
+- Easily switchable colour theme (create your own colour theme in 5 minutes)
+- Responsive design
+- Mobile support (open application on any mobile device)
+- Support over 50 documents and image formats
+- Image mode
+- Fully customizable navigation panel
+- Annotate password protected documents
+- Download original documents
+- Download annotated documents
+- Upload documents
+- Annotate document with such annotation types:
+ * **Text** – highlights and comments selected text
+ * **Area** – marks an area with a rectangle and adds notes to it
+ * **Point** – sticks comments to any point in a document
+ * **TextStrikeout** – marks text with a strikethrough styling
+ * **Polyline** – draws shapes and freehand lines
+ * **TextField** – adds rectangle with a text inside
+ * **Watermark** - Horizontal textual watermark
+ * **TextReplacement** – replaces original text with user’s text
+ * **Arrow** – draws an arrow on a document
+ * **TextRedaction** – fills black rectangle with fixed position (used if you want to hide some text)
+ * **ResourcesRedaction** – fills black rectangle with fixed position
+ * **TextUnderline** – marks text with a underline styling
+ * **Distance** – measures a distance between objects in a document
+- Draw annotation over the document page
+- Add comment or reply
+- Print document
+- Smooth page navigation
+- Smooth document scrolling
+- Preload pages for faster document rendering
+- Multi-language support for displaying errors
+- Cross-browser support (Safari, Chrome, Opera, Firefox)
+- Cross-platform support (Windows, Linux, MacOS)
+
+
+## How to run
+
+You can run this sample by one of following methods
+
+
+#### Build from source
+
+Download [source code](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java-Dropwizard/archive/master.zip) from github or clone this repository.
+
+```bash
+git clone https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java/
+cd /Demos/Dropwizard
+mvn clean compile exec:java
+## Open http://localhost:8080/annotation/ in your favorite browser.
+```
+
+#### Docker image
+Use [docker](https://hub.docker.com/u/groupdocs) image.
+
+```bash
+mkdir DocumentSamples
+mkdir Licenses
+docker run -p 8080:8080 --env application.hostAddress=localhost -v `pwd`/DocumentSamples:/home/groupdocs/app/DocumentSamples -v `pwd`/Licenses:/home/groupdocs/app/Licenses groupdocs/annotation-dropwizard
+## Open http://localhost:8080/annotation/ in your favorite browser.
+```
+
+## Configuration
+For all methods above you can adjust settings in `configuration.yml`. By default in this sample will lookup for license file in `./Licenses` folder, so you can simply put your license file in that folder or specify relative/absolute path by setting `licensePath` value in `configuration.yml`.
+
+### Annotation configuration options
+
+| Option | Type | Default value | Description |
+| ---------------------------------- | ------- |:-----------------:|:-------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`filesDirectory`** | String | `DocumentSamples` | Files directory path. Indicates where uploaded and predefined files are stored. It can be absolute or relative path |
+| **`fontsDirectory`** | String | | Path to custom fonts directory. |
+| **`defaultDocument`** | String | | Absolute path to default document that will be loaded automaticaly. |
+| **`preloadPageCount`** | Integer | `0` | Indicate how many pages from a document should be loaded, remaining pages will be loaded on page scrolling.Set `0` to load all pages at once |
+| **`textAnnotation`** | Boolean | `true` | Enable/disable Text annotation |
+| **`areaAnnotation`** | Boolean | `true` | Enable/disable Area annotation |
+| **`areaAnnotation`** | Boolean | `true` | Enable/disable Point annotation |
+| **`pointAnnotation`** | Boolean | `true` | Enable thumbnails preview |
+| **`textStrikeoutAnnotation`** | Boolean | `true` | Enable/disable TextStrikeout annotation |
+| **`polylineAnnotation`** | Boolean | `true` | Enable/disable Polyline annotation |
+| **`textFieldAnnotation`** | Boolean | `true` | Enable/disable TextField annotation |
+| **`watermarkAnnotation`** | Boolean | `true` | Enable/disable Watermark annotation |
+| **`textReplacementAnnotation`** | Boolean | `true` | Enable/disable TextReplacement annotation |
+| **`arrowAnnotation`** | Boolean | `true` | Enable/disable Arrow annotation |
+| **`textRedactionAnnotation`** | Boolean | `true` | Enable/disable TextRedaction annotation |
+| **`resourcesRedactionAnnotation`** | Boolean | `true` | Enable/disable ResourcesRedaction annotation |
+| **`textUnderlineAnnotation`** | Boolean | `true` | Enable/disable TextUnderline annotation |
+| **`distanceAnnotation`** | Boolean | `true` | Enable/disable Distance annotation |
+| **`downloadOriginal`** | Boolean | `true` | Enable/disable original document downloading |
+| **`downloadAnnotated`** | Boolean | `true` | Enable/disable signed document downloading |
+| **`zoom`** | Boolean | `true` | Enable/disable zoom |
+| **`fitWidth`** | Boolean | `true` | Enable/disable fit width. Set true to zoom document pages fit width |
+
+## License
+The MIT License (MIT).
+
+Please have a look at the LICENSE.md for more details
+
+## GroupDocs Annotation on other platforms & frameworks
+
+- JAVA Spring [Document & PDF annotator](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java/tree/master/Demos/Spring)
+- .NET MVC [Document & PDF annotator](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-.NET/tree/master/Demos)
+- .NET WebForms [Document & PDF annotator](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-.NET/tree/master/Demos)
+
+[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/) | [Free Support](https://forum.groupdocs.com/c/annotation) | [Temporary License](https://purchase.groupdocs.com/temporary-license)
diff --git a/Demos/Dropwizard/client/.editorconfig b/Demos/Dropwizard/client/.editorconfig
new file mode 100644
index 0000000..6e87a00
--- /dev/null
+++ b/Demos/Dropwizard/client/.editorconfig
@@ -0,0 +1,13 @@
+# Editor configuration, see http://editorconfig.org
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 2
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+max_line_length = off
+trim_trailing_whitespace = false
diff --git a/Demos/Dropwizard/client/.gitignore b/Demos/Dropwizard/client/.gitignore
new file mode 100644
index 0000000..ee5c9d8
--- /dev/null
+++ b/Demos/Dropwizard/client/.gitignore
@@ -0,0 +1,39 @@
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+
+# compiled output
+/dist
+/tmp
+/out-tsc
+
+# dependencies
+/node_modules
+
+# IDEs and editors
+/.idea
+.project
+.classpath
+.c9/
+*.launch
+.settings/
+*.sublime-workspace
+
+# IDE - VSCode
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+
+# misc
+/.sass-cache
+/connect.lock
+/coverage
+/libpeerconnection.log
+npm-debug.log
+yarn-error.log
+testem.log
+/typings
+
+# System Files
+.DS_Store
+Thumbs.db
diff --git a/Demos/Dropwizard/client/.prettierignore b/Demos/Dropwizard/client/.prettierignore
new file mode 100644
index 0000000..d0b804d
--- /dev/null
+++ b/Demos/Dropwizard/client/.prettierignore
@@ -0,0 +1,4 @@
+# Add files here to ignore them from prettier formatting
+
+/dist
+/coverage
diff --git a/Demos/Dropwizard/client/.prettierrc b/Demos/Dropwizard/client/.prettierrc
new file mode 100644
index 0000000..544138b
--- /dev/null
+++ b/Demos/Dropwizard/client/.prettierrc
@@ -0,0 +1,3 @@
+{
+ "singleQuote": true
+}
diff --git a/Demos/Dropwizard/client/.vscode/extensions.json b/Demos/Dropwizard/client/.vscode/extensions.json
new file mode 100644
index 0000000..7804e26
--- /dev/null
+++ b/Demos/Dropwizard/client/.vscode/extensions.json
@@ -0,0 +1,8 @@
+{
+ "recommendations": [
+ "nrwl.angular-console",
+ "angular.ng-template",
+ "ms-vscode.vscode-typescript-tslint-plugin",
+ "esbenp.prettier-vscode"
+ ]
+}
diff --git a/Demos/Dropwizard/client/README.md b/Demos/Dropwizard/client/README.md
new file mode 100644
index 0000000..8337f8c
--- /dev/null
+++ b/Demos/Dropwizard/client/README.md
@@ -0,0 +1,84 @@
+# Client
+
+This project was generated using [Nx](https://nx.dev).
+
+
+
+🔎 **Nx is a set of Extensible Dev Tools for Monorepos.**
+
+## Quick Start & Documentation
+
+[Nx Documentation](https://nx.dev/angular)
+
+[10-minute video showing all Nx features](https://nx.dev/angular/getting-started/what-is-nx)
+
+[Interactive Tutorial](https://nx.dev/angular/tutorial/01-create-application)
+
+## Adding capabilities to your workspace
+
+Nx supports many plugins which add capabilities for developing different types of applications and different tools.
+
+These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects as well.
+
+Below are some plugins which you can add to your workspace:
+
+- [Angular](https://angular.io)
+ - `ng add @nrwl/angular`
+- [React](https://reactjs.org)
+ - `ng add @nrwl/react`
+- Web (no framework frontends)
+ - `ng add @nrwl/web`
+- [Nest](https://nestjs.com)
+ - `ng add @nrwl/nest`
+- [Express](https://expressjs.com)
+ - `ng add @nrwl/express`
+- [Node](https://nodejs.org)
+ - `ng add @nrwl/node`
+
+## Generate an application
+
+Run `ng g @nrwl/angular:app my-app` to generate an application.
+
+> You can use any of the plugins above to generate applications as well.
+
+When using Nx, you can create multiple applications and libraries in the same workspace.
+
+## Generate a library
+
+Run `ng g @nrwl/angular:lib my-lib` to generate a library.
+
+> You can also use any of the plugins above to generate libraries as well.
+
+Libraries are sharable across libraries and applications. They can be imported from `@client/mylib`.
+
+## Development server
+
+Run `ng serve my-app` for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
+
+## Code scaffolding
+
+Run `ng g component my-component --project=my-app` to generate a new component.
+
+## Build
+
+Run `ng build my-app` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
+
+## Running unit tests
+
+Run `ng test my-app` to execute the unit tests via [Jest](https://jestjs.io).
+
+Run `nx affected:test` to execute the unit tests affected by a change.
+
+## Running end-to-end tests
+
+Run `ng e2e my-app` to execute the end-to-end tests via [Cypress](https://www.cypress.io).
+
+Run `nx affected:e2e` to execute the end-to-end tests affected by a change.
+
+## Understand your workspace
+
+Run `nx dep-graph` to see a diagram of the dependencies of your projects.
+
+## Further help
+
+Visit the [Nx Documentation](https://nx.dev/angular) to learn more.
diff --git a/Demos/Dropwizard/client/angular.json b/Demos/Dropwizard/client/angular.json
new file mode 100644
index 0000000..34f7f04
--- /dev/null
+++ b/Demos/Dropwizard/client/angular.json
@@ -0,0 +1,140 @@
+{
+ "version": 1,
+ "projects": {
+ "annotation": {
+ "projectType": "application",
+ "schematics": {
+ "@nrwl/angular:component": {
+ "style": "less"
+ }
+ },
+ "root": "apps/annotation",
+ "sourceRoot": "apps/annotation/src",
+ "prefix": "client",
+ "architect": {
+ "build": {
+ "builder": "@angular-devkit/build-angular:browser",
+ "options": {
+ "outputPath": "../src/main/resources/assets/angular/annotation",
+ "index": "apps/annotation/src/index.html",
+ "main": "apps/annotation/src/main.ts",
+ "polyfills": "apps/annotation/src/polyfills.ts",
+ "tsConfig": "apps/annotation/tsconfig.app.json",
+ "aot": true,
+ "assets": [
+ "apps/annotation/src/favicon.ico",
+ "apps/annotation/src/assets"
+ ],
+ "styles": ["apps/annotation/src/styles.less"],
+ "scripts": []
+ },
+ "configurations": {
+ "production": {
+ "fileReplacements": [
+ {
+ "replace": "apps/annotation/src/environments/environment.ts",
+ "with": "apps/annotation/src/environments/environment.prod.ts"
+ }
+ ],
+ "optimization": true,
+ "outputHashing": "all",
+ "sourceMap": false,
+ "extractCss": true,
+ "namedChunks": false,
+ "extractLicenses": true,
+ "vendorChunk": false,
+ "buildOptimizer": true,
+ "budgets": [
+ {
+ "type": "initial",
+ "maximumWarning": "2mb",
+ "maximumError": "5mb"
+ },
+ {
+ "type": "anyComponentStyle",
+ "maximumWarning": "6kb",
+ "maximumError": "10kb"
+ }
+ ]
+ }
+ }
+ },
+ "serve": {
+ "builder": "@angular-devkit/build-angular:dev-server",
+ "options": {
+ "browserTarget": "annotation:build"
+ },
+ "configurations": {
+ "production": {
+ "browserTarget": "annotation:build:production"
+ }
+ }
+ },
+ "extract-i18n": {
+ "builder": "@angular-devkit/build-angular:extract-i18n",
+ "options": {
+ "browserTarget": "annotation:build"
+ }
+ },
+ "lint": {
+ "builder": "@angular-devkit/build-angular:tslint",
+ "options": {
+ "tsConfig": [
+ "apps/annotation/tsconfig.app.json",
+ "apps/annotation/tsconfig.spec.json"
+ ],
+ "exclude": ["**/node_modules/**", "!apps/annotation/**"]
+ }
+ },
+ "test": {
+ "builder": "@nrwl/jest:jest",
+ "options": {
+ "jestConfig": "apps/annotation/jest.config.js",
+ "tsConfig": "apps/annotation/tsconfig.spec.json",
+ "setupFile": "apps/annotation/src/test-setup.ts"
+ }
+ }
+ }
+ },
+ "annotation-e2e": {
+ "root": "apps/annotation-e2e",
+ "sourceRoot": "apps/annotation-e2e/src",
+ "projectType": "application",
+ "architect": {
+ "e2e": {
+ "builder": "@nrwl/cypress:cypress",
+ "options": {
+ "cypressConfig": "apps/annotation-e2e/cypress.json",
+ "tsConfig": "apps/annotation-e2e/tsconfig.e2e.json",
+ "devServerTarget": "annotation:serve"
+ },
+ "configurations": {
+ "production": {
+ "devServerTarget": "annotation:serve:production"
+ }
+ }
+ },
+ "lint": {
+ "builder": "@angular-devkit/build-angular:tslint",
+ "options": {
+ "tsConfig": ["apps/annotation-e2e/tsconfig.e2e.json"],
+ "exclude": ["**/node_modules/**", "!apps/annotation-e2e/**"]
+ }
+ }
+ }
+ }
+ },
+ "cli": {
+ "defaultCollection": "@nrwl/angular"
+ },
+ "schematics": {
+ "@nrwl/angular:application": {
+ "unitTestRunner": "jest",
+ "e2eTestRunner": "cypress"
+ },
+ "@nrwl/angular:library": {
+ "unitTestRunner": "jest"
+ }
+ },
+ "defaultProject": "annotation"
+}
diff --git a/Demos/Dropwizard/client/apps/.gitkeep b/Demos/Dropwizard/client/apps/.gitkeep
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/.gitkeep
@@ -0,0 +1 @@
+
diff --git a/Demos/Dropwizard/client/apps/annotation-e2e/cypress.json b/Demos/Dropwizard/client/apps/annotation-e2e/cypress.json
new file mode 100644
index 0000000..156cb77
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation-e2e/cypress.json
@@ -0,0 +1,12 @@
+{
+ "fileServerFolder": ".",
+ "fixturesFolder": "./src/fixtures",
+ "integrationFolder": "./src/integration",
+ "modifyObstructiveCode": false,
+ "pluginsFile": "./src/plugins/index",
+ "supportFile": "./src/support/index.ts",
+ "video": true,
+ "videosFolder": "../../dist/cypress/apps/annotation-e2e/videos",
+ "screenshotsFolder": "../../dist/cypress/apps/annotation-e2e/screenshots",
+ "chromeWebSecurity": false
+}
diff --git a/Demos/Dropwizard/client/apps/annotation-e2e/src/fixtures/example.json b/Demos/Dropwizard/client/apps/annotation-e2e/src/fixtures/example.json
new file mode 100644
index 0000000..294cbed
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation-e2e/src/fixtures/example.json
@@ -0,0 +1,4 @@
+{
+ "name": "Using fixtures to represent data",
+ "email": "hello@cypress.io"
+}
diff --git a/Demos/Dropwizard/client/apps/annotation-e2e/src/integration/app.spec.ts b/Demos/Dropwizard/client/apps/annotation-e2e/src/integration/app.spec.ts
new file mode 100644
index 0000000..e75549a
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation-e2e/src/integration/app.spec.ts
@@ -0,0 +1,13 @@
+import { getGreeting } from '../support/app.po';
+
+describe('annotation', () => {
+ beforeEach(() => cy.visit('/'));
+
+ it('should display welcome message', () => {
+ // Custom command example, see `../support/commands.ts` file
+ cy.login('my-email@something.com', 'myPassword');
+
+ // Function helper example, see `../support/app.po.ts` file
+ getGreeting().contains('Welcome to annotation!');
+ });
+});
diff --git a/Demos/Dropwizard/client/apps/annotation-e2e/src/plugins/index.js b/Demos/Dropwizard/client/apps/annotation-e2e/src/plugins/index.js
new file mode 100644
index 0000000..9067e75
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation-e2e/src/plugins/index.js
@@ -0,0 +1,22 @@
+// ***********************************************************
+// This example plugins/index.js can be used to load plugins
+//
+// You can change the location of this file or turn off loading
+// the plugins file with the 'pluginsFile' configuration option.
+//
+// You can read more here:
+// https://on.cypress.io/plugins-guide
+// ***********************************************************
+
+// This function is called when a project is opened or re-opened (e.g. due to
+// the project's config changing)
+
+const { preprocessTypescript } = require('@nrwl/cypress/plugins/preprocessor');
+
+module.exports = (on, config) => {
+ // `on` is used to hook into various events Cypress emits
+ // `config` is the resolved Cypress config
+
+ // Preprocess Typescript file using Nx helper
+ on('file:preprocessor', preprocessTypescript(config));
+};
diff --git a/Demos/Dropwizard/client/apps/annotation-e2e/src/support/app.po.ts b/Demos/Dropwizard/client/apps/annotation-e2e/src/support/app.po.ts
new file mode 100644
index 0000000..3293424
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation-e2e/src/support/app.po.ts
@@ -0,0 +1 @@
+export const getGreeting = () => cy.get('h1');
diff --git a/Demos/Dropwizard/client/apps/annotation-e2e/src/support/commands.ts b/Demos/Dropwizard/client/apps/annotation-e2e/src/support/commands.ts
new file mode 100644
index 0000000..61b3a3e
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation-e2e/src/support/commands.ts
@@ -0,0 +1,31 @@
+// ***********************************************
+// This example commands.js shows you how to
+// create various custom commands and overwrite
+// existing commands.
+//
+// For more comprehensive examples of custom
+// commands please read more here:
+// https://on.cypress.io/custom-commands
+// ***********************************************
+// eslint-disable-next-line @typescript-eslint/no-namespace
+declare namespace Cypress {
+ interface Chainable {
+ login(email: string, password: string): void;
+ }
+}
+//
+// -- This is a parent command --
+Cypress.Commands.add('login', (email, password) => {
+ console.log('Custom command example: Login', email, password);
+});
+//
+// -- This is a child command --
+// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
+//
+//
+// -- This is a dual command --
+// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
+//
+//
+// -- This will overwrite an existing command --
+// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
diff --git a/Demos/Dropwizard/client/apps/annotation-e2e/src/support/index.ts b/Demos/Dropwizard/client/apps/annotation-e2e/src/support/index.ts
new file mode 100644
index 0000000..3d469a6
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation-e2e/src/support/index.ts
@@ -0,0 +1,17 @@
+// ***********************************************************
+// This example support/index.js is processed and
+// loaded automatically before your test files.
+//
+// This is a great place to put global configuration and
+// behavior that modifies Cypress.
+//
+// You can change the location of this file or turn off
+// automatically serving support files with the
+// 'supportFile' configuration option.
+//
+// You can read more here:
+// https://on.cypress.io/configuration
+// ***********************************************************
+
+// Import commands.js using ES2015 syntax:
+import './commands';
diff --git a/Demos/Dropwizard/client/apps/annotation-e2e/tsconfig.e2e.json b/Demos/Dropwizard/client/apps/annotation-e2e/tsconfig.e2e.json
new file mode 100644
index 0000000..824748b
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation-e2e/tsconfig.e2e.json
@@ -0,0 +1,8 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "sourceMap": false,
+ "outDir": "../../dist/out-tsc"
+ },
+ "include": ["src/**/*.ts", "src/**/*.js"]
+}
diff --git a/Demos/Dropwizard/client/apps/annotation-e2e/tsconfig.json b/Demos/Dropwizard/client/apps/annotation-e2e/tsconfig.json
new file mode 100644
index 0000000..d8d4ea3
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation-e2e/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "types": ["cypress", "node"]
+ },
+ "include": ["**/*.ts", "**/*.js"]
+}
diff --git a/Demos/Dropwizard/client/apps/annotation-e2e/tslint.json b/Demos/Dropwizard/client/apps/annotation-e2e/tslint.json
new file mode 100644
index 0000000..8acd9a3
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation-e2e/tslint.json
@@ -0,0 +1 @@
+{ "extends": "../../tslint.json", "rules": {} }
diff --git a/Demos/Dropwizard/client/apps/annotation/browserslist b/Demos/Dropwizard/client/apps/annotation/browserslist
new file mode 100644
index 0000000..8084853
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/browserslist
@@ -0,0 +1,12 @@
+# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
+# For additional information regarding the format and rule options, please see:
+# https://github.com/browserslist/browserslist#queries
+
+# You can see what browsers were selected by your queries by running:
+# npx browserslist
+
+> 0.5%
+last 2 versions
+Firefox ESR
+not dead
+not IE 9-11 # For IE 9-11 support, remove 'not'.
\ No newline at end of file
diff --git a/Demos/Dropwizard/client/apps/annotation/jest.config.js b/Demos/Dropwizard/client/apps/annotation/jest.config.js
new file mode 100644
index 0000000..dd90dfa
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/jest.config.js
@@ -0,0 +1,10 @@
+module.exports = {
+ name: 'annotation',
+ preset: '../../jest.config.js',
+ coverageDirectory: '../../coverage/apps/annotation',
+ snapshotSerializers: [
+ 'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js',
+ 'jest-preset-angular/build/AngularSnapshotSerializer.js',
+ 'jest-preset-angular/build/HTMLCommentSerializer.js'
+ ]
+};
diff --git a/Demos/Dropwizard/client/apps/annotation/src/app/app.component.html b/Demos/Dropwizard/client/apps/annotation/src/app/app.component.html
new file mode 100644
index 0000000..557d7ad
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/src/app/app.component.html
@@ -0,0 +1 @@
+
diff --git a/Demos/Dropwizard/client/apps/annotation/src/app/app.component.less b/Demos/Dropwizard/client/apps/annotation/src/app/app.component.less
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Dropwizard/client/apps/annotation/src/app/app.component.spec.ts b/Demos/Dropwizard/client/apps/annotation/src/app/app.component.spec.ts
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Dropwizard/client/apps/annotation/src/app/app.component.ts b/Demos/Dropwizard/client/apps/annotation/src/app/app.component.ts
new file mode 100644
index 0000000..e6fb213
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/src/app/app.component.ts
@@ -0,0 +1,10 @@
+import { Component } from '@angular/core';
+
+@Component({
+ selector: 'client-root',
+ templateUrl: './app.component.html',
+ styleUrls: ['./app.component.less']
+})
+export class AppComponent {
+ title = 'annotation';
+}
diff --git a/Demos/Dropwizard/client/apps/annotation/src/app/app.module.ts b/Demos/Dropwizard/client/apps/annotation/src/app/app.module.ts
new file mode 100644
index 0000000..32e6832
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/src/app/app.module.ts
@@ -0,0 +1,16 @@
+import {BrowserModule} from '@angular/platform-browser';
+import {NgModule} from '@angular/core';
+
+import {AppComponent} from './app.component';
+import {AnnotationModule} from "@groupdocs.examples.angular/annotation";
+
+import { TranslateModule } from '@ngx-translate/core';
+
+@NgModule({
+ declarations: [AppComponent],
+ imports: [BrowserModule, AnnotationModule, TranslateModule.forRoot()],
+ providers: [],
+ bootstrap: [AppComponent]
+})
+export class AppModule {
+}
diff --git a/Demos/Dropwizard/client/apps/annotation/src/assets/.gitkeep b/Demos/Dropwizard/client/apps/annotation/src/assets/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Dropwizard/client/apps/annotation/src/environments/environment.prod.ts b/Demos/Dropwizard/client/apps/annotation/src/environments/environment.prod.ts
new file mode 100644
index 0000000..3612073
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/src/environments/environment.prod.ts
@@ -0,0 +1,3 @@
+export const environment = {
+ production: true
+};
diff --git a/Demos/Dropwizard/client/apps/annotation/src/environments/environment.ts b/Demos/Dropwizard/client/apps/annotation/src/environments/environment.ts
new file mode 100644
index 0000000..7b4f817
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/src/environments/environment.ts
@@ -0,0 +1,16 @@
+// This file can be replaced during build by using the `fileReplacements` array.
+// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
+// The list of file replacements can be found in `angular.json`.
+
+export const environment = {
+ production: false
+};
+
+/*
+ * For easier debugging in development mode, you can import the following file
+ * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
+ *
+ * This import should be commented out in production mode because it will have a negative impact
+ * on performance if an error is thrown.
+ */
+// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
diff --git a/Demos/Dropwizard/client/apps/annotation/src/favicon.ico b/Demos/Dropwizard/client/apps/annotation/src/favicon.ico
new file mode 100644
index 0000000..317ebcb
Binary files /dev/null and b/Demos/Dropwizard/client/apps/annotation/src/favicon.ico differ
diff --git a/Demos/Dropwizard/client/apps/annotation/src/index.html b/Demos/Dropwizard/client/apps/annotation/src/index.html
new file mode 100644
index 0000000..70c837f
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/src/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+ Annotation
+
+
+
+
+
+
+
+
diff --git a/Demos/Dropwizard/client/apps/annotation/src/main.ts b/Demos/Dropwizard/client/apps/annotation/src/main.ts
new file mode 100644
index 0000000..fa4e0ae
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/src/main.ts
@@ -0,0 +1,13 @@
+import { enableProdMode } from '@angular/core';
+import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
+
+import { AppModule } from './app/app.module';
+import { environment } from './environments/environment';
+
+if (environment.production) {
+ enableProdMode();
+}
+
+platformBrowserDynamic()
+ .bootstrapModule(AppModule)
+ .catch(err => console.error(err));
diff --git a/Demos/Dropwizard/client/apps/annotation/src/polyfills.ts b/Demos/Dropwizard/client/apps/annotation/src/polyfills.ts
new file mode 100644
index 0000000..2f258e5
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/src/polyfills.ts
@@ -0,0 +1,62 @@
+/**
+ * This file includes polyfills needed by Angular and is loaded before the app.
+ * You can add your own extra polyfills to this file.
+ *
+ * This file is divided into 2 sections:
+ * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
+ * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
+ * file.
+ *
+ * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
+ * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
+ * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
+ *
+ * Learn more in https://angular.io/guide/browser-support
+ */
+
+/***************************************************************************************************
+ * BROWSER POLYFILLS
+ */
+
+/** IE10 and IE11 requires the following for NgClass support on SVG elements */
+// import 'classlist.js'; // Run `npm install --save classlist.js`.
+
+/**
+ * Web Animations `@angular/platform-browser/animations`
+ * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
+ * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
+ */
+// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
+
+/**
+ * By default, zone.js will patch all possible macroTask and DomEvents
+ * user can disable parts of macroTask/DomEvents patch by setting following flags
+ * because those flags need to be set before `zone.js` being loaded, and webpack
+ * will put import in the top of bundle, so user need to create a separate file
+ * in this directory (for example: zone-flags.ts), and put the following flags
+ * into that file, and then add the following code before importing zone.js.
+ * import './zone-flags.ts';
+ *
+ * The flags allowed in zone-flags.ts are listed here.
+ *
+ * The following flags will work for all browsers.
+ *
+ * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
+ * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
+ * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
+ *
+ * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
+ * with the following flag, it will bypass `zone.js` patch for IE/Edge
+ *
+ * (window as any).__Zone_enable_cross_context_check = true;
+ *
+ */
+
+/***************************************************************************************************
+ * Zone JS is required by default for Angular itself.
+ */
+import 'zone.js/dist/zone'; // Included with Angular CLI.
+
+/***************************************************************************************************
+ * APPLICATION IMPORTS
+ */
diff --git a/Demos/Dropwizard/client/apps/annotation/src/styles.less b/Demos/Dropwizard/client/apps/annotation/src/styles.less
new file mode 100644
index 0000000..90d4ee0
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/src/styles.less
@@ -0,0 +1 @@
+/* You can add global styles to this file, and also import other style files */
diff --git a/Demos/Dropwizard/client/apps/annotation/src/test-setup.ts b/Demos/Dropwizard/client/apps/annotation/src/test-setup.ts
new file mode 100644
index 0000000..8d88704
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/src/test-setup.ts
@@ -0,0 +1 @@
+import 'jest-preset-angular';
diff --git a/Demos/Dropwizard/client/apps/annotation/tsconfig.app.json b/Demos/Dropwizard/client/apps/annotation/tsconfig.app.json
new file mode 100644
index 0000000..12dc816
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/tsconfig.app.json
@@ -0,0 +1,10 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../dist/out-tsc",
+ "types": []
+ },
+ "files": ["src/main.ts", "src/polyfills.ts"],
+ "include": ["**/*.ts"],
+ "exclude": ["src/test-setup.ts", "**/*.spec.ts"]
+}
diff --git a/Demos/Dropwizard/client/apps/annotation/tsconfig.json b/Demos/Dropwizard/client/apps/annotation/tsconfig.json
new file mode 100644
index 0000000..e5decd5
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "types": ["node", "jest"]
+ },
+ "include": ["**/*.ts"]
+}
diff --git a/Demos/Dropwizard/client/apps/annotation/tsconfig.spec.json b/Demos/Dropwizard/client/apps/annotation/tsconfig.spec.json
new file mode 100644
index 0000000..cfff29a
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/tsconfig.spec.json
@@ -0,0 +1,10 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../dist/out-tsc",
+ "module": "commonjs",
+ "types": ["jest", "node"]
+ },
+ "files": ["src/test-setup.ts"],
+ "include": ["**/*.spec.ts", "**/*.d.ts"]
+}
diff --git a/Demos/Dropwizard/client/apps/annotation/tslint.json b/Demos/Dropwizard/client/apps/annotation/tslint.json
new file mode 100644
index 0000000..df75834
--- /dev/null
+++ b/Demos/Dropwizard/client/apps/annotation/tslint.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tslint.json",
+ "rules": {
+ "directive-selector": [true, "attribute", "client", "camelCase"],
+ "component-selector": [true, "element", "client", "kebab-case"]
+ }
+}
diff --git a/Demos/Dropwizard/client/jest.config.js b/Demos/Dropwizard/client/jest.config.js
new file mode 100644
index 0000000..ffd5ba2
--- /dev/null
+++ b/Demos/Dropwizard/client/jest.config.js
@@ -0,0 +1,10 @@
+module.exports = {
+ testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
+ transform: {
+ '^.+\\.(ts|js|html)$': 'ts-jest'
+ },
+ resolver: '@nrwl/jest/plugins/resolver',
+ moduleFileExtensions: ['ts', 'js', 'html'],
+ coverageReporters: ['html'],
+ passWithNoTests: true
+};
diff --git a/Demos/Dropwizard/client/libs/.gitkeep b/Demos/Dropwizard/client/libs/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Dropwizard/client/nx.json b/Demos/Dropwizard/client/nx.json
new file mode 100644
index 0000000..9fa5e7a
--- /dev/null
+++ b/Demos/Dropwizard/client/nx.json
@@ -0,0 +1,19 @@
+{
+ "npmScope": "client",
+ "implicitDependencies": {
+ "angular.json": "*",
+ "package.json": "*",
+ "tsconfig.json": "*",
+ "tslint.json": "*",
+ "nx.json": "*"
+ },
+ "projects": {
+ "annotation": {
+ "tags": []
+ },
+ "annotation-e2e": {
+ "tags": [],
+ "implicitDependencies": ["annotation"]
+ }
+ }
+}
diff --git a/Demos/Dropwizard/client/package.json b/Demos/Dropwizard/client/package.json
new file mode 100644
index 0000000..45ce89f
--- /dev/null
+++ b/Demos/Dropwizard/client/package.json
@@ -0,0 +1,67 @@
+{
+ "name": "client",
+ "version": "0.0.0",
+ "license": "MIT",
+ "scripts": {
+ "ng": "ng",
+ "nx": "nx",
+ "start": "ng serve",
+ "build": "ng build",
+ "test": "ng test",
+ "lint": "nx workspace-lint && ng lint",
+ "e2e": "ng e2e",
+ "affected:apps": "nx affected:apps",
+ "affected:libs": "nx affected:libs",
+ "affected:build": "nx affected:build",
+ "affected:e2e": "nx affected:e2e",
+ "affected:test": "nx affected:test",
+ "affected:lint": "nx affected:lint",
+ "affected:dep-graph": "nx affected:dep-graph",
+ "affected": "nx affected",
+ "format": "nx format:write",
+ "format:write": "nx format:write",
+ "format:check": "nx format:check",
+ "update": "ng update @nrwl/workspace",
+ "workspace-schematic": "nx workspace-schematic",
+ "dep-graph": "nx dep-graph",
+ "help": "nx help"
+ },
+ "private": true,
+ "dependencies": {
+ "@angular/animations": "^8.2.14",
+ "@angular/common": "^8.2.14",
+ "@angular/compiler": "^8.2.4",
+ "@angular/core": "^8.2.14",
+ "@angular/forms": "^8.2.14",
+ "@angular/platform-browser": "^8.2.14",
+ "@angular/platform-browser-dynamic": "^8.2.14",
+ "@angular/router": "^8.2.14",
+ "@groupdocs.examples.angular/annotation": "^0.8.99",
+ "@nrwl/angular": "^8.12.11",
+ "common-components": "^1.0.5",
+ "core-js": "^2.6.11",
+ "rxjs": "~6.4.0",
+ "zone.js": "^0.9.1"
+ },
+ "devDependencies": {
+ "@angular-devkit/build-angular": "^0.800.1",
+ "@angular/cli": "8.1.1",
+ "@angular/compiler-cli": "^8.2.13",
+ "@angular/language-service": "^8.2.13",
+ "@nrwl/cypress": "8.12.11",
+ "@nrwl/jest": "8.12.11",
+ "@nrwl/workspace": "8.12.11",
+ "@types/jest": "24.0.9",
+ "@types/node": "~8.9.4",
+ "codelyzer": "~5.0.1",
+ "cypress": "~3.8.2",
+ "dotenv": "6.2.0",
+ "jest": "24.1.0",
+ "jest-preset-angular": "7.0.0",
+ "prettier": "1.18.2",
+ "ts-jest": "24.0.0",
+ "ts-node": "~7.0.0",
+ "tslint": "~5.11.0",
+ "typescript": "~3.4.5"
+ }
+}
diff --git a/Demos/Dropwizard/client/tools/schematics/.gitkeep b/Demos/Dropwizard/client/tools/schematics/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Dropwizard/client/tools/tsconfig.tools.json b/Demos/Dropwizard/client/tools/tsconfig.tools.json
new file mode 100644
index 0000000..82bd1f0
--- /dev/null
+++ b/Demos/Dropwizard/client/tools/tsconfig.tools.json
@@ -0,0 +1,11 @@
+{
+ "extends": "../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../dist/out-tsc/tools",
+ "rootDir": ".",
+ "module": "commonjs",
+ "target": "es5",
+ "types": ["node"]
+ },
+ "include": ["**/*.ts"]
+}
diff --git a/Demos/Dropwizard/client/tsconfig.json b/Demos/Dropwizard/client/tsconfig.json
new file mode 100644
index 0000000..a5099b5
--- /dev/null
+++ b/Demos/Dropwizard/client/tsconfig.json
@@ -0,0 +1,21 @@
+{
+ "compileOnSave": false,
+ "compilerOptions": {
+ "rootDir": ".",
+ "sourceMap": true,
+ "declaration": false,
+ "moduleResolution": "node",
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "importHelpers": true,
+ "target": "es2015",
+ "module": "esnext",
+ "typeRoots": ["node_modules/@types"],
+ "lib": ["es2017", "dom"],
+ "skipLibCheck": true,
+ "skipDefaultLibCheck": true,
+ "baseUrl": ".",
+ "paths": {}
+ },
+ "exclude": ["node_modules", "tmp"]
+}
diff --git a/Demos/Dropwizard/client/tslint.json b/Demos/Dropwizard/client/tslint.json
new file mode 100644
index 0000000..2533001
--- /dev/null
+++ b/Demos/Dropwizard/client/tslint.json
@@ -0,0 +1,80 @@
+{
+ "rulesDirectory": [
+ "node_modules/@nrwl/workspace/src/tslint",
+ "node_modules/codelyzer"
+ ],
+ "rules": {
+ "arrow-return-shorthand": true,
+ "callable-types": true,
+ "class-name": true,
+ "deprecation": {
+ "severity": "warn"
+ },
+ "forin": true,
+ "import-blacklist": [true, "rxjs/Rx"],
+ "interface-over-type-literal": true,
+ "member-access": false,
+ "member-ordering": [
+ true,
+ {
+ "order": [
+ "static-field",
+ "instance-field",
+ "static-method",
+ "instance-method"
+ ]
+ }
+ ],
+ "no-arg": true,
+ "no-bitwise": true,
+ "no-console": [true, "debug", "info", "time", "timeEnd", "trace"],
+ "no-construct": true,
+ "no-debugger": true,
+ "no-duplicate-super": true,
+ "no-empty": false,
+ "no-empty-interface": true,
+ "no-eval": true,
+ "no-inferrable-types": [true, "ignore-params"],
+ "no-misused-new": true,
+ "no-non-null-assertion": true,
+ "no-shadowed-variable": true,
+ "no-string-literal": false,
+ "no-string-throw": true,
+ "no-switch-case-fall-through": true,
+ "no-unnecessary-initializer": true,
+ "no-unused-expression": true,
+ "no-var-keyword": true,
+ "object-literal-sort-keys": false,
+ "prefer-const": true,
+ "radix": true,
+ "triple-equals": [true, "allow-null-check"],
+ "unified-signatures": true,
+ "variable-name": false,
+ "nx-enforce-module-boundaries": [
+ true,
+ {
+ "allow": [],
+ "depConstraints": [
+ {
+ "sourceTag": "*",
+ "onlyDependOnLibsWithTags": ["*"]
+ }
+ ]
+ }
+ ],
+ "directive-selector": [true, "attribute", "app", "camelCase"],
+ "component-selector": [true, "element", "app", "kebab-case"],
+ "no-conflicting-lifecycle": true,
+ "no-host-metadata-property": true,
+ "no-input-rename": true,
+ "no-inputs-metadata-property": true,
+ "no-output-native": true,
+ "no-output-on-prefix": true,
+ "no-output-rename": true,
+ "no-outputs-metadata-property": true,
+ "template-banana-in-box": true,
+ "template-no-negated-async": true,
+ "use-lifecycle-interface": true,
+ "use-pipe-transform-interface": true
+ }
+}
diff --git a/Demos/Dropwizard/configuration.yml b/Demos/Dropwizard/configuration.yml
new file mode 100644
index 0000000..38e281a
--- /dev/null
+++ b/Demos/Dropwizard/configuration.yml
@@ -0,0 +1,100 @@
+################################################
+# Server configurations
+################################################
+server:
+ type: simple
+ applicationContextPath: /
+ adminContextPath: /admin
+ connector:
+ type: http
+ port: 8080
+
+
+################################################
+# Application (global) configurations
+################################################
+application:
+ # License path
+ # Absolute or relative path to GroupDocs license file
+ licensePath:
+ # Host name or ip for server instance
+ hostAddress: ${application.hostAddress}
+
+################################################
+# Common configurations
+################################################
+common:
+ # File rewriting on document uploading
+ # Set false to keep both files
+ # Set true to replace files with same name
+ rewrite: true
+ # Page navigation
+ # Set false to disable document navigation (go to next, previous, last and first page)
+ pageSelector: true
+ # Document download
+ # Set false to disable document download
+ download: true
+ # Document upload
+ # Set false to disable document upload
+ upload: true
+ # Document print
+ # Set false to disable document print
+ print: true
+ # File browser
+ # Set false to disable document browse
+ browse: true
+ # Set false to disable right mouse click
+ enableRightClick: true
+
+################################################
+# GroupDocs.Annotation configurations
+################################################
+annotation:
+ # Files directory path
+ # Absolute or relative path to files directory
+ filesDirectory:
+ # Default document
+ # Absolute or relative path to default document
+ defaultDocument: ''
+ # Pages preload
+ # How many pages from a document should be loaded, remaining pages will be loaded on page scrolling
+ # Set 0 to load all pages at once
+ preloadPageCount: 0
+ # Fonts path
+ # Absolute path to custom fonts directory
+ fontsDirectory: ''
+ # Enable/disable Text annotation
+ textAnnotation: true
+ # Enable/disable Area annotation
+ areaAnnotation: true
+ # Enable/disable Point annotation
+ pointAnnotation: true
+ # Enable/disable TextStrikeout annotation
+ textStrikeoutAnnotation: true
+ # Enable/disable Polyline annotation
+ polylineAnnotation: true
+ # Enable/disable TextField annotation
+ textFieldAnnotation: true
+ # Enable/disable Watermark annotation
+ watermarkAnnotation: true
+ # Enable/disable TextReplacement annotation
+ textReplacementAnnotation: true
+ # Enable/disable Arrow annotation
+ arrowAnnotation: true
+ # Enable/disable TextRedaction annotation
+ textRedactionAnnotation: true
+ # Enable/disable ResourcesRedaction annotation
+ resourcesRedactionAnnotation: true
+ # Enable/disable TextUnderline annotation
+ textUnderlineAnnotation: true
+ # Enable/disable Distance annotation
+ distanceAnnotation: true
+ # Enable/disable original document downloading
+ downloadOriginal: true
+ # Enable/disable signed document downloading
+ downloadAnnotated: true
+ # Enable/disable zoom
+ zoom: true
+ # Enable/disable fit width
+ # set true to zoom document pages fit width
+ fitWidth: true
diff --git a/Demos/Dropwizard/pom.xml b/Demos/Dropwizard/pom.xml
new file mode 100644
index 0000000..b3c68d6
--- /dev/null
+++ b/Demos/Dropwizard/pom.xml
@@ -0,0 +1,250 @@
+
+
+ 4.0.0
+
+ com.groupdocs.ui
+ annotation
+ 1.12.26
+ jar
+
+ GroupDocs.Annotation Dropwizard
+ https://groupdocs.com
+
+
+ UTF-8
+
+
+
+
+ io.dropwizard
+ dropwizard-core
+ 1.3.0
+
+
+ io.dropwizard
+ dropwizard-views-freemarker
+ 1.3.0
+
+
+ io.dropwizard
+ dropwizard-assets
+ 1.3.0
+
+
+ io.dropwizard
+ dropwizard-auth
+ 1.3.0
+
+
+ io.dropwizard
+ dropwizard-forms
+ 1.3.0
+
+
+ io.dropwizard
+ dropwizard-testing
+ 1.3.7
+ test
+
+
+ io.dropwizard
+ dropwizard-client
+ 1.3.7
+
+
+ org.glassfish.jersey.core
+ jersey-client
+ 2.25.1
+
+
+ org.gitlab4j
+ gitlab4j-api
+ 4.6.9
+
+
+ com.google.code.gson
+ gson
+ 2.8.2
+
+
+ org.json
+ json
+ 20180130
+
+
+ commons-io
+ commons-io
+ 2.7
+
+
+ com.groupdocs
+ groupdocs-annotation
+ 24.6
+
+
+ javax.xml.bind
+ jaxb-api
+ 2.3.0
+
+
+ javax.activation
+ activation
+ 1.1
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.0
+
+ 1.8
+ 1.8
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.2.1
+
+ com.groupdocs.ui.common.MainService
+
+ server
+ configuration.yml
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.3
+
+
+
+ *:*
+
+ META-INF/*.SF
+ META-INF/*.DSA
+ META-INF/*.RSA
+
+
+
+ false
+
+
+
+ package
+
+ shade
+
+
+
+
+
+ com.groupdocs.ui.common.MainService
+
+ .
+
+
+
+
+
+
+
+
+ com.github.eirslett
+ frontend-maven-plugin
+ 1.6
+
+ client
+
+
+
+
+ install node and npm
+
+ install-node-and-npm
+
+
+ v10.15.1
+
+
+
+ npm install
+
+ npm
+
+
+ install
+
+
+
+ npm update
+
+ npm
+
+
+ update
+
+
+
+ install client
+
+ npm
+
+
+ install
+
+
+
+ build client
+
+ npm
+
+
+ run build
+
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.2
+
+
+ default-prepare-agent
+
+ prepare-agent
+
+
+
+ default-report
+ prepare-package
+
+ report
+
+
+
+
+
+
+
+
+
+ com.springsource.repository.bundles.external
+ SpringSource Enterprise Bundle Repository - External Bundle Releases
+ https://repository.springsource.com/maven/bundles/external
+
+
+ GroupDocsJavaAPI
+ GroupDocs Java API
+ https://artifact.groupdocs.com/repo/
+
+
+
+
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/AbstractTextAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/AbstractTextAnnotator.java
new file mode 100644
index 0000000..21dd199
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/AbstractTextAnnotator.java
@@ -0,0 +1,23 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.Point;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class AbstractTextAnnotator extends BaseAnnotator {
+
+ protected AbstractTextAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+ }
+
+ protected static java.util.List getPoints(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ List tmp0 = new ArrayList<>();
+ tmp0.add(new Point(annotationData.getLeft(), pageInfo.getHeight() - annotationData.getTop()));
+ tmp0.add(new Point(annotationData.getLeft() + annotationData.getWidth(), pageInfo.getHeight() - annotationData.getTop()));
+ tmp0.add(new Point(annotationData.getLeft(), pageInfo.getHeight() - annotationData.getTop() - annotationData.getHeight()));
+ tmp0.add(new Point(annotationData.getLeft() + annotationData.getWidth(), pageInfo.getHeight() - annotationData.getTop() - annotationData.getHeight()));
+ return tmp0;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/AnnotatorFactory.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/AnnotatorFactory.java
new file mode 100644
index 0000000..08d4a84
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/AnnotatorFactory.java
@@ -0,0 +1,60 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.ui.common.exception.TotalGroupDocsException;
+
+public class AnnotatorFactory {
+
+ /**
+ *
+ * Create annotator instance depending on type of annotation
+ *
+ *
+ * @return
+ * @param annotationData AnnotationDataEntity
+ * @param pageInfo PageInfo
+ */
+ public static BaseAnnotator createAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ AnnotationDataEntity roundedAnnotationData = roundCoordinates(annotationData);
+ switch (roundedAnnotationData.getType().toLowerCase()) { // addev .toLowerCase()
+ case "text":
+ case "texthighlight": //textHighlight
+ return new TextHighlightAnnotator(roundedAnnotationData, pageInfo);
+ case "area":
+ return new AreaAnnotator(roundedAnnotationData, pageInfo);
+ case "point":
+ return new PointAnnotator(roundedAnnotationData, pageInfo);
+ case "textstrikeout": //textStrikeout
+ return new TextStrikeoutAnnotator(roundedAnnotationData, pageInfo);
+ case "polyline":
+ return new PolylineAnnotator(roundedAnnotationData, pageInfo);
+ case "textfield": //textField
+ return new TextFieldAnnotator(roundedAnnotationData, pageInfo);
+ case "watermark":
+ return new WatermarkAnnotator(roundedAnnotationData, pageInfo);
+ case "textreplacement": //textReplacement
+ return new TextReplacementAnnotator(roundedAnnotationData, pageInfo);
+ case "arrow":
+ return new ArrowAnnotator(roundedAnnotationData, pageInfo);
+ case "textredaction": //textRedaction
+ return new TextRedactionAnnotator(roundedAnnotationData, pageInfo);
+ case "resourcesredaction": //resourcesRedaction
+ return new ResourceRedactionAnnotator(roundedAnnotationData, pageInfo);
+ case "textunderline": //textUnderline
+ return new TextUnderlineAnnotator(roundedAnnotationData, pageInfo);
+ case "distance":
+ return new DistanceAnnotator(roundedAnnotationData, pageInfo);
+ default:
+ throw new TotalGroupDocsException("Wrong annotation data without annotation type!");
+ }
+ }
+
+ private static AnnotationDataEntity roundCoordinates(AnnotationDataEntity annotationData) {
+ annotationData.setHeight((float) Math.round(annotationData.getHeight()));
+ annotationData.setLeft((float) Math.round(annotationData.getLeft()));
+ annotationData.setTop((float) Math.round(annotationData.getTop()));
+ annotationData.setWidth((float) Math.round(annotationData.getWidth()));
+ return annotationData;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/AreaAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/AreaAnnotator.java
new file mode 100644
index 0000000..6edbf8a
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/AreaAnnotator.java
@@ -0,0 +1,55 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+
+public class AreaAnnotator extends BaseAnnotator {
+
+ private AreaAnnotation areaAnnotation;
+
+ public AreaAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ areaAnnotation = new AreaAnnotation();
+ areaAnnotation.setBox(getBox());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ areaAnnotation = (AreaAnnotation) initAnnotationBase(areaAnnotation);
+ return areaAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateWord();
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.AREA;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/ArrowAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/ArrowAnnotator.java
new file mode 100644
index 0000000..d5b10bc
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/ArrowAnnotator.java
@@ -0,0 +1,90 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.ArrowAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.CommentsEntity;
+
+public class ArrowAnnotator extends BaseAnnotator {
+
+ private boolean withGuid = false;
+ private ArrowAnnotation arrowAnnotation;
+
+ public ArrowAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ this.arrowAnnotation = new ArrowAnnotation();
+ this.arrowAnnotation.setBox(getBox());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ withGuid = false;
+ arrowAnnotation = (ArrowAnnotation) initAnnotationBase(arrowAnnotation);
+ return arrowAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ withGuid = true;
+ arrowAnnotation = (ArrowAnnotation) initAnnotationBase(arrowAnnotation);
+ return arrowAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateWord();
+ }
+
+ @Override
+ protected Reply getAnnotationReplyInfo(CommentsEntity comment) {
+ Reply annotationReplyInfo = super.getAnnotationReplyInfo(comment);
+ if (withGuid) {
+ annotationReplyInfo.setParentReply(new Reply());
+ annotationReplyInfo.getParentReply().setId(annotationData.getId());
+ }
+ return annotationReplyInfo;
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.ARROW;
+ }
+
+ @Override
+ protected Rectangle getBox() {
+ String svgPath = annotationData.getSvgPath();
+
+ String startPoint = svgPath.replace("[a-zA-Z]+", "").split(" ")[0];
+ String endPoint = svgPath.replace("[a-zA-Z]+", "").split(" ")[1];
+
+ String[] start = startPoint.split(",");
+ float startX = Float.parseFloat(start.length > 0 ? start[0].replace("M", "").replace(",", ".") : "0");
+ float startY = Float.parseFloat(start.length > 0 ? start[1].replace("M", "").replace(",", ".") : "0");
+
+ String[] end = endPoint.split(",");
+ float endX = Float.parseFloat(end.length > 0 ? end[0].replace("L", "").replace(",", ".") : "0") - startX;
+ float endY = Float.parseFloat(end.length > 1 ? end[1].replace("L", "").replace(",", ".") : "0") - startY;
+
+ return new Rectangle(startX, startY, endX, endY);
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/BaseAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/BaseAnnotator.java
new file mode 100644
index 0000000..7bc2c5e
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/BaseAnnotator.java
@@ -0,0 +1,225 @@
+package com.groupdocs.ui.annotation.annotator;
+
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.User;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.CommentsEntity;
+import com.groupdocs.ui.common.exception.TotalGroupDocsException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.TimeZone;
+
+/**
+ *
+ * BaseSigner
+ *
+ */
+public abstract class BaseAnnotator {
+
+ public String Message = "Annotation of type {0} for this file type is not supported";
+ protected AnnotationDataEntity annotationData;
+ protected PageInfo pageInfo;
+
+ /**
+ *
+ * Constructor
+ *
+ *
+ * @param annotationData
+ * @param pageInfo
+ */
+ protected BaseAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ this.annotationData = annotationData;
+ this.pageInfo = pageInfo;
+ }
+
+ /**
+ *
+ * Add area annotation into the Word document
+ *
+ *
+ * @return AnnotationBase
+ */
+ public abstract AnnotationBase annotateWord();
+
+ /**
+ *
+ * Add area annotation into the pdf document
+ *
+ *
+ * @return AnnotationBase
+ */
+ public abstract AnnotationBase annotatePdf();
+
+ /////
+ ///// Add area annotation into the Excel document
+ /////
+ ///// AnnotationBase
+ public abstract AnnotationBase annotateCells();
+
+ /**
+ *
+ * Add area annotation into the Power Point document
+ *
+ *
+ * @return AnnotationBase
+ */
+ public abstract AnnotationBase annotateSlides();
+
+ /**
+ *
+ * Add area annotation into the image document
+ *
+ *
+ * @return AnnotationBase
+ */
+ public abstract AnnotationBase annotateImage();
+
+ /**
+ *
+ * Add area annotation into the document
+ *
+ *
+ * @return AnnotationBase
+ */
+ public abstract AnnotationBase annotateDiagram();
+
+ /**
+ *
+ * Initial for annotation info
+ *
+ *
+ * @param annotationBase
+ * @return AnnotationBase
+ */
+ protected final AnnotationBase initAnnotationBase(AnnotationBase annotationBase) {
+ // set page number to add annotation
+ annotationBase.setPageNumber(annotationData.getPageNumber() - 1);
+ // set annotation type
+ annotationBase.setType(getType());
+ annotationBase.setCreatedOn(Date.from(Instant.now()));
+ annotationBase.setId(annotationData.getId());
+ // add replies
+ CommentsEntity[] comments = annotationData.getComments();
+ if (comments != null && comments.length != 0) {
+ java.util.List replies = new ArrayList<>();
+ for (int i = 0; i < comments.length; i++) {
+ Reply reply = getAnnotationReplyInfo(comments[i]);
+ replies.add(reply);
+ }
+ annotationBase.setReplies(replies);
+ }
+ return annotationBase;
+ }
+
+ /**
+ *
+ * Initial for reply annotation info
+ *
+ *
+ * @return AnnotationReplyInfo
+ * @param comment CommentsEntity
+ */
+ protected Reply getAnnotationReplyInfo(CommentsEntity comment) {
+ Reply reply = new Reply();
+ reply.setComment(comment.getText());
+ DateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss");
+ format.setTimeZone(TimeZone.getTimeZone("GMT"));
+ Date date;
+ try {
+ date = new Date(Long.parseLong(comment.getTime()));
+ } catch (Exception e) {
+ try {
+ date = format.parse(comment.getTime());
+ } catch (Exception exc) {
+ format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
+ try {
+ date = format.parse(comment.getTime());
+ } catch (ParseException ex) {
+ throw new TotalGroupDocsException(ex.getMessage());
+ }
+ }
+ }
+ reply.setRepliedOn(date);
+ reply.setUser(new User());
+ reply.getUser().setName(comment.getUserName());
+ return reply;
+ }
+
+ /**
+ *
+ * Get rectangle
+ *
+ *
+ * @return Rectangle
+ */
+ protected Rectangle getBox() {
+ return new Rectangle(annotationData.getLeft(), annotationData.getTop(), annotationData.getWidth(), annotationData.getHeight());
+ }
+
+ /**
+ *
+ * Get type of annotation
+ *
+ *
+ * @return byte
+ */
+ protected abstract int getType();
+
+ /**
+ *
+ * Get Annotation info depending on document type
+ *
+ *
+ * @return AnnotationBase
+ * @param documentType string
+ */
+ public final AnnotationBase getAnnotationBase(String documentType) {
+ switch (documentType) {
+ case "Portable Document Format":
+ return annotatePdf();
+ case "Microsoft Word":
+ case "Open Document Text":
+ return annotateWord();
+ case "Rich Text Format":
+ return annotateWord();
+ case "Microsoft PowerPoint":
+ return annotateSlides();
+ case "image":
+ return annotateImage();
+ case "Microsoft Excel":
+ return annotateCells();
+ case "AutoCAD Drawing File Format":
+ return annotateDiagram();
+ default:
+ throw new TotalGroupDocsException("Wrong annotation data without document type!");
+ }
+ }
+
+ /**
+ *
+ * Check if the current annotatin is supported
+ *
+ *
+ * @return
+ * @param documentType string
+ */
+ public final boolean isSupported(String documentType) {
+ try {
+ AnnotatorFactory.createAnnotator(annotationData, pageInfo).getAnnotationBase(documentType);
+ return true;
+ } catch (java.lang.UnsupportedOperationException e) {
+ Message += annotationData.getType();
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/DistanceAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/DistanceAnnotator.java
new file mode 100644
index 0000000..1efc61b
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/DistanceAnnotator.java
@@ -0,0 +1,92 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.DistanceAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.CommentsEntity;
+
+public class DistanceAnnotator extends BaseAnnotator {
+
+ private DistanceAnnotation distanceAnnotation;
+
+ public DistanceAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ distanceAnnotation = new DistanceAnnotation();
+ distanceAnnotation.setBox(getBox());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ distanceAnnotation = (DistanceAnnotation) initAnnotationBaseDistanceAnnotator(distanceAnnotation);
+ return distanceAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateWord();
+ }
+
+ protected final AnnotationBase initAnnotationBaseDistanceAnnotator(AnnotationBase annotationBase) {
+ distanceAnnotation = (DistanceAnnotation) super.initAnnotationBase(annotationBase);
+ String tmp0 = annotationData.getText();
+ if (tmp0 == null) {
+ tmp0 = "";
+ }
+ // add replies
+ String text = tmp0;
+ CommentsEntity[] comments = annotationData.getComments();
+ if (comments != null && comments.length != 0) {
+ Reply reply = distanceAnnotation.getReplies().get(0);
+ if (reply != null) {
+ reply.setComment(String.format("%s %s", text, reply.getComment()));
+ }
+ }
+
+ return distanceAnnotation;
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.DISTANCE;
+ }
+
+ @Override
+ protected Rectangle getBox() {
+ String svgPath = annotationData.getSvgPath();
+
+ String startPoint = svgPath.replaceAll("[a-zA-Z]+", "").split(" ")[0];
+ String endPoint = svgPath.replaceAll("[a-zA-Z]+", "").split(" ")[1];
+ String[] start = startPoint.split(",");
+ float startX = Float.parseFloat(start.length > 0 ? start[0] : "0");
+ float startY = Float.parseFloat(start.length > 1 ? start[1] : "0");
+ String[] end = endPoint.split(",");
+ float endX = Float.parseFloat(end.length > 0 ? end[0] : "0") - startX;
+ float endY = Float.parseFloat(end.length > 1 ? end[1] : "0") - startY;
+ return new Rectangle(startX, startY, endX, endY);
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/PointAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/PointAnnotator.java
new file mode 100644
index 0000000..82c853f
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/PointAnnotator.java
@@ -0,0 +1,56 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.PointAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+
+
+public class PointAnnotator extends BaseAnnotator {
+
+ private PointAnnotation pointAnnotation;
+
+ public PointAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ pointAnnotation = new PointAnnotation();
+ pointAnnotation.setBox(getBox());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ pointAnnotation = (PointAnnotation) super.initAnnotationBase(pointAnnotation);
+ return pointAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateWord();
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.POINT;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/PolylineAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/PolylineAnnotator.java
new file mode 100644
index 0000000..a554cb1
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/PolylineAnnotator.java
@@ -0,0 +1,79 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.User;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.PolylineAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.CommentsEntity;
+
+
+public class PolylineAnnotator extends BaseAnnotator {
+
+ private PolylineAnnotation polylineAnnotation;
+
+ public PolylineAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ this.polylineAnnotation = new PolylineAnnotation();
+ this.polylineAnnotation.setBox(getBox());
+ this.polylineAnnotation.setPenColor(1201033);
+ this.polylineAnnotation.setPenWidth((byte) 2);
+ this.polylineAnnotation.setSvgPath(annotationData.getSvgPath());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ polylineAnnotation = (PolylineAnnotation) initAnnotationBase(polylineAnnotation);
+ return polylineAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ polylineAnnotation = (PolylineAnnotation) initAnnotationBase(polylineAnnotation);
+ fillCreatorName(polylineAnnotation, annotationData);
+ return polylineAnnotation;
+ }
+
+ /**
+ *
+ * Fill creator name field in annotation info
+ *
+ *
+ * @param polylineAnnotation AnnotationBase
+ * @param annotationData
+ */
+ protected static void fillCreatorName(AnnotationBase polylineAnnotation, AnnotationDataEntity annotationData) {
+ CommentsEntity[] comments = annotationData.getComments();
+ if (comments != null && comments.length > 0 && comments[0] != null) {
+ polylineAnnotation.setUser(new User());
+ polylineAnnotation.getUser().setName(comments[0].getUserName());
+ }
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateSlides();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateSlides();
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.POLYLINE;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/ResourceRedactionAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/ResourceRedactionAnnotator.java
new file mode 100644
index 0000000..bef6255
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/ResourceRedactionAnnotator.java
@@ -0,0 +1,57 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.ResourcesRedactionAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.common.exception.TotalGroupDocsException;
+
+
+public class ResourceRedactionAnnotator extends BaseAnnotator {
+
+ private ResourcesRedactionAnnotation resourcesRedactionAnnotation;
+
+ public ResourceRedactionAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ this.resourcesRedactionAnnotation = new ResourcesRedactionAnnotation();
+ this.resourcesRedactionAnnotation.setBox(getBox());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ resourcesRedactionAnnotation = (ResourcesRedactionAnnotation) initAnnotationBase(resourcesRedactionAnnotation);
+ return resourcesRedactionAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateWord();
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.RESOURCES_REDACTION;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextFieldAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextFieldAnnotator.java
new file mode 100644
index 0000000..4df87dc
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextFieldAnnotator.java
@@ -0,0 +1,61 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.TextFieldAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+
+
+public class TextFieldAnnotator extends BaseAnnotator {
+
+ private TextFieldAnnotation textFieldAnnotation;
+
+ public TextFieldAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ textFieldAnnotation = new TextFieldAnnotation();
+ textFieldAnnotation.setBox(getBox());
+
+ textFieldAnnotation.setFontFamily(annotationData.getFont() != null || !"".equals(annotationData.getFont()) ? annotationData.getFont() : "Arial");
+ textFieldAnnotation.setFontColor(annotationData.getFontColor());
+ textFieldAnnotation.setFontSize(annotationData.getFontSize() == 0 ? 12 : annotationData.getFontSize());
+ textFieldAnnotation.setText(annotationData.getText());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ textFieldAnnotation = (TextFieldAnnotation) initAnnotationBase(textFieldAnnotation);
+ return textFieldAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateWord();
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.TEXT_FIELD;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextHighlightAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextHighlightAnnotator.java
new file mode 100644
index 0000000..cc4b08d
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextHighlightAnnotator.java
@@ -0,0 +1,57 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.HighlightAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.common.exception.TotalGroupDocsException;
+
+
+public class TextHighlightAnnotator extends AbstractTextAnnotator {
+
+ private HighlightAnnotation highlightAnnotation;
+
+ public TextHighlightAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ highlightAnnotation = new HighlightAnnotation();
+ highlightAnnotation.setPoints(getPoints(annotationData, pageInfo));
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ highlightAnnotation = (HighlightAnnotation) initAnnotationBase(highlightAnnotation);
+ return highlightAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.TEXT_HIGHLIGHT;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextRedactionAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextRedactionAnnotator.java
new file mode 100644
index 0000000..f1b3a4b
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextRedactionAnnotator.java
@@ -0,0 +1,56 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.TextRedactionAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.common.exception.TotalGroupDocsException;
+
+public class TextRedactionAnnotator extends TextHighlightAnnotator {
+
+ private TextRedactionAnnotation textRedactionAnnotation;
+
+ public TextRedactionAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ textRedactionAnnotation = new TextRedactionAnnotation();
+ textRedactionAnnotation.setPoints(getPoints(annotationData, pageInfo));
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotatePdf();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotatePdf();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ textRedactionAnnotation = (TextRedactionAnnotation) initAnnotationBase(textRedactionAnnotation);
+ return textRedactionAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ return annotatePdf();
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.TEXT_REDACTION;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextReplacementAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextReplacementAnnotator.java
new file mode 100644
index 0000000..c6d92ca
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextReplacementAnnotator.java
@@ -0,0 +1,58 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.ReplacementAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.common.exception.TotalGroupDocsException;
+
+
+public class TextReplacementAnnotator extends AbstractTextAnnotator {
+
+ private ReplacementAnnotation replacementAnnotation;
+
+ public TextReplacementAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ replacementAnnotation = new ReplacementAnnotation();
+ replacementAnnotation.setPoints(getPoints(annotationData, pageInfo));
+ replacementAnnotation.setTextToReplace(annotationData.getText());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ replacementAnnotation = (ReplacementAnnotation) initAnnotationBase(replacementAnnotation);
+ return replacementAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.TEXT_REPLACEMENT;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextStrikeoutAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextStrikeoutAnnotator.java
new file mode 100644
index 0000000..3f36675
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextStrikeoutAnnotator.java
@@ -0,0 +1,58 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.StrikeoutAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.common.exception.TotalGroupDocsException;
+
+public class TextStrikeoutAnnotator extends AbstractTextAnnotator {
+
+ private StrikeoutAnnotation strikeoutAnnotation;
+
+ public TextStrikeoutAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ strikeoutAnnotation = new StrikeoutAnnotation();
+ strikeoutAnnotation.setPoints(getPoints(annotationData, pageInfo));
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ strikeoutAnnotation = (StrikeoutAnnotation) initAnnotationBase(strikeoutAnnotation);
+ return strikeoutAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ strikeoutAnnotation = (StrikeoutAnnotation) initAnnotationBase(strikeoutAnnotation);
+ this.strikeoutAnnotation.setFontColor(0);
+ return strikeoutAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.TEXT_STRIKEOUT;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextUnderlineAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextUnderlineAnnotator.java
new file mode 100644
index 0000000..ef09636
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/TextUnderlineAnnotator.java
@@ -0,0 +1,60 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.UnderlineAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.common.exception.TotalGroupDocsException;
+
+
+public class TextUnderlineAnnotator extends AbstractTextAnnotator {
+
+ private UnderlineAnnotation underlineAnnotation;
+
+ public TextUnderlineAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ underlineAnnotation = new UnderlineAnnotation();
+ underlineAnnotation.setPoints(getPoints(annotationData, pageInfo));
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ underlineAnnotation = (UnderlineAnnotation) initAnnotationBase(underlineAnnotation);
+ underlineAnnotation.setFontColor(1201033);
+ return underlineAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ underlineAnnotation = (UnderlineAnnotation) initAnnotationBase(underlineAnnotation);
+ underlineAnnotation.setFontColor(0);
+ return underlineAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.TEXT_UNDERLINE;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/WatermarkAnnotator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/WatermarkAnnotator.java
new file mode 100644
index 0000000..b395e0a
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/annotator/WatermarkAnnotator.java
@@ -0,0 +1,60 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.WatermarkAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.common.exception.TotalGroupDocsException;
+
+public class WatermarkAnnotator extends BaseAnnotator {
+
+ private WatermarkAnnotation watermarkAnnotation;
+
+ public WatermarkAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ watermarkAnnotation = new WatermarkAnnotation();
+ watermarkAnnotation.setBox(getBox());
+ watermarkAnnotation.setFontFamily(annotationData.getFont() != null || !"".equals(annotationData.getFont()) ? annotationData.getFont() : "Arial");
+ watermarkAnnotation.setFontColor(annotationData.getFontColor());
+ watermarkAnnotation.setFontSize(annotationData.getFontSize() == 0 ? 12 : annotationData.getFontSize());
+ watermarkAnnotation.setText(annotationData.getText());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ watermarkAnnotation = (WatermarkAnnotation) initAnnotationBase(watermarkAnnotation);
+ return watermarkAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.WATERMARK;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfiguration.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfiguration.java
new file mode 100644
index 0000000..55738cb
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfiguration.java
@@ -0,0 +1,270 @@
+package com.groupdocs.ui.annotation.config;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.dropwizard.Configuration;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.validation.Valid;
+
+import static com.groupdocs.ui.common.config.DefaultDirectories.defaultAnnotationDirectory;
+import static com.groupdocs.ui.common.config.DefaultDirectories.relativePathToAbsolute;
+
+/**
+ * AnnotationConfiguration
+ *
+ * @author Aspose Pty Ltd
+ */
+public class AnnotationConfiguration extends Configuration {
+
+ @Valid
+ @JsonProperty
+ private String filesDirectory;
+
+ @Valid
+ @JsonProperty
+ private String defaultDocument;
+
+ @Valid
+ @JsonProperty
+ private int preloadPageCount;
+
+ @Valid
+ @JsonProperty
+ private String fontsDirectory;
+
+ @Valid
+ @JsonProperty
+ private boolean textAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean areaAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean pointAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean textStrikeoutAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean polylineAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean textFieldAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean watermarkAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean textReplacementAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean arrowAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean textRedactionAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean resourcesRedactionAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean textUnderlineAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean distanceAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean downloadOriginal;
+
+ @Valid
+ @JsonProperty
+ private boolean downloadAnnotated;
+
+ @Valid
+ @JsonProperty
+ private boolean zoom;
+
+ @Valid
+ @JsonProperty
+ private boolean fitWidth;
+
+ public String getFilesDirectory() {
+ return filesDirectory;
+ }
+
+ public void setFilesDirectory(String filesDirectory) {
+ this.filesDirectory = StringUtils.isEmpty(filesDirectory) ? defaultAnnotationDirectory() : relativePathToAbsolute(filesDirectory);
+ }
+
+ public String getDefaultDocument() {
+ return defaultDocument;
+ }
+
+ public void setDefaultDocument(String defaultDocument) {
+ this.defaultDocument = defaultDocument;
+ }
+
+ public int getPreloadPageCount() {
+ return preloadPageCount;
+ }
+
+ public void setPreloadPageCount(int preloadPageCount) {
+ this.preloadPageCount = preloadPageCount;
+ }
+
+ public String getFontsDirectory() {
+ return fontsDirectory;
+ }
+
+ public void setFontsDirectory(String fontsDirectory) {
+ this.fontsDirectory = fontsDirectory;
+ }
+
+ public boolean getTextAnnotation() {
+ return textAnnotation;
+ }
+
+ public void setTextAnnotation(boolean textAnnotation) {
+ this.textAnnotation = textAnnotation;
+ }
+
+ public boolean getAreaAnnotation() {
+ return areaAnnotation;
+ }
+
+ public void setAreaAnnotation(boolean areaAnnotation) {
+ this.areaAnnotation = areaAnnotation;
+ }
+
+ public boolean getPointAnnotation() {
+ return pointAnnotation;
+ }
+
+ public void setPointAnnotation(boolean pointAnnotation) {
+ this.pointAnnotation = pointAnnotation;
+ }
+
+ public boolean getTextStrikeoutAnnotation() {
+ return textStrikeoutAnnotation;
+ }
+
+ public void setTextStrikeoutAnnotation(boolean textStrikeoutAnnotation) {
+ this.textStrikeoutAnnotation = textStrikeoutAnnotation;
+ }
+
+ public boolean getPolylineAnnotation() {
+ return polylineAnnotation;
+ }
+
+ public void setPolylineAnnotation(boolean polylineAnnotation) {
+ this.polylineAnnotation = polylineAnnotation;
+ }
+
+ public boolean getTextFieldAnnotation() {
+ return textFieldAnnotation;
+ }
+
+ public void setTextFieldAnnotation(boolean textFieldAnnotation) {
+ this.textFieldAnnotation = textFieldAnnotation;
+ }
+
+ public boolean getWatermarkAnnotation() {
+ return watermarkAnnotation;
+ }
+
+ public void setWatermarkAnnotation(boolean watermarkAnnotation) {
+ this.watermarkAnnotation = watermarkAnnotation;
+ }
+
+ public boolean getTextReplacementAnnotation() {
+ return textReplacementAnnotation;
+ }
+
+ public void setTextReplacementAnnotation(boolean textReplacementAnnotation) {
+ this.textReplacementAnnotation = textReplacementAnnotation;
+ }
+
+ public boolean getArrowAnnotation() {
+ return arrowAnnotation;
+ }
+
+ public void setArrowAnnotation(boolean arrowAnnotation) {
+ this.arrowAnnotation = arrowAnnotation;
+ }
+
+ public boolean getTextRedactionAnnotation() {
+ return textRedactionAnnotation;
+ }
+
+ public void setTextRedactionAnnotation(boolean textRedactionAnnotation) {
+ this.textRedactionAnnotation = textRedactionAnnotation;
+ }
+
+ public boolean getResourcesRedactionAnnotation() {
+ return resourcesRedactionAnnotation;
+ }
+
+ public void setResourcesRedactionAnnotation(boolean resourcesRedactionAnnotation) {
+ this.resourcesRedactionAnnotation = resourcesRedactionAnnotation;
+ }
+
+ public boolean getTextUnderlineAnnotation() {
+ return textUnderlineAnnotation;
+ }
+
+ public void setTextUnderlineAnnotation(boolean textUnderlineAnnotation) {
+ this.textUnderlineAnnotation = textUnderlineAnnotation;
+ }
+
+ public boolean getDistanceAnnotation() {
+ return distanceAnnotation;
+ }
+
+ public void setDistanceAnnotation(boolean distanceAnnotation) {
+ this.distanceAnnotation = distanceAnnotation;
+ }
+
+ public boolean getDownloadOriginal() {
+ return downloadOriginal;
+ }
+
+ public void setDownloadOriginal(boolean downloadOriginal) {
+ this.downloadOriginal = downloadOriginal;
+ }
+
+ public boolean getDownloadAnnotated() {
+ return downloadAnnotated;
+ }
+
+ public void setDownloadAnnotated(boolean downloadAnnotated) {
+ this.downloadAnnotated = downloadAnnotated;
+ }
+
+ public boolean getZoom() {
+ return zoom;
+ }
+
+ public void setZoom(boolean zoom) {
+ this.zoom = zoom;
+ }
+
+ public boolean getFitWidth() {
+ return fitWidth;
+ }
+
+ public void setFitWidth(boolean fitWidth) {
+ this.fitWidth = fitWidth;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfigurationModel.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfigurationModel.java
new file mode 100644
index 0000000..e71e628
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfigurationModel.java
@@ -0,0 +1,289 @@
+package com.groupdocs.ui.annotation.config;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.groupdocs.ui.common.config.CommonConfiguration;
+import com.groupdocs.ui.common.config.CommonConfigurationModel;
+
+import javax.validation.Valid;
+
+public class AnnotationConfigurationModel extends CommonConfigurationModel {
+
+ @Valid
+ @JsonProperty
+ private String filesDirectory;
+
+ @Valid
+ @JsonProperty
+ private String defaultDocument;
+
+ @Valid
+ @JsonProperty
+ private int preloadPageCount;
+
+ @Valid
+ @JsonProperty
+ private String fontsDirectory;
+
+ @Valid
+ @JsonProperty
+ private boolean textAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean areaAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean pointAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean textStrikeoutAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean polylineAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean textFieldAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean watermarkAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean textReplacementAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean arrowAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean textRedactionAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean resourcesRedactionAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean textUnderlineAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean distanceAnnotation;
+
+ @Valid
+ @JsonProperty
+ private boolean downloadOriginal;
+
+ @Valid
+ @JsonProperty
+ private boolean downloadAnnotated;
+
+ @Valid
+ @JsonProperty
+ private boolean zoom;
+
+ @Valid
+ @JsonProperty
+ private boolean fitWidth;
+
+ public String getFilesDirectory() {
+ return filesDirectory;
+ }
+
+ public void setFilesDirectory(String filesDirectory) {
+ this.filesDirectory = filesDirectory;
+ }
+
+ public String getDefaultDocument() {
+ return defaultDocument;
+ }
+
+ public void setDefaultDocument(String defaultDocument) {
+ this.defaultDocument = defaultDocument;
+ }
+
+ public int getPreloadPageCount() {
+ return preloadPageCount;
+ }
+
+ public void setPreloadPageCount(int preloadPageCount) {
+ this.preloadPageCount = preloadPageCount;
+ }
+
+ public String getFontsDirectory() {
+ return fontsDirectory;
+ }
+
+ public void setFontsDirectory(String fontsDirectory) {
+ this.fontsDirectory = fontsDirectory;
+ }
+
+ public boolean isTextAnnotation() {
+ return textAnnotation;
+ }
+
+ public void setTextAnnotation(boolean textAnnotation) {
+ this.textAnnotation = textAnnotation;
+ }
+
+ public boolean isAreaAnnotation() {
+ return areaAnnotation;
+ }
+
+ public void setAreaAnnotation(boolean areaAnnotation) {
+ this.areaAnnotation = areaAnnotation;
+ }
+
+ public boolean isPointAnnotation() {
+ return pointAnnotation;
+ }
+
+ public void setPointAnnotation(boolean pointAnnotation) {
+ this.pointAnnotation = pointAnnotation;
+ }
+
+ public boolean isTextStrikeoutAnnotation() {
+ return textStrikeoutAnnotation;
+ }
+
+ public void setTextStrikeoutAnnotation(boolean textStrikeoutAnnotation) {
+ this.textStrikeoutAnnotation = textStrikeoutAnnotation;
+ }
+
+ public boolean isPolylineAnnotation() {
+ return polylineAnnotation;
+ }
+
+ public void setPolylineAnnotation(boolean polylineAnnotation) {
+ this.polylineAnnotation = polylineAnnotation;
+ }
+
+ public boolean isTextFieldAnnotation() {
+ return textFieldAnnotation;
+ }
+
+ public void setTextFieldAnnotation(boolean textFieldAnnotation) {
+ this.textFieldAnnotation = textFieldAnnotation;
+ }
+
+ public boolean isWatermarkAnnotation() {
+ return watermarkAnnotation;
+ }
+
+ public void setWatermarkAnnotation(boolean watermarkAnnotation) {
+ this.watermarkAnnotation = watermarkAnnotation;
+ }
+
+ public boolean isTextReplacementAnnotation() {
+ return textReplacementAnnotation;
+ }
+
+ public void setTextReplacementAnnotation(boolean textReplacementAnnotation) {
+ this.textReplacementAnnotation = textReplacementAnnotation;
+ }
+
+ public boolean isArrowAnnotation() {
+ return arrowAnnotation;
+ }
+
+ public void setArrowAnnotation(boolean arrowAnnotation) {
+ this.arrowAnnotation = arrowAnnotation;
+ }
+
+ public boolean isTextRedactionAnnotation() {
+ return textRedactionAnnotation;
+ }
+
+ public void setTextRedactionAnnotation(boolean textRedactionAnnotation) {
+ this.textRedactionAnnotation = textRedactionAnnotation;
+ }
+
+ public boolean isResourcesRedactionAnnotation() {
+ return resourcesRedactionAnnotation;
+ }
+
+ public void setResourcesRedactionAnnotation(boolean resourcesRedactionAnnotation) {
+ this.resourcesRedactionAnnotation = resourcesRedactionAnnotation;
+ }
+
+ public boolean isTextUnderlineAnnotation() {
+ return textUnderlineAnnotation;
+ }
+
+ public void setTextUnderlineAnnotation(boolean textUnderlineAnnotation) {
+ this.textUnderlineAnnotation = textUnderlineAnnotation;
+ }
+
+ public boolean isDistanceAnnotation() {
+ return distanceAnnotation;
+ }
+
+ public void setDistanceAnnotation(boolean distanceAnnotation) {
+ this.distanceAnnotation = distanceAnnotation;
+ }
+
+ public boolean isDownloadOriginal() {
+ return downloadOriginal;
+ }
+
+ public void setDownloadOriginal(boolean downloadOriginal) {
+ this.downloadOriginal = downloadOriginal;
+ }
+
+ public boolean isDownloadAnnotated() {
+ return downloadAnnotated;
+ }
+
+ public void setDownloadAnnotated(boolean downloadAnnotated) {
+ this.downloadAnnotated = downloadAnnotated;
+ }
+
+ public boolean isZoom() {
+ return zoom;
+ }
+
+ public void setZoom(boolean zoom) {
+ this.zoom = zoom;
+ }
+
+ public boolean isFitWidth() {
+ return fitWidth;
+ }
+
+ public void setFitWidth(boolean fitWidth) {
+ this.fitWidth = fitWidth;
+ }
+
+ public static AnnotationConfigurationModel createAnnotationConfiguration(AnnotationConfiguration annotation, CommonConfiguration common) {
+ AnnotationConfigurationModel config = new AnnotationConfigurationModel();
+ config.init(common);
+ config.setFilesDirectory(annotation.getFilesDirectory());
+ config.setDefaultDocument(annotation.getDefaultDocument());
+ config.setPreloadPageCount(annotation.getPreloadPageCount());
+ config.setFontsDirectory(annotation.getFontsDirectory());
+ config.setTextAnnotation(annotation.getTextAnnotation());
+ config.setAreaAnnotation(annotation.getAreaAnnotation());
+ config.setPointAnnotation(annotation.getPointAnnotation());
+ config.setTextStrikeoutAnnotation(annotation.getTextStrikeoutAnnotation());
+ config.setPolylineAnnotation(annotation.getPolylineAnnotation());
+ config.setTextFieldAnnotation(annotation.getTextFieldAnnotation());
+ config.setTextReplacementAnnotation(annotation.getTextReplacementAnnotation());
+ config.setTextRedactionAnnotation(annotation.getTextRedactionAnnotation());
+ config.setTextUnderlineAnnotation(annotation.getTextUnderlineAnnotation());
+ config.setWatermarkAnnotation(annotation.getWatermarkAnnotation());
+ config.setArrowAnnotation(annotation.getArrowAnnotation());
+ config.setDistanceAnnotation(annotation.getDistanceAnnotation());
+ config.setResourcesRedactionAnnotation(annotation.getResourcesRedactionAnnotation());
+ config.setZoom(annotation.getZoom());
+ config.setFitWidth(annotation.getFitWidth());
+ config.setDownloadOriginal(annotation.getDownloadOriginal());
+ config.setDownloadAnnotated(annotation.getDownloadAnnotated());
+ return config;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/request/AnnotateDocumentRequest.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/request/AnnotateDocumentRequest.java
new file mode 100644
index 0000000..3a005b9
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/request/AnnotateDocumentRequest.java
@@ -0,0 +1,49 @@
+package com.groupdocs.ui.annotation.entity.request;
+
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.common.entity.web.request.LoadDocumentRequest;
+
+/**
+ * AnnotateDocumentRequest
+ *
+ * @author Aspose Pty Ltd
+ */
+public class AnnotateDocumentRequest extends LoadDocumentRequest {
+ /**
+ * List of annotation data
+ */
+ private AnnotationDataEntity[] annotationsData;
+ /**
+ * Document type
+ */
+ private String documentType;
+
+ /**
+ * For print annotated file
+ */
+ private Boolean print;
+
+ public AnnotationDataEntity[] getAnnotationsData() {
+ return annotationsData;
+ }
+
+ public void setAnnotationsData(AnnotationDataEntity[] annotationsData) {
+ this.annotationsData = annotationsData;
+ }
+
+ public String getDocumentType() {
+ return documentType;
+ }
+
+ public void setDocumentType(String documentType) {
+ this.documentType = documentType;
+ }
+
+ public Boolean getPrint() {
+ return print;
+ }
+
+ public void setPrint(Boolean print) {
+ this.print = print;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/request/PostedDataEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/request/PostedDataEntity.java
new file mode 100644
index 0000000..cf02445
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/request/PostedDataEntity.java
@@ -0,0 +1,183 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.groupdocs.ui.annotation.entity.request;
+
+import java.util.List;
+
+/**
+ *
+ * @author AlexT
+ */
+public class PostedDataEntity {
+ /**
+ *
+ * Absolute path to the posted document.
+ *
+ * @return
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ *
+ * Absolute path to the posted document.
+ *
+ * @param value
+ */
+ public void setPath(String value) {
+ path = value;
+ }
+ private String path;
+
+ /**
+ *
+ * Absolute path to the document.
+ *
+ * @return
+ */
+ public String getGuid() {
+ return guid;
+ }
+
+ /**
+ *
+ * Absolute path to the document.
+ *
+ * @param value
+ */
+ public void setGuid(String value) {
+ guid = value;
+ }
+ private String guid;
+
+ /**
+ *
+ * Document password.
+ *
+ * @return
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ *
+ * Document password.
+ *
+ * @param value
+ */
+ public void setPassword(String value) {
+ password = value;
+ }
+ private String password;
+
+ /**
+ *
+ * Url of the posted file.
+ *
+ * @return
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ /**
+ *
+ * Url of the posted file.
+ *
+ * @param value
+ */
+ public void setUrl(String value) {
+ url = value;
+ }
+ private String url;
+
+ /**
+ *
+ * Page number.
+ *
+ * @return
+ */
+ public int getPage() {
+ return page;
+ }
+
+ /**
+ *
+ * Page number.
+ *
+ * @param value
+ */
+ public void setPage(int value) {
+ page = value;
+ }
+ private int page;
+
+ /**
+ *
+ * Page rotation angle.
+ *
+ * @return
+ */
+ public int getAngle() {
+ return angle;
+ }
+
+ /**
+ *
+ * Page rotation angle.
+ *
+ * @param value
+ */
+ public void setAngle(int value) {
+ angle = value;
+ }
+ private int angle;
+
+ /**
+ *
+ * Collection of the document pages with their data.
+ *
+ * @return
+ */
+ public List getPages() {
+ return pages;
+ }
+
+ /**
+ *
+ * Collection of the document pages with their data.
+ *
+ * @param value
+ */
+ public void setPages(List value) {
+ pages = value;
+ }
+
+ private List pages;
+
+ /**
+ *
+ * Flag indicating whether the file should be overwritten.
+ *
+ * @return
+ */
+ public boolean getRewrite() {
+ return rewrite;
+ }
+
+ /**
+ *
+ * Flag indicating whether the file should be overwritten.
+ *
+ * @param value
+ */
+ public void setRewrite(boolean value) {
+ rewrite = value;
+ }
+ private boolean rewrite;
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotatedDocumentEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotatedDocumentEntity.java
new file mode 100644
index 0000000..143983a
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotatedDocumentEntity.java
@@ -0,0 +1,48 @@
+package com.groupdocs.ui.annotation.entity.web;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * AnnotatedDocumentEntity
+ *
+ * @author Aspose Pty Ltd
+ */
+public class AnnotatedDocumentEntity extends PageDescriptionEntity {
+ /**
+ * Document Guid
+ */
+ private String guid;
+ /**
+ * List of supported types of annotations
+ */
+ public String[] supportedAnnotations;
+ /**
+ * list of pages
+ */
+ private List pages = new ArrayList<>();;
+
+ public String getGuid() {
+ return guid;
+ }
+
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ public String[] getSupportedAnnotations() {
+ return supportedAnnotations;
+ }
+
+ public void setSupportedAnnotations(String[] supportedAnnotations) {
+ this.supportedAnnotations = supportedAnnotations;
+ }
+
+ public List getPages() {
+ return pages;
+ }
+
+ public void setPages(List pages) {
+ this.pages = pages;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotationDataEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotationDataEntity.java
new file mode 100644
index 0000000..bbca6ae
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotationDataEntity.java
@@ -0,0 +1,177 @@
+package com.groupdocs.ui.annotation.entity.web;
+
+/**
+ * AnnotationDataEntity
+ *
+ * @author Aspose Pty Ltd
+ */
+public class AnnotationDataEntity {
+ /**
+ * Annotation Id
+ */
+ private Integer id;
+ /**
+ * The number of page in document
+ */
+ private Integer pageNumber;
+ /**
+ * The size of font of annotation
+ */
+ private Double fontSize;
+ /**
+ * Annotation position. Left position.
+ */
+ private float left;
+ /**
+ * Annotation position. Top position.
+ */
+ private float top;
+ /**
+ * Annotation position. Width of annotation.
+ */
+ private float width;
+ /**
+ * Annotation position. Height of annotation.
+ */
+ private float height;
+ /**
+ * SVG path
+ */
+ private String svgPath;
+ /**
+ * The type of annotation (text, watermark, ect)
+ */
+ private String type;
+ /**
+ * Annotation text
+ */
+ private String text;
+ /**
+ * The annotation font
+ */
+ private String font;
+ /**
+ * List of comments in annotation
+ */
+ private CommentsEntity[] comments;
+ /**
+ * Imported annotations
+ */
+ private boolean imported;
+ /**
+ * font color
+ */
+ private Integer fontColor;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public Integer getPageNumber() {
+ return pageNumber;
+ }
+
+ public void setPageNumber(Integer pageNumber) {
+ this.pageNumber = pageNumber;
+ }
+
+ public Double getFontSize() {
+ return fontSize;
+ }
+
+ public void setFontSize(Double fontSize) {
+ this.fontSize = fontSize;
+ }
+
+ public float getLeft() {
+ return left;
+ }
+
+ public void setLeft(float left) {
+ this.left = left;
+ }
+
+ public float getTop() {
+ return top;
+ }
+
+ public void setTop(float top) {
+ this.top = top;
+ }
+
+ public float getWidth() {
+ return width;
+ }
+
+ public void setWidth(float width) {
+ this.width = width;
+ }
+
+ public float getHeight() {
+ return height;
+ }
+
+ public void setHeight(float height) {
+ this.height = height;
+ }
+
+ public String getSvgPath() {
+ return svgPath;
+ }
+
+ public void setSvgPath(String svgPath) {
+ this.svgPath = svgPath;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getFont() {
+ return font;
+ }
+
+ public void setFont(String font) {
+ this.font = font;
+ }
+
+ public CommentsEntity[] getComments() {
+ return comments;
+ }
+
+ public void setComments(CommentsEntity[] comments) {
+ this.comments = comments;
+ }
+
+ public boolean isImported() {
+ return imported;
+ }
+
+ public void setImported(boolean imported) {
+ this.imported = imported;
+ }
+
+ public Integer getFontColor() {
+ return fontColor;
+ }
+
+ public void setFontColor(Integer fontColor) {
+ this.fontColor = fontColor;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotationPostedDataEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotationPostedDataEntity.java
new file mode 100644
index 0000000..5df2967
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotationPostedDataEntity.java
@@ -0,0 +1,42 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.groupdocs.ui.annotation.entity.web;
+
+import com.groupdocs.ui.annotation.entity.request.PostedDataEntity;
+
+/**
+ *
+ * @author AlexT
+ */
+public class AnnotationPostedDataEntity extends PostedDataEntity {
+
+ public final String getDocumentType() {
+ return documentType;
+ }
+
+ public final void setDocumentType(String value) {
+ documentType = value;
+ }
+ private String documentType;
+
+ public final AnnotationDataEntity[] getAnnotationsData() {
+ return annotationsData;
+ }
+
+ public final void setAnnotationsData(AnnotationDataEntity[] value) {
+ annotationsData = value;
+ }
+ private AnnotationDataEntity[] annotationsData;
+
+ public final boolean getPrint() {
+ return print;
+ }
+
+ public final void setPrint(boolean value) {
+ print = value;
+ }
+ private boolean print;
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/CommentsEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/CommentsEntity.java
new file mode 100644
index 0000000..30fd005
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/CommentsEntity.java
@@ -0,0 +1,45 @@
+package com.groupdocs.ui.annotation.entity.web;
+
+/**
+ * CommentsEntity
+ *
+ * @author Aspose Pty Ltd
+ */
+public class CommentsEntity {
+ private Integer id;
+ private String time;
+ private String text;
+ private String userName;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getTime() {
+ return time;
+ }
+
+ public void setTime(String time) {
+ this.time = time;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/PageDataDescriptionEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/PageDataDescriptionEntity.java
new file mode 100644
index 0000000..3b27c48
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/PageDataDescriptionEntity.java
@@ -0,0 +1,26 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.groupdocs.ui.annotation.entity.web;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+/**
+ *
+ * @author AlexT
+ */
+public class PageDataDescriptionEntity extends PageDescriptionEntity {
+ @JsonProperty
+ private List annotations; // AnnotationDataEntity[] => List
+
+ public final void setAnnotations(List annotations) {
+ this.annotations = annotations;
+ }
+
+ public final List getAnnotations() {
+ return annotations;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/PageDescriptionEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/PageDescriptionEntity.java
new file mode 100644
index 0000000..f54bd66
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/entity/web/PageDescriptionEntity.java
@@ -0,0 +1,61 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.groupdocs.ui.annotation.entity.web;
+
+/**
+ *
+ * @author AlexT
+ */
+public class PageDescriptionEntity {
+ /**
+ * Page data
+ */
+ private String data;
+ private int angle;
+ private double width;
+ private double height;
+ private int number;
+
+ public int getAngle() {
+ return angle;
+ }
+
+ public void setAngle(int angle) {
+ this.angle = angle;
+ }
+
+ public double getWidth() {
+ return width;
+ }
+
+ public void setWidth(double width) {
+ this.width = width;
+ }
+
+ public double getHeight() {
+ return height;
+ }
+
+ public void setHeight(double height) {
+ this.height = height;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/resources/AnnotationResources.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/resources/AnnotationResources.java
new file mode 100644
index 0000000..d9fdfbf
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/resources/AnnotationResources.java
@@ -0,0 +1,187 @@
+package com.groupdocs.ui.annotation.resources;
+
+import com.groupdocs.ui.annotation.config.AnnotationConfigurationModel;
+import com.groupdocs.ui.annotation.entity.web.AnnotatedDocumentEntity;
+import com.groupdocs.ui.annotation.entity.web.AnnotationPostedDataEntity;
+import com.groupdocs.ui.annotation.entity.web.PageDataDescriptionEntity;
+import com.groupdocs.ui.annotation.service.AnnotationService;
+import com.groupdocs.ui.annotation.service.AnnotationServiceImpl;
+import com.groupdocs.ui.annotation.views.Annotation;
+import com.groupdocs.ui.common.config.GlobalConfiguration;
+import com.groupdocs.ui.common.entity.web.FileDescriptionEntity;
+import com.groupdocs.ui.common.entity.web.UploadedDocumentEntity;
+import com.groupdocs.ui.common.entity.web.request.FileTreeRequest;
+import com.groupdocs.ui.common.entity.web.request.LoadDocumentPageRequest;
+import com.groupdocs.ui.common.entity.web.request.LoadDocumentRequest;
+import com.groupdocs.ui.common.resources.Resources;
+import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
+import org.glassfish.jersey.media.multipart.FormDataParam;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.*;
+import javax.ws.rs.core.Context;
+import java.io.*;
+import java.net.UnknownHostException;
+import java.util.*;
+import static javax.ws.rs.core.MediaType.*;
+
+
+/**
+ * AnnotationResources
+ *
+ * @author Aspose Pty Ltd
+ */
+@Path(value = "/annotation")
+public class AnnotationResources extends Resources {
+ private static final Logger logger = LoggerFactory.getLogger(AnnotationResources.class);
+
+ private AnnotationService annotationService;
+
+ /**
+ * Constructor
+ *
+ * @param globalConfiguration global configuration object
+ * @throws UnknownHostException
+ */
+ public AnnotationResources(GlobalConfiguration globalConfiguration) throws UnknownHostException {
+ super(globalConfiguration);
+
+ annotationService = new AnnotationServiceImpl(globalConfiguration);
+ }
+
+ /**
+ * Get and set annotation page
+ *
+ * @return html view
+ */
+ @GET
+ public Annotation getView() {
+ // initiate index page
+ return new Annotation(globalConfiguration, DEFAULT_CHARSET);
+ }
+
+ @GET
+ @Path(value = "/loadConfig")
+ @Produces(APPLICATION_JSON)
+ public AnnotationConfigurationModel loadConfig() {
+ return AnnotationConfigurationModel.createAnnotationConfiguration(annotationService.getAnnotationConfiguration(), globalConfiguration.getCommon());
+ }
+
+ /**
+ * Get files and directories
+ *
+ * @param fileTreeRequest request's object with specified path
+ * @return files and directories list
+ */
+ @POST
+ @Path(value = "/loadFileTree")
+ @Produces(APPLICATION_JSON)
+ @Consumes(APPLICATION_JSON)
+ public List loadFileTree(FileTreeRequest fileTreeRequest) {
+ return annotationService.getFileList(fileTreeRequest);
+ }
+
+ /**
+ * Get document description
+ *
+ * @param loadDocumentRequest
+ * @return document description
+ */
+ @POST
+ @Path(value = "/loadDocumentDescription")
+ @Produces(APPLICATION_JSON)
+ @Consumes(APPLICATION_JSON)
+ public AnnotatedDocumentEntity loadDocumentDescription(LoadDocumentRequest loadDocumentRequest) {
+ return annotationService.getDocumentDescription(loadDocumentRequest);
+ }
+
+ /**
+ * Get document page
+ *
+ * @return document page
+ */
+ @POST
+ @Path(value = "/loadDocumentPage")
+ @Produces(APPLICATION_JSON)
+ @Consumes(APPLICATION_JSON)
+ public PageDataDescriptionEntity loadDocumentPage(LoadDocumentPageRequest loadDocumentPageRequest) {
+ return annotationService.getDocumentPage(loadDocumentPageRequest);
+ }
+
+ /**
+ * Download document
+ *
+ * @param documentGuid path to document parameter
+ * @param response
+ */
+ @GET
+ @Path(value = "/downloadDocument")
+ @Produces(APPLICATION_OCTET_STREAM)
+ public void downloadDocument(@QueryParam("path") String documentGuid,
+ @Context HttpServletResponse response) {
+ // download the file
+ downloadFile(response, documentGuid);
+ }
+
+ /**
+ * Upload document
+ *
+ * @param inputStream file content
+ * @param fileDetail file description
+ * @param documentUrl url for document
+ * @param rewrite flag for rewriting file
+ * @return uploaded document object (the object contains uploaded document guid)
+ */
+ @POST
+ @Path(value = "/uploadDocument")
+ @Produces(APPLICATION_JSON)
+ @Consumes(MULTIPART_FORM_DATA)
+ public UploadedDocumentEntity uploadDocument(@FormDataParam("file") InputStream inputStream,
+ @FormDataParam("file") FormDataContentDisposition fileDetail,
+ @FormDataParam("url") String documentUrl,
+ @FormDataParam("rewrite") Boolean rewrite) {
+ // upload file
+ String pathname = uploadFile(documentUrl, inputStream, fileDetail, rewrite, null);
+ // create response
+ UploadedDocumentEntity uploadedDocument = new UploadedDocumentEntity();
+ uploadedDocument.setGuid(pathname);
+ return uploadedDocument;
+
+ }
+
+ @Override
+ protected String getStoragePath(Map params) {
+ return globalConfiguration.getAnnotation().getFilesDirectory();
+ }
+
+ /**
+ * Annotate document
+ *
+ * @param annotateDocumentRequest
+ * @return annotated document info
+ */
+ @POST
+ @Path(value = "/annotate")
+ @Produces(APPLICATION_JSON)
+ @Consumes(APPLICATION_JSON)
+ public AnnotatedDocumentEntity annotate(AnnotationPostedDataEntity annotateDocumentRequest) {
+ return annotationService.annotate(annotateDocumentRequest);
+ }
+
+
+ /**
+ * Download document
+ *
+ * @param documentGuid path to document parameter
+ * @param response
+ */
+ @GET
+ @Path(value = "/downloadAnnotated")
+ @Produces(APPLICATION_OCTET_STREAM)
+ public void downloadAnnotated(@QueryParam("path") String documentGuid,
+ @Context HttpServletResponse response) {
+ // download the file
+ downloadFile(response, documentGuid);
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/service/AnnotationService.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/service/AnnotationService.java
new file mode 100644
index 0000000..3be6c20
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/service/AnnotationService.java
@@ -0,0 +1,72 @@
+package com.groupdocs.ui.annotation.service;
+
+import com.groupdocs.ui.annotation.config.AnnotationConfiguration;
+import com.groupdocs.ui.annotation.entity.web.AnnotatedDocumentEntity;
+import com.groupdocs.ui.annotation.entity.web.AnnotationPostedDataEntity;
+import com.groupdocs.ui.annotation.entity.web.PageDataDescriptionEntity;
+import com.groupdocs.ui.common.config.GlobalConfiguration;
+import com.groupdocs.ui.common.entity.web.FileDescriptionEntity;
+import com.groupdocs.ui.common.entity.web.request.FileTreeRequest;
+import com.groupdocs.ui.common.entity.web.request.LoadDocumentPageRequest;
+import com.groupdocs.ui.common.entity.web.request.LoadDocumentRequest;
+import java.io.InputStream;
+import java.util.List;
+
+/**
+ * Service for annotating documents
+ */
+public interface AnnotationService {
+ /**
+ * Get global configuration
+ *
+ * @return global configuration
+ */
+ GlobalConfiguration getGlobalConfiguration();
+
+ /**
+ * Get annotation configuration
+ *
+ * @return annotation configuration
+ */
+ AnnotationConfiguration getAnnotationConfiguration();
+
+ /**
+ * Get list of files and folders
+ *
+ * @param fileTreeRequest request object with path for loading list of files
+ * @return list of files and folders
+ */
+ List getFileList(FileTreeRequest fileTreeRequest);
+
+ /**
+ * Get document information
+ *
+ * @param loadDocumentRequest request object with document guid
+ * @return document with list of pages
+ */
+ AnnotatedDocumentEntity getDocumentDescription(LoadDocumentRequest loadDocumentRequest);
+
+ /**
+ * Load document page
+ *
+ * @param loadDocumentPageRequest request object with document guid and page number
+ * @return document page data
+ */
+ PageDataDescriptionEntity getDocumentPage(LoadDocumentPageRequest loadDocumentPageRequest);
+
+ /**
+ * Annotate document
+ *
+ * @param annotateDocumentRequest request object with document guid and annotations data
+ * @return annotated document
+ */
+ AnnotatedDocumentEntity annotate(AnnotationPostedDataEntity annotateDocumentRequest);
+
+ /**
+ * Annotate document by streams
+ *
+ * @param annotateDocumentRequest request object with document guid and annotations data
+ * @return stream of annotated document
+ */
+ InputStream annotateByStream(AnnotationPostedDataEntity annotateDocumentRequest);
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/service/AnnotationServiceImpl.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/service/AnnotationServiceImpl.java
new file mode 100644
index 0000000..ee15f59
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/service/AnnotationServiceImpl.java
@@ -0,0 +1,542 @@
+package com.groupdocs.ui.annotation.service;
+
+import com.groupdocs.annotation.licenses.License;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.IDocumentInfo;
+import com.groupdocs.annotation.exceptions.AnnotatorException;
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.options.LoadOptions;
+import com.groupdocs.annotation.options.pagepreview.PreviewFormats;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.annotation.options.export.SaveOptions;
+import com.groupdocs.annotation.options.pagepreview.CreatePageStream;
+import com.groupdocs.annotation.options.pagepreview.PreviewOptions;
+import com.groupdocs.ui.annotation.annotator.AnnotatorFactory;
+import com.groupdocs.ui.annotation.annotator.BaseAnnotator;
+import com.groupdocs.ui.annotation.config.AnnotationConfiguration;
+import com.groupdocs.ui.annotation.entity.web.AnnotatedDocumentEntity;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.AnnotationPostedDataEntity;
+import com.groupdocs.ui.annotation.entity.web.PageDataDescriptionEntity;
+import com.groupdocs.ui.common.config.GlobalConfiguration;
+import com.groupdocs.ui.annotation.util.AnnotationMapper;
+import com.groupdocs.ui.annotation.util.DocumentTypesConverter;
+import com.groupdocs.ui.annotation.util.SupportedAnnotations;
+import com.groupdocs.ui.common.entity.web.FileDescriptionEntity;
+import com.groupdocs.ui.common.entity.web.request.FileTreeRequest;
+import com.groupdocs.ui.common.entity.web.request.LoadDocumentPageRequest;
+import com.groupdocs.ui.common.entity.web.request.LoadDocumentRequest;
+import com.groupdocs.ui.common.exception.TotalGroupDocsException;
+
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Iterator;
+
+import org.apache.commons.lang3.StringUtils;
+
+public class AnnotationServiceImpl implements AnnotationService {
+
+ private static final Logger logger = LoggerFactory.getLogger(AnnotationServiceImpl.class);
+ private final List SupportedImageFormats = new ArrayList<>();
+
+ private GlobalConfiguration globalConfiguration;
+
+ private AnnotationConfiguration annotationConfiguration;
+
+ private final List annotationPageDescriptionEntityList = new ArrayList<>();
+
+ public AnnotationServiceImpl(GlobalConfiguration globalConfiguration) {
+ this.annotationConfiguration = globalConfiguration.getAnnotation();
+ this.globalConfiguration = globalConfiguration;
+ try {
+ SupportedImageFormats.add(".bmp");
+ SupportedImageFormats.add(".jpeg");
+ SupportedImageFormats.add(".jpg");
+ SupportedImageFormats.add(".tiff");
+ SupportedImageFormats.add(".tif");
+ SupportedImageFormats.add(".png");
+ SupportedImageFormats.add(".dwg");
+ SupportedImageFormats.add(".dcm");
+ SupportedImageFormats.add(".dxf");
+
+ // set GroupDocs license
+ License license = new License();
+ license.setLicense(globalConfiguration.getApplication().getLicensePath());
+ } catch (Throwable exc) {
+ logger.error("Can not verify Annotation license!");
+ }
+ }
+
+ @Override
+ public GlobalConfiguration getGlobalConfiguration() {
+ return globalConfiguration;
+ }
+
+ @Override
+ public AnnotationConfiguration getAnnotationConfiguration() {
+ return annotationConfiguration;
+ }
+
+ @Override
+ public List getFileList(FileTreeRequest fileTreeRequest) {
+ String path = fileTreeRequest.getPath();
+ if (StringUtils.isEmpty(path)) {
+ path = annotationConfiguration.getFilesDirectory();
+ }
+ try {
+ File directory = new File(path);
+ List filesList = Arrays.asList(directory.listFiles());
+
+ List fileList = getFileDescriptionEntities(filesList);
+ return fileList;
+ } catch (Exception ex) {
+ logger.error("Exception in getting file list", ex);
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+
+ public List getFileDescriptionEntities(List filesList) {
+ List fileList = new ArrayList<>();
+ for (File file : filesList) {
+ String guid = file.getAbsolutePath();
+ String extension = FilenameUtils.getExtension(guid);
+ if (file.isDirectory() || (!StringUtils.isEmpty(extension))) {
+ FileDescriptionEntity fileDescription = new FileDescriptionEntity();
+ fileDescription.setGuid(guid);
+ fileDescription.setName(file.getName());
+ fileDescription.setDirectory(file.isDirectory());
+ fileDescription.setSize(file.length());
+ fileList.add(fileDescription);
+ }
+ }
+ return fileList;
+ }
+
+ @Override
+ public AnnotatedDocumentEntity getDocumentDescription(LoadDocumentRequest loadDocumentRequest) {
+ try {
+ return loadDocument(
+ loadDocumentRequest,
+ annotationConfiguration.getPreloadPageCount() == 0
+ );
+ } catch (Throwable ex) {
+ throw new TotalGroupDocsException(ex.getMessage());
+ }
+ }
+
+ public final AnnotatedDocumentEntity loadDocument(LoadDocumentRequest loadDocumentRequest, boolean loadAllPages) {
+ Annotator annotator = null;
+ AnnotatedDocumentEntity description = new AnnotatedDocumentEntity();
+ String guid = loadDocumentRequest.getGuid();
+ String password = loadDocumentRequest.getPassword();
+ LoadOptions loadOptions = new LoadOptions();
+ loadOptions.setPassword(password);
+
+ try {
+ annotator = new Annotator(guid, loadOptions);
+
+ IDocumentInfo info = null;
+ try {
+ info = annotator.getDocument().getDocumentInfo();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ List annotations = annotator.get();
+
+ description.setGuid(loadDocumentRequest.getGuid());
+
+ String documentType = "";
+ if (info.getFileType() != null) {
+ documentType = SupportedImageFormats.contains(info.getFileType().getExtension()) ? "image" : info.getFileType().toString();
+ } else {
+ documentType = "Portable Document Format";
+ }
+
+ description.supportedAnnotations = SupportedAnnotations.getSupportedAnnotations(documentType);
+
+ List pagesContent = new ArrayList<>();
+
+ if (loadAllPages) {
+ pagesContent = getAllPagesContent(password, guid, info);
+ }
+ for (int i = 0; i < info.getPageCount(); i++) {
+ PageDataDescriptionEntity page = new PageDataDescriptionEntity();
+ page.setNumber(i + 1);
+ page.setHeight(info.getPagesInfo().get(i).getHeight());
+ page.setWidth(info.getPagesInfo().get(i).getWidth());
+
+ if (annotations != null && annotations.size() > 0) {
+ page.setAnnotations(AnnotationMapper.mapForPage(annotations, i + 1, info.getPagesInfo().get(i)));
+ }
+
+ if (pagesContent.size() > 0) {
+ page.setData(pagesContent.get(i));
+ }
+ description.getPages().add(page);
+ }
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+
+ description.setGuid(guid);
+ // return document description
+ return description;
+ }
+
+ public static String getStringFromStream(InputStream inputStream) throws IOException {
+ inputStream.reset();
+ inputStream.skip(0);
+
+ byte[] bytes = IOUtils.toByteArray(inputStream);
+ // encode ByteArray into String
+ return Base64.getEncoder().encodeToString(bytes);
+ }
+
+ @Override
+ public PageDataDescriptionEntity getDocumentPage(LoadDocumentPageRequest loadDocumentPageRequest) {
+ String password = "";
+ try {
+ // get/set parameters
+ String documentGuid = loadDocumentPageRequest.getGuid();
+ int pageNumber = loadDocumentPageRequest.getPage();
+ password = loadDocumentPageRequest.getPassword();
+ PageDataDescriptionEntity loadedPage = new PageDataDescriptionEntity();
+
+ // get page image
+ byte[] bytes;
+
+ final Annotator annotator = new Annotator(documentGuid, getLoadOptions(password));
+ try {
+ final OutputStream renderPage = renderPageToMemoryStream(pageNumber, documentGuid, password);
+
+ ByteArrayOutputStream bufferRenderPage = (ByteArrayOutputStream) renderPage;
+ byte[] bytesRenderPage = bufferRenderPage.toByteArray();
+ InputStream streamRenderPage = new ByteArrayInputStream(bytesRenderPage);
+
+ try {
+ bytes = IOUtils.toByteArray(streamRenderPage);
+ } finally {
+ if (streamRenderPage != null) {
+ streamRenderPage.close();
+ }
+ }
+
+ IDocumentInfo info = annotator.getDocument().getDocumentInfo();
+ List annotations = annotator.get();
+
+ if (annotations != null && annotations.size() > 0) {
+ loadedPage.setAnnotations(AnnotationMapper.mapForPage(annotations, pageNumber, info.getPagesInfo().get(pageNumber - 1)));
+ }
+
+ String encodedImage = Base64.getEncoder().encodeToString(bytes);
+ loadedPage.setData(encodedImage);
+
+ loadedPage.setHeight(info.getPagesInfo().get(pageNumber - 1).getHeight());
+ loadedPage.setWidth(info.getPagesInfo().get(pageNumber - 1).getWidth());
+ loadedPage.setNumber(pageNumber);
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+
+ // return loaded page object
+ return loadedPage;
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex.getMessage());
+ }
+ }
+
+ private static OutputStream renderPageToMemoryStream(int pageNumberToRender, String documentGuid, String password) {
+ try {
+ OutputStream result = new ByteArrayOutputStream(); // MemoryStream => OutputStream
+ InputStream inputStream = new FileInputStream(documentGuid); //final FileStream outputStream = File.openRead(documentGuid);
+ try {
+ final Annotator annotator = new Annotator(inputStream, getLoadOptions(password));
+ try {
+ PreviewOptions previewOptions = new PreviewOptions( //PreviewOptions previewOptions = new PreviewOptions((pageNumber) = > result);
+ new CreatePageStream() {
+ @Override
+ public OutputStream invoke(int pageNumber) {
+ return result;
+ }
+ }
+ );
+ previewOptions.setPreviewFormat(PreviewFormats.PNG);
+ previewOptions.setPageNumbers(new int[]{pageNumberToRender});
+ previewOptions.setRenderComments(false);
+
+ annotator.getDocument().generatePreview(previewOptions);
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+ return result;
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex.getMessage());
+ }
+ }
+
+ private static LoadOptions getLoadOptions(String password) {
+ LoadOptions loadOptions = new LoadOptions();
+ loadOptions.setPassword(password);
+ return loadOptions;
+ }
+
+ public InputStream annotateDocument(String documentGuid, String documentType, List annotations) throws FileNotFoundException {
+ Annotator annotator = new Annotator(documentGuid);
+
+ SaveOptions saveOptions = new SaveOptions();
+ saveOptions.setAnnotationTypes(AnnotationType.NONE);
+
+ annotator.save(documentGuid, saveOptions);
+
+ if (annotations.size() > 0) {
+ annotator.add(annotations);
+ annotator.save(documentGuid, new SaveOptions());
+ }
+
+ return new FileInputStream(documentGuid);
+ }
+
+ @Override
+ public AnnotatedDocumentEntity annotate(AnnotationPostedDataEntity annotateDocumentRequest) {
+ AnnotatedDocumentEntity annotatedDocument = new AnnotatedDocumentEntity();
+ try {
+ // get/set parameters
+ String documentGuid = annotateDocumentRequest.getGuid();
+ String password = annotateDocumentRequest.getPassword();
+
+ //String documentType1 = DocumentTypesConverter.checkedDocumentType(documentGuid, annotateDocumentRequest.getDocumentType());
+ String documentType = SupportedImageFormats.contains(
+ FilenameUtils.getExtension(annotateDocumentRequest.getGuid())
+ ) ? "image" : annotateDocumentRequest.getDocumentType();
+
+ String tempPath = getTempPath(documentGuid);
+
+ AnnotationDataEntity[] annotationsData = annotateDocumentRequest.getAnnotationsData();
+ // initiate list of annotations to add
+ List annotations = new ArrayList<>();
+
+ final Annotator annotator = new Annotator(documentGuid, getLoadOptions(password));
+ try {
+ IDocumentInfo info = annotator.getDocument().getDocumentInfo();
+
+ for (int i = 0; i < annotationsData.length; i++) {
+ AnnotationDataEntity annotationData = annotationsData[i];
+ PageInfo pageInfo = info.getPagesInfo().get(annotationsData[i].getPageNumber() - 1);
+ // add annotation, if current annotation type isn't supported by the current document type it will be ignored
+ try {
+ BaseAnnotator baseAnnotator = AnnotatorFactory.createAnnotator(annotationData, pageInfo);
+ if (baseAnnotator.isSupported(documentType)) {
+ annotations.add(baseAnnotator.getAnnotationBase(documentType));
+ }
+ } catch (java.lang.RuntimeException ex) {
+ throw new AnnotatorException(ex.getMessage(), ex);
+ }
+ }
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+
+ // Add annotation to the document
+ removeAnnotations(documentGuid, password);
+ // check if annotations array contains at least one annotation to add
+ if (annotations.size() != 0) {
+ final Annotator annotator1 = new Annotator(documentGuid, getLoadOptions(password));
+ try {
+ //foreach to while statements conversion
+ Iterator tmp0 = (annotations).iterator();
+
+ while (tmp0.hasNext()) {
+ AnnotationBase annotation = (AnnotationBase) tmp0.next();
+ annotator1.add(annotation);
+ }
+
+ annotator1.save(tempPath);
+ } finally {
+ if (annotator1 != null) {
+ annotator1.dispose();
+ }
+ }
+
+ try (OutputStream fileStream = new FileOutputStream(documentGuid)) {
+ InputStream inputStream1 = new FileInputStream(tempPath);
+ IOUtils.copyLarge(inputStream1, fileStream);
+ }
+ }
+
+ annotatedDocument = new AnnotatedDocumentEntity();
+ annotatedDocument.setGuid(documentGuid);
+ if (annotateDocumentRequest.getPrint()) {
+ annotatedDocument.setPages(getAnnotatedPagesForPrint(password, documentGuid));
+ Files.move(Paths.get(documentGuid), Paths.get(annotateDocumentRequest.getGuid()));
+ }
+ } catch (Exception ex) {
+ // set exception message
+ throw new TotalGroupDocsException(ex.getMessage());
+ }
+
+ return annotatedDocument;
+
+ }
+
+ private List getAnnotatedPagesForPrint(String password, String documentGuid) {
+ AnnotatedDocumentEntity description = new AnnotatedDocumentEntity();
+ try {
+ InputStream outputStream = new FileInputStream(documentGuid);
+ try {
+ final Annotator annotator = new Annotator(outputStream, getLoadOptions(password));
+ try {
+ IDocumentInfo info = annotator.getDocument().getDocumentInfo();
+ List pagesContent = getAllPagesContent(password, documentGuid, info);
+
+ for (int i = 0; i < info.getPageCount(); i++) {
+ PageDataDescriptionEntity page = new PageDataDescriptionEntity();
+
+ if (pagesContent.size() > 0) {
+ page.setData(pagesContent.get(i));
+ }
+
+ description.getPages().add(page);
+ }
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+ } finally {
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ }
+
+ return description.getPages();
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+
+ private static String getTempPath(String documentGuid) {
+ File fileName = new File(documentGuid);
+ return fileName.getParentFile().getPath() + "//tmp_" + fileName.getName();
+ }
+
+ public static void removeAnnotations(String documentGuid, String password) {
+ String tempPath = getTempPath(documentGuid);
+
+ try {
+ final InputStream inputStream = new FileInputStream(documentGuid);
+ //final Stream inputStream = File.open(documentGuid, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
+ try {
+ final Annotator annotator = new Annotator(inputStream, getLoadOptions(password));
+ try {
+ SaveOptions tmp0 = new SaveOptions();
+ tmp0.setAnnotationTypes(AnnotationType.NONE);
+ annotator.save(tempPath, tmp0);
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+
+
+ try (PrintWriter writer = new PrintWriter(documentGuid)) {
+ writer.print("");
+ }
+
+ try (OutputStream fileStream = new FileOutputStream(documentGuid)) {
+ InputStream inputStream1 = new FileInputStream(tempPath);
+ IOUtils.copyLarge(inputStream1, fileStream);
+ }
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+
+ private List getAllPagesContent(String password, String documentGuid, IDocumentInfo pages) {
+ List allPages = new ArrayList<>();
+
+ for (int i = 0; i < pages.getPageCount(); i++) {
+ byte[] bytes;
+ try (OutputStream memoryStream = renderPageToMemoryStream(i + 1, documentGuid, password)) {
+ ByteArrayOutputStream bos = (ByteArrayOutputStream) memoryStream;
+ bytes = bos.toByteArray(); //memoryStream.ToArray();
+ } catch (IOException ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+
+ String encodedImage = new String(Base64.getEncoder().encode(bytes)); //Convert.ToBase64String(bytes);
+ allPages.add(encodedImage);
+ }
+
+ return allPages;
+ }
+
+
+ public List getAnnotationInfos(AnnotationPostedDataEntity annotateDocumentRequest, String documentType) {
+ try {
+ AnnotationDataEntity[] annotationsData = annotateDocumentRequest.getAnnotationsData();
+ // get document info - required to get document page height and calculate annotation top position
+
+ List annotations = new ArrayList<>();
+ for (AnnotationDataEntity annotationData : annotationsData) {
+ // create annotator
+ // add annotation, if current annotation type isn't supported by the current document type it will be ignored
+ PageDataDescriptionEntity pageData = annotationPageDescriptionEntityList.get(annotationData.getPageNumber() - 1);
+
+ PageInfo pageInfo = new PageInfo();
+ pageInfo.setHeight((int) pageData.getHeight());
+ //pageInfo.setPageNumber(pageData.getNumber());
+ pageInfo.setWidth((int) pageData.getWidth());
+
+ try {
+ annotations.add(AnnotatorFactory.createAnnotator(annotationData, pageInfo).getAnnotationBase(documentType));
+ } catch (Throwable ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+ return annotations;
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+
+ @Override
+ public InputStream annotateByStream(AnnotationPostedDataEntity annotateDocumentRequest) {
+ String documentGuid = annotateDocumentRequest.getGuid();
+ String documentType = DocumentTypesConverter.checkedDocumentType(documentGuid, annotateDocumentRequest.getDocumentType());
+ List annotations = getAnnotationInfos(annotateDocumentRequest, documentType);
+ try {
+ return annotateDocument(documentGuid, documentType, annotations);
+ } catch (FileNotFoundException ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/AnnotationMapper.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/AnnotationMapper.java
new file mode 100644
index 0000000..52b9318
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/AnnotationMapper.java
@@ -0,0 +1,149 @@
+package com.groupdocs.ui.annotation.util;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.Point;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.IBox;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.IFontColor;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.IFontFamily;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.IFontSize;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.IPoints;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.ISvgPath;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.IText;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.ITextToReplace;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.CommentsEntity;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class AnnotationMapper {
+
+ private AnnotationMapper() {
+ }
+
+ /**
+ *
+ * Map AnnotationInfo instances into AnnotationDataEntity
+ *
+ *
+ * @param pageInfo
+ * @return
+ * @param annotations AnnotationInfo[]
+ * @param pageNumber int
+ */
+ // AnnotationDataEntity[] => List
+ public static List mapForPage(List annotations, int pageNumber, PageInfo pageInfo) { //AnnotationBase[] => List
+ // initiate annotations data array
+ List pageAnnotations = new ArrayList<>();
+ // each annotation data - this functionality used since annotations data returned by the
+ // GroupDocs.Annotation library are obfuscated
+ for (int n = 0; n < annotations.size(); n++) {
+ AnnotationBase annotationInfo = annotations.get(n);
+ if (pageNumber == annotationInfo.getPageNumber() + 1) {
+ AnnotationDataEntity annotation = mapAnnotationDataEntity(annotationInfo, pageInfo);
+ pageAnnotations.add(annotation);
+ }
+ }
+
+ return pageAnnotations;
+ }
+
+ /**
+ *
+ * Map AnnotationInfo instances into AnnotationDataEntity
+ *
+ *
+ * @param pageInfo
+ * @return AnnotationDataEntity
+ * @param annotationInfo AnnotationInfo
+ */
+ public static AnnotationDataEntity mapAnnotationDataEntity(AnnotationBase annotationInfo, PageInfo pageInfo) {
+ String annotationTypeName = AnnotationType.getName(annotationInfo.getType());
+ float maxY = 0, minY = Float.MAX_VALUE, maxX = 0, minX = Float.MAX_VALUE; // minY = 0, minX = 0
+ float boxX = 0, boxY = 0, boxHeight = 0, boxWidth = 0;
+ String svgPath = "";
+
+ if (annotationInfo instanceof IPoints) {
+ List points = ((IPoints)annotationInfo).getPoints();
+ for (Point point : points) {
+ maxY = point.getY() > maxY ? point.getY(): maxY;
+ maxX = point.getX() > maxX ? point.getX(): maxX;
+ minY = point.getY() < minY ? point.getY(): minY;
+ minX = point.getX() < minX ? point.getX(): minX;
+ }
+ }
+
+ if (annotationInfo instanceof IBox) {
+ Rectangle box = ((IBox)annotationInfo).getBox();
+ boxX = box.getX();
+ boxY = box.getY();
+ boxHeight = box.getHeight();
+ boxWidth = box.getWidth();
+
+ StringBuilder builder = new StringBuilder().
+ append("M").append(box.getX()).
+ append(",").append(box.getY()).
+ append("L").append(box.getWidth()).
+ append(",").append(box.getHeight());
+
+ svgPath = builder.toString();
+ }
+
+ AnnotationDataEntity annotation = new AnnotationDataEntity();
+ annotation.setFont(annotationInfo instanceof IFontFamily ? ((IFontFamily)annotationInfo).getFontFamily() : "");
+
+ Double fontSize = annotationInfo instanceof IFontSize ? (((IFontSize)annotationInfo).getFontSize() == null) ? 0.0 : ((IFontSize)annotationInfo).getFontSize() : 0.0;
+
+ annotation.setFontSize(fontSize);
+
+ annotation.setFontColor(
+ annotationInfo instanceof IFontColor ?
+ ((((IFontColor) annotationInfo).getFontColor() == null) ? 0 : (int)((IFontColor) annotationInfo).getFontColor())
+ : 0
+ );
+ annotation.setHeight(annotationInfo instanceof IBox ? boxHeight : (annotationInfo instanceof IPoints ? (maxY - minY) : 0));
+ annotation.setLeft(annotationInfo instanceof IBox ? boxX : (annotationInfo instanceof IPoints ? minX : 0));
+
+ annotation.setPageNumber((int)annotationInfo.getPageNumber() + 1);
+ annotation.setSvgPath(annotationInfo instanceof ISvgPath ? (((ISvgPath)annotationInfo).getSvgPath().replace("l", "L")) : svgPath);
+
+ String text = "";
+ if (annotationInfo.getMessage() == null && annotationInfo instanceof ITextToReplace) {
+ text = ((ITextToReplace) annotationInfo).getTextToReplace();
+ } else if (annotationInfo instanceof IText && ((IText) annotationInfo).getText() != null) {
+ text = ((IText) annotationInfo).getText();
+ } else if (annotationInfo.getMessage() != null) {
+ text = annotationInfo.getMessage();
+ }
+ annotation.setText(text);
+
+ // TODO: remove comment after check all annotations types on main formats
+ annotation.setTop(annotationInfo instanceof IBox ? boxY : (annotationInfo instanceof IPoints ? pageInfo.getHeight() - maxY : 0));
+ annotation.setType(annotationTypeName.toLowerCase());
+ annotation.setWidth(annotationInfo instanceof IBox ? boxWidth : (annotationInfo instanceof IPoints ? (maxX - minX) : 0));
+ // each reply data
+ List replies = annotationInfo.getReplies();
+ if (replies != null && replies.size() > 0) {
+ CommentsEntity[] comments = new CommentsEntity[replies.size()];
+ for (int m = 0; m < replies.size(); m++) {
+ CommentsEntity comment = new CommentsEntity();
+ Reply reply = replies.get(m);
+ comment.setText(reply.getComment());
+ DateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss"); //"yyyy-MM-dd HH:mm:ss"
+ comment.setTime(format.format(reply.getRepliedOn()));
+
+ comment.setUserName(reply.getUser().getName());
+ comments[m] = comment;
+ }
+ annotation.setComments(comments);
+ }
+
+ return annotation;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/AnnotationTypes.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/AnnotationTypes.java
new file mode 100644
index 0000000..6793ba5
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/AnnotationTypes.java
@@ -0,0 +1,57 @@
+package com.groupdocs.ui.annotation.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * AnnotationTypes
+ * Contains all annotations types
+ *
+ * @author Aspose Pty Ltd
+ */
+public class AnnotationTypes {
+
+ /**
+ * Map annotation types from byte into string
+ */
+ private static final Map types = new HashMap<>();
+
+ // init map values
+ {
+ types.put((byte) 0, "text");
+ types.put((byte) 1, "area");
+ types.put((byte) 2, "point");
+ types.put((byte) 3, "textStrikeout");
+ types.put((byte) 4, "polyline");
+ types.put((byte) 5, "textField");
+ types.put((byte) 6, "watermark");
+ types.put((byte) 7, "textReplacement");
+ types.put((byte) 8, "arrow");
+ types.put((byte) 9, "textRedaction");
+ types.put((byte) 10, "resourcesRedaction");
+ types.put((byte) 11, "textUnderline");
+ types.put((byte) 12, "distance");
+ }
+
+ /**
+ * Instance of AnnotationTypes
+ */
+ public static final AnnotationTypes instance = new AnnotationTypes();
+
+ /**
+ * Private constructor, for using only in this class
+ */
+ private AnnotationTypes() {
+ }
+
+ /**
+ * Get string value of annotation type
+ *
+ * @param type byte value of annotation type
+ * @return string value of annotation type
+ */
+ public String getAnnotationType(byte type) {
+ return types.get(type);
+ }
+}
+
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/DocumentTypesConverter.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/DocumentTypesConverter.java
new file mode 100644
index 0000000..bac184e
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/DocumentTypesConverter.java
@@ -0,0 +1,68 @@
+package com.groupdocs.ui.annotation.util;
+
+//import com.groupdocs.annotation.domain.DocumentType;
+
+import com.google.common.collect.Lists;
+import com.groupdocs.annotation.models.DocumentType;
+import static com.groupdocs.ui.common.util.Utils.parseFileExtension;
+import java.util.List;
+
+/**
+ * Converter for document types
+ */
+public class DocumentTypesConverter {
+
+ private static final List supportedImageFormats = Lists.newArrayList("bmp", "jpeg", "jpg", "tiff", "tif", "png", "gif", "emf", "wmf", "dwg", "dicom", "djvu");
+ private static final List supportedDiagramFormats = Lists.newArrayList(".vsd", ".vdx", ".vss", ".vsx", ".vst", ".vtx", ".vsdx", ".vdw", ".vstx", ".vssx");
+
+ /**
+ *
+ * Convert document type from string into int
+ *
+ *
+ * @return int
+ * @param documentType string
+ */
+// public static int getDocumentType(String documentType) {
+// switch (documentType) {
+// case "Portable Document Format":
+// case "PDF":
+// return DocumentType.Pdf;
+// case "Microsoft Word":
+// case "WORDS":
+// case "Microsoft Word Open XML format (.docx)":
+// return DocumentType.Words;
+// case "Microsoft PowerPoint":
+// case "SLIDES":
+// return DocumentType.Slides;
+// case "image":
+// return DocumentType.Images;
+// case "Microsoft Excel":
+// case "CELLS":
+// return DocumentType.Cells;
+// case "AutoCAD Drawing File Format":
+// case "diagram":
+// return DocumentType.Diagram;
+// default:
+// return DocumentType.Undefined;
+// }
+// }
+
+ /**
+ * Check image and diagram document types
+ *
+ * @param documentGuid document name
+ * @param documentType string value of document type
+ * @return correct document type
+ */
+ public static String checkedDocumentType(String documentGuid, String documentType) {
+ String fileExtension = parseFileExtension(documentGuid);
+ // check if document type is image
+ if (supportedImageFormats.contains(fileExtension)) {
+ documentType = "image";
+ } else if (supportedDiagramFormats.contains(fileExtension)) {
+ documentType = "diagram";
+ }
+ return documentType;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/SupportedAnnotations.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/SupportedAnnotations.java
new file mode 100644
index 0000000..f523ff4
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/SupportedAnnotations.java
@@ -0,0 +1,102 @@
+package com.groupdocs.ui.annotation.util;
+
+/**
+ * The list of supported annotation types for each document type
+ */
+public class SupportedAnnotations {
+ public static String[] CELLS = {
+ "text"
+ };
+ public static String[] DIAGRAM = {
+ "area",
+ "point",
+ "polyline",
+ "textField",
+ "arrow",
+ "textRedaction",
+ "resourcesRedaction",
+ "distance"
+ };
+ public static String[] WORD = {
+ "point",
+ "textStrikeout",
+ "polyline",
+ "textField",
+ "watermark",
+ "textReplacement",
+ "arrow",
+ "textRedaction",
+ "resourcesRedaction",
+ "textUnderline",
+ "distance",
+ "text"
+ };
+ public static String[] PDF = {
+ "area",
+ "point",
+ "textStrikeout",
+ "polyline",
+ "textField",
+ "watermark",
+ "textReplacement",
+ "arrow",
+ "textRedaction",
+ "resourcesRedaction",
+ "textUnderline",
+ "distance",
+ "text"
+ };
+ public static String[] IMAGE = {
+ "area",
+ "point",
+ "textStrikeout",
+ "polyline",
+ "textField",
+ "watermark",
+ "arrow",
+ "textRedaction",
+ "resourcesRedaction",
+ "textUnderline",
+ "distance",
+ "text"
+ };
+ public static String[] SLIDES = {
+ "area",
+ "point",
+ "textStrikeout",
+ "polyline",
+ "textField",
+ "watermark",
+ "arrow",
+ "textRedaction",
+ "resourcesRedaction",
+ "textUnderline",
+ "text"
+ };
+
+ public static String[] getSupportedAnnotations(String documentType) {
+ switch (documentType) {
+ case "Adobe Portable Document format":
+ case "Portable Document Format":
+ case "PDF":
+ return PDF;
+ case "Microsoft Word Open XML format":
+ case "Microsoft Word":
+ case "WORDS":
+ return WORD;
+ case "Microsoft PowerPoint":
+ case "SLIDES":
+ return SLIDES;
+ case "image":
+ return IMAGE;
+ case "Microsoft Excel":
+ case "CELLS":
+ return CELLS;
+ case "AutoCAD Drawing File Format":
+ case "diagram":
+ return DIAGRAM;
+ default:
+ return PDF;
+ }
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/DirectoryUtils.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/DirectoryUtils.java
new file mode 100644
index 0000000..6025fe0
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/DirectoryUtils.java
@@ -0,0 +1,28 @@
+package com.groupdocs.ui.annotation.util.directory;
+
+import com.groupdocs.ui.annotation.config.AnnotationConfiguration;
+
+/**
+ * DirectoryUtils
+ * Compare and sort file types - folders first
+ * @author Aspose Pty Ltd
+ */
+public class DirectoryUtils {
+ private FilesDirectoryUtils filesDirectory;
+
+ /**
+ * Constructor
+ * @param annotationConfiguration
+ */
+ public DirectoryUtils(AnnotationConfiguration annotationConfiguration){
+ filesDirectory = new FilesDirectoryUtils(annotationConfiguration);
+ }
+
+ /**
+ * Get files directory - path where all documents for signing are stored
+ * @return FilesDirectoryUtils
+ */
+ public FilesDirectoryUtils getFilesDirectory() {
+ return filesDirectory;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/FilesDirectoryUtils.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/FilesDirectoryUtils.java
new file mode 100644
index 0000000..160c080
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/FilesDirectoryUtils.java
@@ -0,0 +1,30 @@
+package com.groupdocs.ui.annotation.util.directory;
+
+import com.groupdocs.ui.annotation.config.AnnotationConfiguration;
+
+/**
+ * FilesDirectoryUtils
+ * Compare and sort file types - folders first
+ * @author Aspose Pty Ltd
+ */
+public class FilesDirectoryUtils implements IDirectoryUtils {
+ private AnnotationConfiguration annotationConfiguration;
+
+ /**
+ * Constructor
+ * @param annotationConfiguration
+ */
+ public FilesDirectoryUtils(AnnotationConfiguration annotationConfiguration){
+ this.annotationConfiguration = annotationConfiguration;
+ }
+
+ /**
+ * Get path for files directory
+ * @return path of the files directory
+ */
+ @Override
+ public String getPath() {
+ return annotationConfiguration.getFilesDirectory();
+ }
+
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/IDirectoryUtils.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/IDirectoryUtils.java
new file mode 100644
index 0000000..3bfe9d9
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/util/directory/IDirectoryUtils.java
@@ -0,0 +1,11 @@
+package com.groupdocs.ui.annotation.util.directory;
+
+/**
+ * IDirectoryUtils
+ * Compare and sort file types - folders first
+ * @author Aspose Pty Ltd
+ */
+public interface IDirectoryUtils {
+
+ String getPath();
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/views/Annotation.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/views/Annotation.java
new file mode 100644
index 0000000..d5452d8
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/annotation/views/Annotation.java
@@ -0,0 +1,43 @@
+package com.groupdocs.ui.annotation.views;
+
+import com.groupdocs.ui.common.config.GlobalConfiguration;
+import io.dropwizard.views.View;
+
+import java.nio.charset.Charset;
+
+/**
+ * Annotation
+ *
+ * @author Aspose Pty Ltd
+ */
+
+public class Annotation extends View {
+ private GlobalConfiguration globalConfiguration;
+
+ /**
+ * Constructor
+ * @param globalConfiguration total configuration
+ * @param charset charset
+ */
+ public Annotation(GlobalConfiguration globalConfiguration, String charset){
+ super("annotation.ftl", Charset.forName(charset));
+ this.globalConfiguration = globalConfiguration;
+ }
+
+ /**
+ * Get total config
+ * @return total config
+ */
+ public GlobalConfiguration getGlobalConfiguration() {
+ return globalConfiguration;
+ }
+
+ /**
+ * Set total config
+ * @param globalConfiguration total config
+ */
+ public void setGlobalConfiguration(GlobalConfiguration globalConfiguration) {
+ this.globalConfiguration = globalConfiguration;
+ }
+
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/MainService.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/MainService.java
new file mode 100644
index 0000000..76f92d6
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/MainService.java
@@ -0,0 +1,107 @@
+package com.groupdocs.ui.common;
+
+import com.google.common.collect.Sets;
+import com.groupdocs.ui.annotation.resources.AnnotationResources;
+import com.groupdocs.ui.common.config.GlobalConfiguration;
+import com.groupdocs.ui.common.exception.TotalGroupDocsExceptionMapper;
+import com.groupdocs.ui.common.health.TemplateHealthCheck;
+import io.dropwizard.Application;
+import io.dropwizard.assets.AssetsBundle;
+import io.dropwizard.configuration.ResourceConfigurationSourceProvider;
+import io.dropwizard.forms.MultiPartBundle;
+import io.dropwizard.setup.Bootstrap;
+import io.dropwizard.setup.Environment;
+import io.dropwizard.views.ViewBundle;
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.jetty.servlets.CrossOriginFilter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.DispatcherType;
+import javax.servlet.FilterRegistration;
+import java.io.File;
+import java.util.EnumSet;
+import java.util.HashSet;
+
+/**
+ * Main class
+ * Where all the magic starts
+ *
+ * @author Aspose Pty Ltd
+ */
+
+public class MainService extends Application {
+ private static final Logger logger = LoggerFactory.getLogger(MainService.class);
+
+ private static final String SERVER_COMMAND = "server";
+ private static final String CHECK_COMMAND = "check";
+ private static final HashSet COMMANDS = Sets.newHashSet(SERVER_COMMAND, CHECK_COMMAND);
+ private static final String DEFAULT_CONFIGURATION_FILE = "defaultConfiguration.yml";
+ private static final String EXTERNAL_CONFIGURATION_FILE = "configuration.yml";
+
+ private boolean defaultConfiguration;
+
+ public MainService() {
+ super();
+ defaultConfiguration = false;
+ }
+
+ public MainService(boolean defaultConfiguration) {
+ super();
+ this.defaultConfiguration = defaultConfiguration;
+ }
+
+ public static void main(String[] args) throws Exception {
+ if (args == null || args.length == 0 || (args.length == 1 && !COMMANDS.contains(args[0]))) {
+ logger.info("Command is not specified. Use default: server.");
+ args = args.length == 1 ? new String[]{SERVER_COMMAND, args[0]} : new String[]{SERVER_COMMAND, EXTERNAL_CONFIGURATION_FILE};
+ }
+ if (args.length > 1 && StringUtils.isNotEmpty(args[1]) && new File(args[1]).exists()) {
+ new MainService(false).run(args);
+ } else {
+ logger.info("Can not find external configuration file. Use default.");
+ String[] newArgs = new String[]{args[0], DEFAULT_CONFIGURATION_FILE};
+ new MainService(true).run(newArgs);
+ }
+ }
+
+ @Override
+ public void initialize(Bootstrap bootstrap) {
+ if (defaultConfiguration) {
+ bootstrap.setConfigurationSourceProvider(new ResourceConfigurationSourceProvider());
+ } else {
+ bootstrap.setConfigurationSourceProvider(new MergedConfigurationSourceProvider(DEFAULT_CONFIGURATION_FILE));
+ }
+ // add assets bundle in order to get resources from assets directory
+ bootstrap.addBundle(new AssetsBundle());
+ // init view bundle
+ bootstrap.addBundle(new ViewBundle());
+ // for injection file content in resource methods
+ bootstrap.addBundle(new MultiPartBundle());
+ }
+
+ @Override
+ public void run(GlobalConfiguration globalConfiguration, Environment environment) throws Exception {
+ // Enable CORS headers
+ final FilterRegistration.Dynamic cors = environment.servlets().addFilter("CORS", CrossOriginFilter.class);
+
+ // Configure CORS parameters
+ cors.setInitParameter("allowedOrigins", "*");
+ cors.setInitParameter("allowedHeaders", "X-Requested-With,Content-Type,Accept,Origin");
+ cors.setInitParameter("allowedMethods", "OPTIONS,GET,PUT,POST,DELETE,HEAD");
+
+ // Add URL mapping
+ cors.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true, "/*");
+
+ // Initiate resources (web pages)
+ environment.jersey().register(new AnnotationResources(globalConfiguration));
+
+ // Add custom exception mapper
+ environment.jersey().register(new TotalGroupDocsExceptionMapper());
+
+ // Add dummy health check to get rid of console warnings
+ // TODO: implement health check
+ final TemplateHealthCheck healthCheck = new TemplateHealthCheck("");
+ environment.healthChecks().register("HealthCheck", healthCheck);
+ }
+}
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/MergedConfigurationSourceProvider.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/MergedConfigurationSourceProvider.java
new file mode 100644
index 0000000..ee4c33f
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/MergedConfigurationSourceProvider.java
@@ -0,0 +1,79 @@
+package com.groupdocs.ui.common;
+
+import io.dropwizard.configuration.ConfigurationSourceProvider;
+import org.yaml.snakeyaml.Yaml;
+
+import javax.validation.constraints.NotNull;
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.util.Map;
+
+/**
+ * Provider for reading two config files default and external file
+ */
+public class MergedConfigurationSourceProvider implements ConfigurationSourceProvider {
+ private String defaultConfigFile;
+
+ public MergedConfigurationSourceProvider(@NotNull String defaultConfigFile) {
+ this.defaultConfigFile = defaultConfigFile;
+ }
+
+ @Override
+ public InputStream open(String path) throws IOException {
+ try (InputStream defaultConfigStream = getResourceAsStream(defaultConfigFile);
+ InputStream extConfigStream = getResourceFile(path)) {
+
+ Yaml yaml = new Yaml();
+ Map defaultConfig = yaml.loadAs(defaultConfigStream, Map.class);
+ Map extConfig = yaml.loadAs(extConfigStream, Map.class);
+
+ merge(defaultConfig, extConfig);
+
+ return new ByteArrayInputStream(new Yaml().dump(defaultConfig).getBytes(StandardCharsets.UTF_8));
+ }
+ }
+
+ /**
+ * Deep merge two map, if there is a property in extConfig, then replace its value in defaultConfig.
+ *
+ * @param defaultConfig contains all properties with default values
+ * @param extConfig contains properties from external config, to replace its values in default config
+ */
+ private void merge(Map defaultConfig, Map extConfig) {
+ for (String key : defaultConfig.keySet()) {
+ if (extConfig.containsKey(key)) {
+ if (defaultConfig.get(key) instanceof Map) {
+ merge((Map) defaultConfig.get(key), (Map) extConfig.get(key));
+ } else {
+ defaultConfig.replace(key, extConfig.get(key));
+ }
+ }
+ }
+ }
+
+ /**
+ * Read file from resources
+ *
+ * @param path path to config file
+ * @return
+ */
+ private InputStream getResourceAsStream(String path) {
+ return this.getClass().getClassLoader().getResourceAsStream(path);
+ }
+
+ /**
+ * Read external file
+ *
+ * @param path path to config file
+ * @return
+ * @throws IOException
+ */
+ private InputStream getResourceFile(String path) throws IOException {
+ File file = new File(path);
+ if (!file.exists()) {
+ throw new FileNotFoundException("File " + file + " not found");
+ } else {
+ return new FileInputStream(file);
+ }
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/ApplicationConfiguration.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/ApplicationConfiguration.java
new file mode 100644
index 0000000..152fbd2
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/ApplicationConfiguration.java
@@ -0,0 +1,41 @@
+package com.groupdocs.ui.common.config;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.dropwizard.Configuration;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.validation.Valid;
+
+import static com.groupdocs.ui.common.config.DefaultDirectories.defaultLicenseDirectory;
+import static com.groupdocs.ui.common.config.DefaultDirectories.relativePathToAbsolute;
+
+/**
+ * ApplicationConfiguration
+ *
+ * @author Aspose Pty Ltd
+ */
+public class ApplicationConfiguration extends Configuration {
+
+ @Valid
+ @JsonProperty
+ private String licensePath;
+ @Valid
+ @JsonProperty
+ private String hostAddress;
+
+ public String getLicensePath() {
+ return licensePath;
+ }
+
+ public void setLicensePath(String licensePath) {
+ this.licensePath = StringUtils.isEmpty(licensePath) ? defaultLicenseDirectory() : relativePathToAbsolute(licensePath);
+ }
+
+ public String getHostAddress() {
+ return hostAddress;
+ }
+
+ public void setHostAddress(String hostAddress) {
+ this.hostAddress = hostAddress;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/CommonConfiguration.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/CommonConfiguration.java
new file mode 100644
index 0000000..74917de
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/CommonConfiguration.java
@@ -0,0 +1,98 @@
+package com.groupdocs.ui.common.config;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.dropwizard.Configuration;
+
+import javax.validation.Valid;
+
+/**
+ * CommonConfiguration
+ *
+ * @author Aspose Pty Ltd
+ */
+public class CommonConfiguration extends Configuration {
+
+ @Valid
+ @JsonProperty
+ private boolean pageSelector;
+
+ @Valid
+ @JsonProperty
+ private boolean download;
+
+ @Valid
+ @JsonProperty
+ private boolean upload;
+
+ @Valid
+ @JsonProperty
+ private boolean print;
+
+ @Valid
+ @JsonProperty
+ private boolean browse;
+
+ @Valid
+ @JsonProperty
+ private boolean rewrite;
+
+ @Valid
+ @JsonProperty
+ private boolean enableRightClick;
+
+ public boolean isPageSelector() {
+ return pageSelector;
+ }
+
+ public void setPageSelector(boolean pageSelector) {
+ this.pageSelector = pageSelector;
+ }
+
+ public boolean isDownload() {
+ return download;
+ }
+
+ public void setDownload(boolean download) {
+ this.download = download;
+ }
+
+ public boolean isUpload() {
+ return upload;
+ }
+
+ public void setUpload(boolean upload) {
+ this.upload = upload;
+ }
+
+ public boolean isPrint() {
+ return print;
+ }
+
+ public void setPrint(boolean print) {
+ this.print = print;
+ }
+
+ public boolean isBrowse() {
+ return browse;
+ }
+
+ public void setBrowse(boolean browse) {
+ this.browse = browse;
+ }
+
+ public boolean isRewrite() {
+ return rewrite;
+ }
+
+ public void setRewrite(boolean rewrite) {
+ this.rewrite = rewrite;
+ }
+
+ public boolean isEnableRightClick() {
+ return enableRightClick;
+ }
+
+ public void setEnableRightClick(boolean enableRightClick) {
+ this.enableRightClick = enableRightClick;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/CommonConfigurationModel.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/CommonConfigurationModel.java
new file mode 100644
index 0000000..446f70e
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/CommonConfigurationModel.java
@@ -0,0 +1,101 @@
+package com.groupdocs.ui.common.config;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import javax.validation.Valid;
+
+public class CommonConfigurationModel {
+ @Valid
+ @JsonProperty
+ private boolean pageSelector;
+
+ @Valid
+ @JsonProperty
+ private boolean download;
+
+ @Valid
+ @JsonProperty
+ private boolean upload;
+
+ @Valid
+ @JsonProperty
+ private boolean print;
+
+ @Valid
+ @JsonProperty
+ private boolean browse;
+
+ @Valid
+ @JsonProperty
+ private boolean rewrite;
+
+ @Valid
+ @JsonProperty
+ private boolean enableRightClick;
+
+ public boolean isPageSelector() {
+ return pageSelector;
+ }
+
+ public void setPageSelector(boolean pageSelector) {
+ this.pageSelector = pageSelector;
+ }
+
+ public boolean isDownload() {
+ return download;
+ }
+
+ public void setDownload(boolean download) {
+ this.download = download;
+ }
+
+ public boolean isUpload() {
+ return upload;
+ }
+
+ public void setUpload(boolean upload) {
+ this.upload = upload;
+ }
+
+ public boolean isPrint() {
+ return print;
+ }
+
+ public void setPrint(boolean print) {
+ this.print = print;
+ }
+
+ public boolean isBrowse() {
+ return browse;
+ }
+
+ public void setBrowse(boolean browse) {
+ this.browse = browse;
+ }
+
+ public boolean isRewrite() {
+ return rewrite;
+ }
+
+ public void setRewrite(boolean rewrite) {
+ this.rewrite = rewrite;
+ }
+
+ public boolean isEnableRightClick() {
+ return enableRightClick;
+ }
+
+ public void setEnableRightClick(boolean enableRightClick) {
+ this.enableRightClick = enableRightClick;
+ }
+
+ public void init(CommonConfiguration common) {
+ this.setPageSelector(common.isPageSelector());
+ this.setDownload(common.isDownload());
+ this.setUpload(common.isUpload());
+ this.setPrint(common.isPrint());
+ this.setBrowse(common.isBrowse());
+ this.setRewrite(common.isRewrite());
+ this.setEnableRightClick(common.isEnableRightClick());
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/DefaultDirectories.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/DefaultDirectories.java
new file mode 100644
index 0000000..4576ea4
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/DefaultDirectories.java
@@ -0,0 +1,76 @@
+package com.groupdocs.ui.common.config;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.nio.file.FileSystems;
+import java.nio.file.Path;
+
+public class DefaultDirectories {
+ private static final Logger logger = LoggerFactory.getLogger(DefaultDirectories.class);
+
+ public static final String LIC = ".lic";
+ public static final String LICENSES = "Licenses";
+ public static final String DOCUMENT_SAMPLES = "DocumentSamples";
+
+ public static String defaultLicenseDirectory() {
+ Path defaultLicFolder = FileSystems.getDefault().getPath(LICENSES).toAbsolutePath();
+ File licFolder = defaultLicFolder.toFile();
+ if (licFolder.exists()) {
+ Path defaultLicFile = getDefaultLicFile(licFolder);
+ if (defaultLicFile != null) {
+ return defaultLicFile.toString();
+ }
+ }
+ licFolder.mkdirs();
+ logger.info("License file path is incorrect, application launched in trial mode");
+ return "";
+ }
+
+ public static String defaultAnnotationDirectory() {
+ return getDefaultDir("");
+ }
+
+ public static String getDefaultDir(String folder) {
+ String dir = DOCUMENT_SAMPLES + File.separator + folder;
+ Path path = FileSystems.getDefault().getPath(dir).toAbsolutePath();
+ makeDirs(path.toFile());
+ return path.toString();
+ }
+
+ private static void makeDirs(File file) {
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ }
+
+ public static String relativePathToAbsolute(String path) {
+ Iterable rootDirectories = FileSystems.getDefault().getRootDirectories();
+
+ if (StringUtils.isEmpty(path)) {
+ return FileSystems.getDefault().getPath("").toAbsolutePath().toString();
+ }
+
+ for (Path root : rootDirectories) {
+ if (path.startsWith(root.toString())) {
+ makeDirs(new File(path));
+ return path;
+ }
+ }
+
+ Path absolutePath = FileSystems.getDefault().getPath(path).toAbsolutePath();
+ makeDirs(absolutePath.toFile());
+ return absolutePath.toString();
+ }
+
+ public static Path getDefaultLicFile(File licFolder) {
+ for (File file : licFolder.listFiles()) {
+ if (file.getName().endsWith(LIC)) {
+ return FileSystems.getDefault().getPath(LICENSES + File.separator + file.getName()).toAbsolutePath();
+ }
+ }
+ return null;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/GlobalConfiguration.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/GlobalConfiguration.java
new file mode 100644
index 0000000..799e298
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/GlobalConfiguration.java
@@ -0,0 +1,76 @@
+package com.groupdocs.ui.common.config;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.groupdocs.ui.annotation.config.AnnotationConfiguration;
+import io.dropwizard.Configuration;
+
+import javax.validation.Valid;
+
+/**
+ * GlobalConfiguration
+ * Object to hold all application's configurations from yml file
+ *
+ * @author Aspose Pty Ltd
+ */
+public class GlobalConfiguration extends Configuration {
+
+ @Valid
+ @JsonProperty
+ private ServerConfiguration server;
+
+ @Valid
+ @JsonProperty
+ private ApplicationConfiguration application;
+
+ @Valid
+ @JsonProperty
+ private CommonConfiguration common;
+
+ @Valid
+ @JsonProperty
+ private AnnotationConfiguration annotation;
+
+ /**
+ * Constructor
+ */
+ public GlobalConfiguration(){
+ server = new ServerConfiguration();
+ application = new ApplicationConfiguration();
+ common = new CommonConfiguration();
+ annotation = new AnnotationConfiguration();
+ }
+
+ /**
+ * Get server configuration
+ * @return server configuration
+ */
+ public ServerConfiguration getServer() {
+ return server;
+ }
+
+ /**
+ * Get application configuration
+ * @return application configuration
+ */
+ public ApplicationConfiguration getApplication() {
+ return application;
+ }
+
+ /**
+ * Get common configuration
+ * @return common configuration
+ */
+ public CommonConfiguration getCommon() {
+ return common;
+ }
+
+ /**
+ * Get annotation configuration
+ * @return annotation configuration
+ */
+ public AnnotationConfiguration getAnnotation() {
+ return annotation;
+ }
+}
+
+
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/ServerConfiguration.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/ServerConfiguration.java
new file mode 100644
index 0000000..36c0d62
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/config/ServerConfiguration.java
@@ -0,0 +1,21 @@
+package com.groupdocs.ui.common.config;
+
+import io.dropwizard.Configuration;
+
+/**
+ * ServerConfiguration
+ *
+ * @author Aspose Pty Ltd
+ */
+public class ServerConfiguration extends Configuration {
+ private int httpPort;
+
+ public int getHttpPort() {
+ return httpPort;
+ }
+
+ public void setHttpPort(int httpPort) {
+ this.httpPort = httpPort;
+ }
+
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/ExceptionEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/ExceptionEntity.java
new file mode 100644
index 0000000..fe4c11f
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/ExceptionEntity.java
@@ -0,0 +1,52 @@
+package com.groupdocs.ui.common.entity.web;
+
+/**
+ * ExceptionEntity
+ *
+ * @author Aspose Pty Ltd
+ */
+public class ExceptionEntity {
+ private String message;
+ private Exception exception;
+
+ public ExceptionEntity() {
+ }
+
+ public ExceptionEntity(String message, Exception exception) {
+ this.message = message;
+ this.exception = exception;
+ }
+
+ /**
+ * Get exception message
+ * @return message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Set exception message
+ * @param message message
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ /**
+ * Get exception
+ * @return exception
+ */
+ public Exception getException() {
+ return exception;
+ }
+
+ /**
+ * Set exception
+ * @param exception exception
+ */
+ public void setException(Exception exception) {
+ this.exception = exception;
+ }
+
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/FileDescriptionEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/FileDescriptionEntity.java
new file mode 100644
index 0000000..917dd48
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/FileDescriptionEntity.java
@@ -0,0 +1,95 @@
+package com.groupdocs.ui.common.entity.web;
+
+/**
+ * FileDescriptionEntity
+ *
+ * @author Aspose Pty Ltd
+ */
+public class FileDescriptionEntity {
+ private String guid;
+ private String name;
+ private String docType;
+ private Boolean isDirectory;
+ private Long size;
+
+ /**
+ * Get guid (file id)
+ * @return guid
+ */
+ public String getGuid() {
+ return guid;
+ }
+
+ /**
+ * Set guid (File id)
+ * @param guid guid
+ */
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ /**
+ * Get file name
+ * @return file name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set file name
+ * @param name file name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get document type
+ * @return document type
+ */
+ public String getDocType() {
+ return docType;
+ }
+
+ /**
+ * Set document type
+ * @param docType document type
+ */
+ public void setDocType(String docType) {
+ this.docType = docType;
+ }
+
+ /**
+ * Check if path is directory
+ * @return true/false flag
+ */
+ public Boolean isDirectory() {
+ return isDirectory;
+ }
+
+ /**
+ * Set is directory flag
+ * @param directory true/false flag
+ */
+ public void setDirectory(Boolean directory) {
+ isDirectory = directory;
+ }
+
+ /**
+ * Get file size
+ * @return file size
+ */
+ public Long getSize() {
+ return size;
+ }
+
+ /**
+ * Set file size
+ * @param size file size
+ */
+ public void setSize(Long size) {
+ this.size = size;
+ }
+
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/LoadDocumentEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/LoadDocumentEntity.java
new file mode 100644
index 0000000..2054d93
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/LoadDocumentEntity.java
@@ -0,0 +1,30 @@
+package com.groupdocs.ui.common.entity.web;
+
+import java.util.List;
+
+public class LoadDocumentEntity {
+ /**
+ * Document Guid
+ */
+ private String guid;
+ /**
+ * list of pages
+ */
+ private List pages;
+
+ public String getGuid() {
+ return guid;
+ }
+
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ public List getPages() {
+ return pages;
+ }
+
+ public void setPages(List pages) {
+ this.pages = pages;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/PageDescriptionEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/PageDescriptionEntity.java
new file mode 100644
index 0000000..0cb2f6d
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/PageDescriptionEntity.java
@@ -0,0 +1,57 @@
+package com.groupdocs.ui.common.entity.web;
+
+/**
+ * PageDescriptionEntity
+ *
+ * @author Aspose Pty Ltd
+ */
+public class PageDescriptionEntity {
+ /**
+ * Page data
+ */
+ private String data;
+ private int angle;
+ private double width;
+ private double height;
+ private int number;
+
+ public int getAngle() {
+ return angle;
+ }
+
+ public void setAngle(int angle) {
+ this.angle = angle;
+ }
+
+ public double getWidth() {
+ return width;
+ }
+
+ public void setWidth(double width) {
+ this.width = width;
+ }
+
+ public double getHeight() {
+ return height;
+ }
+
+ public void setHeight(double height) {
+ this.height = height;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/UploadedDocumentEntity.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/UploadedDocumentEntity.java
new file mode 100644
index 0000000..923cd4c
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/UploadedDocumentEntity.java
@@ -0,0 +1,26 @@
+package com.groupdocs.ui.common.entity.web;
+
+/**
+ * UploadedDocumentEntity
+ *
+ * @author Aspose Pty Ltd
+ */
+public class UploadedDocumentEntity {
+ private String guid;
+
+ /**
+ * Get guid (file id)
+ * @return guid
+ */
+ public String getGuid() {
+ return guid;
+ }
+
+ /**
+ * Set guid (file id)
+ * @param guid guid
+ */
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/request/FileTreeRequest.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/request/FileTreeRequest.java
new file mode 100644
index 0000000..1a6008a
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/request/FileTreeRequest.java
@@ -0,0 +1,13 @@
+package com.groupdocs.ui.common.entity.web.request;
+
+public class FileTreeRequest {
+ private String path;
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/request/LoadDocumentPageRequest.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/request/LoadDocumentPageRequest.java
new file mode 100644
index 0000000..d596c66
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/request/LoadDocumentPageRequest.java
@@ -0,0 +1,13 @@
+package com.groupdocs.ui.common.entity.web.request;
+
+public class LoadDocumentPageRequest extends LoadDocumentRequest {
+ private Integer page;
+
+ public Integer getPage() {
+ return page;
+ }
+
+ public void setPage(Integer page) {
+ this.page = page;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/request/LoadDocumentRequest.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/request/LoadDocumentRequest.java
new file mode 100644
index 0000000..01bbd54
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/entity/web/request/LoadDocumentRequest.java
@@ -0,0 +1,23 @@
+package com.groupdocs.ui.common.entity.web.request;
+
+public class LoadDocumentRequest {
+
+ private String guid;
+ private String password;
+
+ public String getGuid() {
+ return guid;
+ }
+
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/exception/PasswordExceptions.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/exception/PasswordExceptions.java
new file mode 100644
index 0000000..d9996d5
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/exception/PasswordExceptions.java
@@ -0,0 +1,6 @@
+package com.groupdocs.ui.common.exception;
+
+public class PasswordExceptions {
+ public static final String PASSWORD_REQUIRED = "Password Required";
+ public static final String INCORRECT_PASSWORD = "Incorrect password";
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/exception/TotalGroupDocsException.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/exception/TotalGroupDocsException.java
new file mode 100644
index 0000000..9db6a46
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/exception/TotalGroupDocsException.java
@@ -0,0 +1,15 @@
+package com.groupdocs.ui.common.exception;
+
+/**
+ * Wrapper for application's exceptions
+ */
+public class TotalGroupDocsException extends RuntimeException {
+
+ public TotalGroupDocsException(String message) {
+ super(message);
+ }
+
+ public TotalGroupDocsException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/exception/TotalGroupDocsExceptionMapper.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/exception/TotalGroupDocsExceptionMapper.java
new file mode 100644
index 0000000..f477fe0
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/exception/TotalGroupDocsExceptionMapper.java
@@ -0,0 +1,40 @@
+package com.groupdocs.ui.common.exception;
+
+import com.groupdocs.ui.common.entity.web.ExceptionEntity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.ext.ExceptionMapper;
+import javax.ws.rs.ext.Provider;
+
+import static com.groupdocs.ui.common.exception.PasswordExceptions.INCORRECT_PASSWORD;
+import static com.groupdocs.ui.common.exception.PasswordExceptions.PASSWORD_REQUIRED;
+
+/**
+ * Map application's exceptions into responses
+ */
+@Provider
+public class TotalGroupDocsExceptionMapper implements ExceptionMapper {
+ private static final Logger logger = LoggerFactory.getLogger(TotalGroupDocsExceptionMapper.class);
+ @Override
+ public Response toResponse(TotalGroupDocsException exception) {
+ ExceptionEntity exceptionEntity = new ExceptionEntity();
+ String message = exception.getMessage();
+ exceptionEntity.setMessage(message);
+ if (PASSWORD_REQUIRED.equals(message) || INCORRECT_PASSWORD.equals(message)) {
+ return Response.ok(exceptionEntity).build();
+ }
+ if (logger.isDebugEnabled()) {
+ exception.printStackTrace();
+ exceptionEntity.setException(exception);
+ }
+ logger.error(exception.getCause() != null? exception.getCause().getLocalizedMessage() : message);
+ return Response
+ .serverError()
+ .entity(exceptionEntity)
+ .type(MediaType.APPLICATION_JSON_TYPE)
+ .build();
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/health/TemplateHealthCheck.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/health/TemplateHealthCheck.java
new file mode 100644
index 0000000..d91a179
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/health/TemplateHealthCheck.java
@@ -0,0 +1,21 @@
+package com.groupdocs.ui.common.health;
+
+import com.codahale.metrics.health.HealthCheck;
+
+/**
+* Dummy HealthCheck
+* @author Aspose Pty Ltd
+*/
+public class TemplateHealthCheck extends HealthCheck {
+ private final String template;
+
+ public TemplateHealthCheck(String template) {
+ this.template = template;
+ }
+
+ @Override
+ protected Result check() throws Exception {
+ return Result.healthy();
+ }
+
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/resources/Resources.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/resources/Resources.java
new file mode 100644
index 0000000..7ba4575
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/resources/Resources.java
@@ -0,0 +1,232 @@
+package com.groupdocs.ui.common.resources;
+
+import com.google.common.collect.Lists;
+import com.groupdocs.ui.common.config.GlobalConfiguration;
+import com.groupdocs.ui.common.exception.TotalGroupDocsException;
+import io.dropwizard.jetty.ConnectorFactory;
+import io.dropwizard.jetty.HttpConnectorFactory;
+import io.dropwizard.server.SimpleServerFactory;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.ws.rs.core.MediaType;
+import java.io.*;
+import java.net.InetAddress;
+import java.net.URL;
+import java.net.UnknownHostException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * Resources
+ *
+ * @author Aspose Pty Ltd
+ */
+public abstract class Resources {
+ protected final String DEFAULT_CHARSET = "UTF-8";
+ protected final GlobalConfiguration globalConfiguration;
+
+ private static final ZoneId GMT = ZoneId.of("GMT");
+
+ /**
+ * Get path to storage. Different for different products
+ *
+ * @param params parameters for calculating the path
+ * @return path to files storage
+ */
+ protected abstract String getStoragePath(Map params);
+
+ /**
+ * Internal upload file into server
+ *
+ * @param documentUrl url for document
+ * @param inputStream file stream
+ * @param fileDetail file description
+ * @param rewrite flag for rewriting file
+ * @param params parameters for creating path to files storage
+ * @return path to file in storage
+ */
+ protected String uploadFile(String documentUrl, InputStream inputStream, FormDataContentDisposition fileDetail, boolean rewrite, Map params) {
+ InputStream uploadedInputStream = null;
+ String pathname;
+ try {
+ String fileName;
+ if (StringUtils.isEmpty(documentUrl)) {
+ // get the InputStream to store the file
+ uploadedInputStream = inputStream;
+ fileName = fileDetail.getFileName();
+ } else {
+ // get the InputStream from the URL
+ URL url = new URL(documentUrl);
+ uploadedInputStream = url.openStream();
+ fileName = FilenameUtils.getName(url.getPath());
+ }
+ // get documents storage path
+ String documentStoragePath = getStoragePath(params);
+ // save the file
+ pathname = String.format("%s%s%s", documentStoragePath, File.separator, fileName);
+ File file = new File(pathname);
+ // check rewrite mode
+ if (rewrite) {
+ // save file with rewrite if exists
+ Files.copy(uploadedInputStream, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ } else {
+ if (file.exists()){
+ // get file with new name
+ file = getFreeFileName(documentStoragePath, fileName);
+ }
+ // save file with out rewriting
+ Path path = file.toPath();
+ Files.copy(uploadedInputStream, path);
+ pathname = path.toString();
+ }
+ } catch(Exception ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ } finally {
+ try {
+ uploadedInputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return pathname;
+ }
+
+ /**
+ * Date formats with time zone as specified in the HTTP RFC.
+ * @see Section 7.1.1.1 of RFC 7231
+ */
+ private static final DateTimeFormatter[] DATE_FORMATTERS = new DateTimeFormatter[] {
+ DateTimeFormatter.RFC_1123_DATE_TIME,
+ DateTimeFormatter.ofPattern("EEEE, dd-MMM-yy HH:mm:ss zz", Locale.US),
+ DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss yyyy",Locale.US).withZone(GMT)
+ };
+
+ /**
+ * Fill Header Content-disposition parameter for download file
+ *
+ * @param response http response to fill header
+ * @param fileName name of file
+ */
+ protected void fillResponseHeaderDisposition(HttpServletResponse response, String fileName) {
+ response.setHeader("Content-disposition", "attachment; filename=" + fileName);
+ }
+
+ /**
+ * Download file
+ *
+ * @param response http response
+ * @param pathToFile path to file
+ */
+ protected void downloadFile(HttpServletResponse response, String pathToFile) {
+ String fileName = FilenameUtils.getName(pathToFile);
+ // don't delete, should be before writing
+ fillResponseHeaderDisposition(response, fileName);
+ long length;
+ try (InputStream inputStream = new FileInputStream(pathToFile);
+ OutputStream outputStream = response.getOutputStream()){
+ // download the document
+ length = IOUtils.copyLarge(inputStream, outputStream);
+ } catch (Exception ex){
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ // set response content disposition
+ addFileDownloadHeaders(response, fileName, length);
+ }
+
+ /**
+ * Constructor
+ * @param globalConfiguration global application configuration
+ * @throws UnknownHostException
+ */
+ public Resources(GlobalConfiguration globalConfiguration) throws UnknownHostException {
+ this.globalConfiguration = globalConfiguration;
+
+ // set HTTP port
+ SimpleServerFactory serverFactory = (SimpleServerFactory) globalConfiguration.getServerFactory();
+ ConnectorFactory connector = serverFactory.getConnector();
+ globalConfiguration.getServer().setHttpPort(((HttpConnectorFactory) connector).getPort());
+
+ // set host address
+ String hostAddress = globalConfiguration.getApplication().getHostAddress();
+ if (StringUtils.isEmpty(hostAddress) || hostAddress.startsWith("${")) {
+ globalConfiguration.getApplication().setHostAddress(InetAddress.getLocalHost().getHostAddress());
+ }
+ }
+
+ /**
+ * Rename file if exist
+ * @param directory directory where files are located
+ * @param fileName file name
+ * @return new file with new file name
+ */
+ protected File getFreeFileName(String directory, String fileName){
+ File file = null;
+ try {
+ File folder = new File(directory);
+ File[] listOfFiles = folder.listFiles();
+ for (int i = 0; i < listOfFiles.length; i++) {
+ int number = i + 1;
+ String newFileName = FilenameUtils.removeExtension(fileName) + "-Copy(" + number + ")." + FilenameUtils.getExtension(fileName);
+ file = new File(directory + File.separator + newFileName);
+ if(file.exists()) {
+ continue;
+ } else {
+ break;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return file;
+ }
+
+ /**
+ * Fill header HTTP response with file data
+ */
+ public void addFileDownloadHeaders(HttpServletResponse response, String fileName, Long fileLength) {
+ Map> fileDownloadHeaders = createFileDownloadHeaders(fileName, fileLength, MediaType.APPLICATION_OCTET_STREAM);
+ for (Map.Entry> entry : fileDownloadHeaders.entrySet()) {
+ for (String value : entry.getValue()) {
+ response.addHeader(entry.getKey(), value);
+ }
+ }
+ }
+
+ /**
+ * Get headers for downloading files
+ */
+ private static Map> createFileDownloadHeaders(String fileName, Long fileLength, String mediaType) {
+ Map> httpHeaders = new HashMap<>();
+ httpHeaders.put("Content-disposition", Lists.newArrayList("attachment; filename=" + fileName));
+ httpHeaders.put("Content-Type", Lists.newArrayList(mediaType));
+ httpHeaders.put("Content-Description", Lists.newArrayList("File Transfer"));
+ httpHeaders.put("Content-Transfer-Encoding", Lists.newArrayList("binary"));
+ httpHeaders.put("Expires", Lists.newArrayList(formatDate(0)));
+ httpHeaders.put("Cache-Control", Lists.newArrayList("must-revalidate"));
+ httpHeaders.put("Pragma", Lists.newArrayList("public"));
+ if (fileLength != null) {
+ httpHeaders.put("Content-Length", Lists.newArrayList(Long.toString(fileLength)));
+ }
+ return httpHeaders;
+ }
+
+ private static String formatDate(long date) {
+ Instant instant = Instant.ofEpochMilli(date);
+ ZonedDateTime time = ZonedDateTime.ofInstant(instant, GMT);
+ return DATE_FORMATTERS[0].format(time);
+ }
+
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/util/Utils.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/util/Utils.java
new file mode 100644
index 0000000..8ac9956
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/util/Utils.java
@@ -0,0 +1,152 @@
+package com.groupdocs.ui.common.util;
+
+import com.google.common.collect.Ordering;
+import com.groupdocs.ui.common.exception.TotalGroupDocsException;
+import com.groupdocs.ui.common.util.comparator.FileNameComparator;
+import com.groupdocs.ui.common.util.comparator.FileTypeComparator;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Base64;
+import java.util.List;
+
+import static com.groupdocs.ui.common.exception.PasswordExceptions.INCORRECT_PASSWORD;
+import static com.groupdocs.ui.common.exception.PasswordExceptions.PASSWORD_REQUIRED;
+
+public class Utils {
+ private static final Logger logger = LoggerFactory.getLogger(Utils.class);
+
+ public static java.util.List orderByTypeAndName(List files) {
+ return Ordering.from(FileTypeComparator.instance).compound(FileNameComparator.instance).sortedCopy(files);
+ }
+
+ /**
+ * Read stream and convert to string
+ *
+ * @param inputStream
+ * @return
+ * @throws IOException
+ */
+ public static String getStringFromStream(InputStream inputStream) throws IOException {
+ byte[] bytes = IOUtils.toByteArray(inputStream);
+ // encode ByteArray into String
+ return Base64.getEncoder().encodeToString(bytes);
+ }
+
+ /**
+ * Parse extension of the file's name
+ *
+ * @param documentGuid path to file
+ * @return extension of the file's name
+ */
+ public static String parseFileExtension(String documentGuid) {
+ String extension = FilenameUtils.getExtension(documentGuid);
+ return extension == null ? null : extension.toLowerCase();
+ }
+
+ /**
+ * Get correct message for security exceptions
+ *
+ * @param password
+ * @return
+ */
+ public static String getExceptionMessage(String password) {
+ return StringUtils.isEmpty(password) ? PASSWORD_REQUIRED : INCORRECT_PASSWORD;
+ }
+
+ /**
+ * Rename file if exist
+ *
+ * @param directory directory where files are located
+ * @param fileName file name
+ * @return new file with new file name
+ */
+ public static File getFreeFileName(String directory, String fileName) {
+ File file = null;
+ try {
+ File folder = new File(directory);
+ File[] listOfFiles = folder.listFiles();
+ for (int i = 0; i < listOfFiles.length; i++) {
+ int number = i + 1;
+ String newFileName = FilenameUtils.removeExtension(fileName) + "-Copy(" + number + ")." + FilenameUtils.getExtension(fileName);
+ file = new File(directory + File.separator + newFileName);
+ if (!file.exists()) {
+ break;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return file;
+ }
+
+ /**
+ * Create file in previewPath and name imageGuid
+ * if the file is already exist, create new file with next number in name
+ * examples, 001, 002, 003, etc
+ *
+ * @param previewPath path to file folder
+ * @param imageGuid path to file
+ * @return created file
+ */
+ public static File getFileWithUniqueName(String previewPath, String imageGuid, String ext) {
+ if (!StringUtils.isEmpty(imageGuid) && new File(imageGuid).exists()) {
+ return new File(imageGuid);
+ } else {
+ File[] listOfFiles = new File(previewPath).listFiles();
+ if (listOfFiles == null) {
+ throw new RuntimeException("Can't list files of '" + previewPath + "' folder");
+ }
+ return createUniqueFile(previewPath, listOfFiles, ext);
+ }
+ }
+
+ private static File createUniqueFile(String previewPath, File[] listOfFiles, String ext) {
+ for (int i = 0; i <= listOfFiles.length; i++) {
+ // set file name, for example 001
+ String fileName = String.format("%03d", i + 1);
+ File file = new File(String.format("%s%s%s.%s", previewPath, File.separator, fileName, ext));
+ // check if file with such name already exists
+ if (!file.exists()) {
+ return file;
+ }
+ }
+ return new File(String.format("%s%s001.png", previewPath, File.separator));
+ }
+
+ /**
+ * Generate empty image for future signing with signature, such approach required to get signature as image
+ *
+ * @param width image width
+ * @param height image height
+ * @return
+ */
+ public static BufferedImage getBufferedImage(int width, int height) {
+ BufferedImage bufImage = null;
+ try {
+ bufImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ // Create a graphics contents on the buffered image
+ Graphics2D g2d = bufImage.createGraphics();
+ // Draw graphics
+ g2d.setColor(Color.WHITE);
+ g2d.fillRect(0, 0, width, height);
+ // Graphics context no longer needed so dispose it
+ g2d.dispose();
+ return bufImage;
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ } finally {
+ if (bufImage != null) {
+ bufImage.flush();
+ }
+ }
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/util/comparator/FileDateComparator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/util/comparator/FileDateComparator.java
new file mode 100644
index 0000000..f5c4f8f
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/util/comparator/FileDateComparator.java
@@ -0,0 +1,36 @@
+package com.groupdocs.ui.common.util.comparator;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.Comparator;
+
+public class FileDateComparator implements Comparator {
+ private static final Logger logger = LoggerFactory.getLogger(FileDateComparator.class);
+
+ public static FileDateComparator instance = new FileDateComparator();
+
+ /**
+ * Compare two file names
+ *
+ * @param file1
+ * @param file2
+ * @return int
+ */
+ @Override
+ public int compare(File file1, File file2) {
+
+ try {
+ BasicFileAttributes attr1 = Files.readAttributes(file1.toPath(), BasicFileAttributes.class);
+ BasicFileAttributes attr2 = Files.readAttributes(file2.toPath(), BasicFileAttributes.class);
+ return attr1.creationTime().compareTo(attr2.creationTime());
+ } catch (IOException e) {
+ logger.error("Error comparing files by creation date");
+ }
+ return 0;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/util/comparator/FileNameComparator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/util/comparator/FileNameComparator.java
new file mode 100644
index 0000000..e5e1b1b
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/util/comparator/FileNameComparator.java
@@ -0,0 +1,27 @@
+package com.groupdocs.ui.common.util.comparator;
+
+import java.io.File;
+import java.util.Comparator;
+
+/**
+ * FileNameComparator
+ * Compare and sort file names alphabetically
+ * @author Aspose Pty Ltd
+ */
+public class FileNameComparator implements Comparator {
+
+ public static FileNameComparator instance = new FileNameComparator();
+
+ /**
+ * Compare two file names
+ * @param file1
+ * @param file2
+ * @return int
+ */
+ @Override
+ public int compare(File file1, File file2) {
+
+ return String.CASE_INSENSITIVE_ORDER.compare(file1.getName(),
+ file2.getName());
+ }
+}
diff --git a/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/util/comparator/FileTypeComparator.java b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/util/comparator/FileTypeComparator.java
new file mode 100644
index 0000000..3ed0c74
--- /dev/null
+++ b/Demos/Dropwizard/src/main/java/com/groupdocs/ui/common/util/comparator/FileTypeComparator.java
@@ -0,0 +1,34 @@
+package com.groupdocs.ui.common.util.comparator;
+
+import java.io.File;
+import java.util.Comparator;
+
+/**
+ * FileTypeComparator
+ * Compare and sort file types - folders first
+ * @author Aspose Pty Ltd
+ */
+public class FileTypeComparator implements Comparator {
+
+ public static FileTypeComparator instance = new FileTypeComparator();
+
+ /**
+ * Compare two file types
+ * @param file1
+ * @param file2
+ * @return
+ */
+ @Override
+ public int compare(File file1, File file2) {
+
+ if (file1.isDirectory() && file2.isFile())
+ return -1;
+ if (file1.isDirectory() && file2.isDirectory()) {
+ return 0;
+ }
+ if (file1.isFile() && file2.isFile()) {
+ return 0;
+ }
+ return 1;
+ }
+}
diff --git a/Demos/Dropwizard/src/main/resources/banner.txt b/Demos/Dropwizard/src/main/resources/banner.txt
new file mode 100644
index 0000000..c73a17c
--- /dev/null
+++ b/Demos/Dropwizard/src/main/resources/banner.txt
@@ -0,0 +1,7 @@
+
+ ______ ____
+ / ____/________ __ ______ / __ \____ __________
+ / / __/ ___/ __ \/ / / / __ \/ / / / __ \/ ___/ ___/
+/ /_/ / / / /_/ / /_/ / /_/ / /_/ / /_/ / /__(__ )
+\____/_/ \____/\__,_/ .___/_____/\____/\___/____/
+ /_/
diff --git a/Demos/Dropwizard/src/main/resources/com/groupdocs/ui/annotation/views/annotation.ftl b/Demos/Dropwizard/src/main/resources/com/groupdocs/ui/annotation/views/annotation.ftl
new file mode 100644
index 0000000..bc0cb33
--- /dev/null
+++ b/Demos/Dropwizard/src/main/resources/com/groupdocs/ui/annotation/views/annotation.ftl
@@ -0,0 +1,24 @@
+<#-- @ftlvariable name="" type="annotation" -->
+
+
+
+
+ Annotation for Java Dropwizard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Demos/Dropwizard/src/main/resources/defaultConfiguration.yml b/Demos/Dropwizard/src/main/resources/defaultConfiguration.yml
new file mode 100644
index 0000000..38e281a
--- /dev/null
+++ b/Demos/Dropwizard/src/main/resources/defaultConfiguration.yml
@@ -0,0 +1,100 @@
+################################################
+# Server configurations
+################################################
+server:
+ type: simple
+ applicationContextPath: /
+ adminContextPath: /admin
+ connector:
+ type: http
+ port: 8080
+
+
+################################################
+# Application (global) configurations
+################################################
+application:
+ # License path
+ # Absolute or relative path to GroupDocs license file
+ licensePath:
+ # Host name or ip for server instance
+ hostAddress: ${application.hostAddress}
+
+################################################
+# Common configurations
+################################################
+common:
+ # File rewriting on document uploading
+ # Set false to keep both files
+ # Set true to replace files with same name
+ rewrite: true
+ # Page navigation
+ # Set false to disable document navigation (go to next, previous, last and first page)
+ pageSelector: true
+ # Document download
+ # Set false to disable document download
+ download: true
+ # Document upload
+ # Set false to disable document upload
+ upload: true
+ # Document print
+ # Set false to disable document print
+ print: true
+ # File browser
+ # Set false to disable document browse
+ browse: true
+ # Set false to disable right mouse click
+ enableRightClick: true
+
+################################################
+# GroupDocs.Annotation configurations
+################################################
+annotation:
+ # Files directory path
+ # Absolute or relative path to files directory
+ filesDirectory:
+ # Default document
+ # Absolute or relative path to default document
+ defaultDocument: ''
+ # Pages preload
+ # How many pages from a document should be loaded, remaining pages will be loaded on page scrolling
+ # Set 0 to load all pages at once
+ preloadPageCount: 0
+ # Fonts path
+ # Absolute path to custom fonts directory
+ fontsDirectory: ''
+ # Enable/disable Text annotation
+ textAnnotation: true
+ # Enable/disable Area annotation
+ areaAnnotation: true
+ # Enable/disable Point annotation
+ pointAnnotation: true
+ # Enable/disable TextStrikeout annotation
+ textStrikeoutAnnotation: true
+ # Enable/disable Polyline annotation
+ polylineAnnotation: true
+ # Enable/disable TextField annotation
+ textFieldAnnotation: true
+ # Enable/disable Watermark annotation
+ watermarkAnnotation: true
+ # Enable/disable TextReplacement annotation
+ textReplacementAnnotation: true
+ # Enable/disable Arrow annotation
+ arrowAnnotation: true
+ # Enable/disable TextRedaction annotation
+ textRedactionAnnotation: true
+ # Enable/disable ResourcesRedaction annotation
+ resourcesRedactionAnnotation: true
+ # Enable/disable TextUnderline annotation
+ textUnderlineAnnotation: true
+ # Enable/disable Distance annotation
+ distanceAnnotation: true
+ # Enable/disable original document downloading
+ downloadOriginal: true
+ # Enable/disable signed document downloading
+ downloadAnnotated: true
+ # Enable/disable zoom
+ zoom: true
+ # Enable/disable fit width
+ # set true to zoom document pages fit width
+ fitWidth: true
diff --git a/Demos/Dropwizard/src/test/java/com/groupdocs/ui/annotation/resources/AnnotationResourcesTest.java b/Demos/Dropwizard/src/test/java/com/groupdocs/ui/annotation/resources/AnnotationResourcesTest.java
new file mode 100644
index 0000000..941aa73
--- /dev/null
+++ b/Demos/Dropwizard/src/test/java/com/groupdocs/ui/annotation/resources/AnnotationResourcesTest.java
@@ -0,0 +1,61 @@
+package com.groupdocs.ui.annotation.resources;
+
+import com.groupdocs.ui.common.MainService;
+import com.groupdocs.ui.common.config.GlobalConfiguration;
+import io.dropwizard.client.JerseyClientBuilder;
+import io.dropwizard.testing.ResourceHelpers;
+import io.dropwizard.testing.junit.DropwizardAppRule;
+import org.glassfish.jersey.client.ClientProperties;
+import org.junit.ClassRule;
+import org.junit.Test;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.core.Response;
+
+import java.io.File;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class AnnotationResourcesTest {
+
+ @ClassRule
+ public static final DropwizardAppRule RULE =
+ new DropwizardAppRule<>(MainService.class, System.getProperty("user.dir") + File.separator +"configuration.yml");
+
+ @Test
+ public void getView() {
+ Client client = new JerseyClientBuilder(RULE.getEnvironment()).build("test client");
+ client.property(ClientProperties.CONNECT_TIMEOUT, 5000);
+ client.property(ClientProperties.READ_TIMEOUT, 5000);
+ Response response = client.target(
+ String.format("http://localhost:%d/annotation", RULE.getLocalPort()))
+ .request()
+ .get();
+
+
+ assertThat(response.getStatus()).isEqualTo(200);
+ client.close();
+ }
+
+
+ public void loadFileTree() {
+ }
+
+ public void loadDocumentDescription() {
+ }
+
+ public void loadDocumentPage() {
+ }
+
+ public void downloadDocument() {
+ }
+
+ public void uploadDocument() {
+ }
+
+ public void textCoordinates() {
+ }
+
+ public void annotate() {
+ }
+}
\ No newline at end of file
diff --git a/Demos/README.md b/Demos/README.md
new file mode 100644
index 0000000..8686a65
--- /dev/null
+++ b/Demos/README.md
@@ -0,0 +1,3 @@
+# GroupDocs.Annotation for Java Demos
+
+GroupDocs.Annotation for Java Demo projects.
diff --git a/Demos/Spring/.gitignore b/Demos/Spring/.gitignore
new file mode 100644
index 0000000..4469f54
--- /dev/null
+++ b/Demos/Spring/.gitignore
@@ -0,0 +1,22 @@
+# Add any directories, files, or patterns you don't want to be tracked by version control
+.idea/*
+*.iml
+*.ipr
+*.iws
+target/*
+.DS_Store
+vs.bin
+App_Data/*
+node_modules
+src/main/resources/static/*
+!src/main/resources/static/.gitkeep
+node/
+etc/
+package-lock.json
+Licenses/*
+!Licenses/.gitkeep
+DocumentSamples/*
+!DocumentSamples/.gitkeep
+
+#License files
+*.lic
diff --git a/Demos/Spring/.travis.yml b/Demos/Spring/.travis.yml
new file mode 100644
index 0000000..5272404
--- /dev/null
+++ b/Demos/Spring/.travis.yml
@@ -0,0 +1,40 @@
+dist: trusty
+language: java
+jdk:
+- oraclejdk8
+- oraclejdk9
+- openjdk8
+#- oraclejdk11
+#- openjdk10
+#- openjdk11
+services:
+ - docker
+jobs:
+ include:
+ - stage: Coverage
+ jdk: oraclejdk8
+ script:
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
+ - chmod +x ./cc-test-reporter
+ - ./cc-test-reporter before-build
+ - mvn clean package
+ - JACOCO_SOURCE_PATH=src/main/java ./cc-test-reporter format-coverage target/site/jacoco/jacoco.xml --input-type jacoco
+ - ./cc-test-reporter upload-coverage
+ - stage: Tag Release
+ if: type = push AND branch = master AND commit_message !~ /^Travis bot released/
+ install: skip
+ script: git checkout master && git reset --hard $sha1 && git config --global push.followTags true && git config --global user.email "travis@travis-ci.org" && git config --global user.name "Travis CI" && export current_version=$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec) && echo "current version ${current_version}" && export minor=$(echo $current_version | sed "s/^[0-9]\{1,\}\.[0-9]\{1,\}\.\([0-9]\{1,\}\)/\1/") && export major=$(echo $current_version | sed "s/^\([0-9]\{1,\}\.[0-9]\{1,\}\)\.[0-9]\{1,\}/\1/") && export next_version=$major.$((minor+1)) && echo "next version ${next_version}" && sed -i.bak "s/$current_version/$next_version/g" README.md && rm README.md.bak && sed -i.bak "s/^ $current_version<\\/version>/ $next_version<\\/version>/g" pom.xml && rm pom.xml.bak && git status && git commit -am "Travis bot released $next_version" && git tag -a $next_version -m "Automated release" && git remote add target https://${GH_TOKEN}@github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java-Spring.git > /dev/null 2>&1 && git remote -v && git push --set-upstream target master
+ - stage: Release
+ if: type = push AND branch = master AND commit_message =~ /^Travis bot released/
+ install: skip
+ jdk: oraclejdk8
+ script: mvn -B clean package && mkdir -p target/release/DocumentSamples && mkdir -p target/release/Licenses && cp target/annotation-spring-*.jar target/release && cp configuration.yml target/release && cd target && tar -zcvf release.tar.gz release && cd .. && echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin && docker build -t groupdocs/annotation . && docker push groupdocs/annotation
+ deploy:
+ provider: releases
+ overwrite: true
+ skip_cleanup: true
+ api_key: $GH_TOKEN
+ file: target/release.tar.gz
+ on:
+ repo: groupdocs-annotation/GroupDocs.Annotation-for-Java-Spring
+ branch: master
\ No newline at end of file
diff --git a/Demos/Spring/Dockerfile b/Demos/Spring/Dockerfile
new file mode 100644
index 0000000..501b4fc
--- /dev/null
+++ b/Demos/Spring/Dockerfile
@@ -0,0 +1,15 @@
+FROM openjdk:18-jdk-bullseye
+RUN mkdir -p /app
+
+RUN apt-get update && \
+ apt-get install -y fontconfig && \
+ fc-cache -f
+
+WORKDIR /app
+COPY /DocumentSamples /app
+COPY /Licenses /app
+COPY target/annotation-spring-*.jar /app/app.jar
+
+EXPOSE 8080
+
+ENTRYPOINT java -jar /app/app.jar configuration.yml
\ No newline at end of file
diff --git a/Demos/Spring/DocumentSamples/.gitkeep b/Demos/Spring/DocumentSamples/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Spring/LICENSE b/Demos/Spring/LICENSE
new file mode 100644
index 0000000..044c00d
--- /dev/null
+++ b/Demos/Spring/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 GroupDocs.Annotation Product Family
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Demos/Spring/Licenses/.gitkeep b/Demos/Spring/Licenses/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Spring/README.md b/Demos/Spring/README.md
new file mode 100644
index 0000000..f7d798d
--- /dev/null
+++ b/Demos/Spring/README.md
@@ -0,0 +1,178 @@
+
+# GroupDocs.Annotation for Java Spring Example
+###### version 1.12.28
+
+[](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java-Spring/blob/master/LICENSE)
+
+## System Requirements
+- Java 8 (JDK 1.8)
+- Maven 3
+
+## Annotate & write on document with Java Spring
+
+**GroupDocs.Annotations for Java** is a powerful library that provides flexible API which allows you to **annotate PDF**, DOCX, PPT, XLS, and over 90 document formats without external dependencies and/or additional document conversions such us (DOCX to PDF or PPT to PDF). With GroupDocs.Annotation API you can write on documents using various annotation tools such as arrow annotation, text annotation or even draw on a document with help of freehand annotation drawing tool.
+
+With GroupDocs.Annotation for Java Spring application, you can annotate and **write on document** using our modern and responsive web UI interface. Thanks to flexible and highly customizable configuration it can be used as standalone application or can be integrated into your project within few simple steps.
+
+**Note:** without a license application will run in trial mode, purchase [GroupDocs.Annotation for Java license](https://purchase.groupdocs.com/buy) or request [GroupDocs.Annotation for Java temporary license](https://purchase.groupdocs.com/temporary-license).
+
+
+## Demo Video
+
+
+
+
+
+
+
+
+## Features
+
+
+
+ Text annotation
+
Add text annotations in any document. Specify font size, set colors, add comments and collaborate.
+
+
+
+
+
+
+ Freehand Drawing
+
Draw on a document using a freehand drawing tool. Easily highlight specific areas on your document page.
+
+
+
+
+
+
+ Blackout & Redaction
+
Blackout and redact sensitive or personally identifiable information on your document.
+
+
+
+
+
+
+ Comments
+
Collaborate and comment on any annotation. Start a discussion right in a document without database dependency/integration.
+
+
+
+
+### More features
+
+- Clean, modern and intuitive design
+- Easily switchable colour theme (create your own colour theme in 5 minutes)
+- Responsive design
+- Mobile support (open application on any mobile device)
+- Support over 50 documents and image formats
+- Image mode
+- Fully customizable navigation panel
+- Annotate password protected documents
+- Download original documents
+- Download annotated documents
+- Upload documents
+- Annotate document with such annotation types:
+ * **Text** – highlights and comments selected text
+ * **Area** – marks an area with a rectangle and adds notes to it
+ * **Point** – sticks comments to any point in a document
+ * **TextStrikeout** – marks text with a strikethrough styling
+ * **Polyline** – draws shapes and freehand lines
+ * **TextField** – adds rectangle with a text inside
+ * **Watermark** - Horizontal textual watermark
+ * **TextReplacement** – replaces original text with user’s text
+ * **Arrow** – draws an arrow on a document
+ * **TextRedaction** – fills black rectangle with fixed position (used if you want to hide some text)
+ * **ResourcesRedaction** – fills black rectangle with fixed position
+ * **TextUnderline** – marks text with a underline styling
+ * **Distance** – measures a distance between objects in a document
+- Draw annotation over the document page
+- Add comment or reply
+- Print document
+- Smooth page navigation
+- Smooth document scrolling
+- Preload pages for faster document rendering
+- Multi-language support for displaying errors
+- Cross-browser support (Safari, Chrome, Opera, Firefox)
+- Cross-platform support (Windows, Linux, MacOS)
+
+
+## How to run
+
+You can run this sample by one of following methods
+
+#### Build from source
+
+Download [source code](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java-Spring/archive/master.zip) from github or clone this repository.
+
+```bash
+git clone https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java/
+cd /Demos/Spring
+mvn clean spring-boot:run
+## Open http://localhost:8080/annotation/ in your favorite browser.
+```
+
+#### Build war from source
+
+Download [source code](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java-Spring/archive/master.zip) from github or clone this repository.
+
+```bash
+git clone https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java/
+cd /Demos/Spring
+mvn package -P war
+## Deploy this war on any server
+```
+
+#### Docker image
+Use [docker](https://hub.docker.com/u/groupdocs) image.
+
+```bash
+mkdir DocumentSamples
+mkdir Licenses
+docker run -p 8080:8080 --env application.hostAddress=localhost -v `pwd`/DocumentSamples:/home/groupdocs/app/DocumentSamples -v `pwd`/Licenses:/home/groupdocs/app/Licenses groupdocs/annotation
+## Open http://localhost:8080/annotation/ in your favorite browser.
+```
+
+#### Configuration
+For all methods above you can adjust settings in `configuration.yml`. By default in this sample will lookup for license file in `./Licenses` folder, so you can simply put your license file in that folder or specify relative/absolute path by setting `licensePath` value in `configuration.yml`.
+
+### Annotation configuration options
+
+| Option | Type | Default value | Description |
+| ---------------------------------- | ------- |:-----------------:|:-------------------------------------------------------------------------------------------------------------------------------------------- |
+| **`filesDirectory`** | String | `DocumentSamples` | Files directory path. Indicates where uploaded and predefined files are stored. It can be absolute or relative path |
+| **`fontsDirectory`** | String | | Path to custom fonts directory. |
+| **`defaultDocument`** | String | | Absolute path to default document that will be loaded automaticaly. |
+| **`preloadPageCount`** | Integer | `0` | Indicate how many pages from a document should be loaded, remaining pages will be loaded on page scrolling.Set `0` to load all pages at once |
+| **`textAnnotation`** | Boolean | `true` | Enable/disable Text annotation |
+| **`areaAnnotation`** | Boolean | `true` | Enable/disable Area annotation |
+| **`areaAnnotation`** | Boolean | `true` | Enable/disable Point annotation |
+| **`pointAnnotation`** | Boolean | `true` | Enable thumbnails preview |
+| **`textStrikeoutAnnotation`** | Boolean | `true` | Enable/disable TextStrikeout annotation |
+| **`polylineAnnotation`** | Boolean | `true` | Enable/disable Polyline annotation |
+| **`textFieldAnnotation`** | Boolean | `true` | Enable/disable TextField annotation |
+| **`watermarkAnnotation`** | Boolean | `true` | Enable/disable Watermark annotation |
+| **`textReplacementAnnotation`** | Boolean | `true` | Enable/disable TextReplacement annotation |
+| **`arrowAnnotation`** | Boolean | `true` | Enable/disable Arrow annotation |
+| **`textRedactionAnnotation`** | Boolean | `true` | Enable/disable TextRedaction annotation |
+| **`resourcesRedactionAnnotation`** | Boolean | `true` | Enable/disable ResourcesRedaction annotation |
+| **`textUnderlineAnnotation`** | Boolean | `true` | Enable/disable TextUnderline annotation |
+| **`distanceAnnotation`** | Boolean | `true` | Enable/disable Distance annotation |
+| **`downloadOriginal`** | Boolean | `true` | Enable/disable original document downloading |
+| **`downloadAnnotated`** | Boolean | `true` | Enable/disable signed document downloading |
+| **`zoom`** | Boolean | `true` | Enable/disable zoom |
+| **`fitWidth`** | Boolean | `true` | Enable/disable fit width. Set true to zoom document pages fit width |
+
+## License
+The MIT License (MIT).
+
+Please have a look at the LICENSE.md for more details
+
+## GroupDocs Annotation on other platforms & frameworks
+
+- JAVA DropWizard [Document & PDF annotator](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java/tree/master/Demos/Dropwizard)
+- .NET MVC [Document & PDF annotator](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-.NET/tree/master/Demos)
+- .NET WebForms [Document & PDF annotator](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-.NET/tree/master/Demos)
+
+[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)
diff --git a/Demos/Spring/client/.editorconfig b/Demos/Spring/client/.editorconfig
new file mode 100644
index 0000000..6e87a00
--- /dev/null
+++ b/Demos/Spring/client/.editorconfig
@@ -0,0 +1,13 @@
+# Editor configuration, see http://editorconfig.org
+root = true
+
+[*]
+charset = utf-8
+indent_style = space
+indent_size = 2
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.md]
+max_line_length = off
+trim_trailing_whitespace = false
diff --git a/Demos/Spring/client/.gitignore b/Demos/Spring/client/.gitignore
new file mode 100644
index 0000000..ee5c9d8
--- /dev/null
+++ b/Demos/Spring/client/.gitignore
@@ -0,0 +1,39 @@
+# See http://help.github.com/ignore-files/ for more about ignoring files.
+
+# compiled output
+/dist
+/tmp
+/out-tsc
+
+# dependencies
+/node_modules
+
+# IDEs and editors
+/.idea
+.project
+.classpath
+.c9/
+*.launch
+.settings/
+*.sublime-workspace
+
+# IDE - VSCode
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+
+# misc
+/.sass-cache
+/connect.lock
+/coverage
+/libpeerconnection.log
+npm-debug.log
+yarn-error.log
+testem.log
+/typings
+
+# System Files
+.DS_Store
+Thumbs.db
diff --git a/Demos/Spring/client/.prettierignore b/Demos/Spring/client/.prettierignore
new file mode 100644
index 0000000..d0b804d
--- /dev/null
+++ b/Demos/Spring/client/.prettierignore
@@ -0,0 +1,4 @@
+# Add files here to ignore them from prettier formatting
+
+/dist
+/coverage
diff --git a/Demos/Spring/client/.prettierrc b/Demos/Spring/client/.prettierrc
new file mode 100644
index 0000000..544138b
--- /dev/null
+++ b/Demos/Spring/client/.prettierrc
@@ -0,0 +1,3 @@
+{
+ "singleQuote": true
+}
diff --git a/Demos/Spring/client/.vscode/extensions.json b/Demos/Spring/client/.vscode/extensions.json
new file mode 100644
index 0000000..7804e26
--- /dev/null
+++ b/Demos/Spring/client/.vscode/extensions.json
@@ -0,0 +1,8 @@
+{
+ "recommendations": [
+ "nrwl.angular-console",
+ "angular.ng-template",
+ "ms-vscode.vscode-typescript-tslint-plugin",
+ "esbenp.prettier-vscode"
+ ]
+}
diff --git a/Demos/Spring/client/README.md b/Demos/Spring/client/README.md
new file mode 100644
index 0000000..8337f8c
--- /dev/null
+++ b/Demos/Spring/client/README.md
@@ -0,0 +1,84 @@
+# Client
+
+This project was generated using [Nx](https://nx.dev).
+
+
+
+🔎 **Nx is a set of Extensible Dev Tools for Monorepos.**
+
+## Quick Start & Documentation
+
+[Nx Documentation](https://nx.dev/angular)
+
+[10-minute video showing all Nx features](https://nx.dev/angular/getting-started/what-is-nx)
+
+[Interactive Tutorial](https://nx.dev/angular/tutorial/01-create-application)
+
+## Adding capabilities to your workspace
+
+Nx supports many plugins which add capabilities for developing different types of applications and different tools.
+
+These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects as well.
+
+Below are some plugins which you can add to your workspace:
+
+- [Angular](https://angular.io)
+ - `ng add @nrwl/angular`
+- [React](https://reactjs.org)
+ - `ng add @nrwl/react`
+- Web (no framework frontends)
+ - `ng add @nrwl/web`
+- [Nest](https://nestjs.com)
+ - `ng add @nrwl/nest`
+- [Express](https://expressjs.com)
+ - `ng add @nrwl/express`
+- [Node](https://nodejs.org)
+ - `ng add @nrwl/node`
+
+## Generate an application
+
+Run `ng g @nrwl/angular:app my-app` to generate an application.
+
+> You can use any of the plugins above to generate applications as well.
+
+When using Nx, you can create multiple applications and libraries in the same workspace.
+
+## Generate a library
+
+Run `ng g @nrwl/angular:lib my-lib` to generate a library.
+
+> You can also use any of the plugins above to generate libraries as well.
+
+Libraries are sharable across libraries and applications. They can be imported from `@client/mylib`.
+
+## Development server
+
+Run `ng serve my-app` for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
+
+## Code scaffolding
+
+Run `ng g component my-component --project=my-app` to generate a new component.
+
+## Build
+
+Run `ng build my-app` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
+
+## Running unit tests
+
+Run `ng test my-app` to execute the unit tests via [Jest](https://jestjs.io).
+
+Run `nx affected:test` to execute the unit tests affected by a change.
+
+## Running end-to-end tests
+
+Run `ng e2e my-app` to execute the end-to-end tests via [Cypress](https://www.cypress.io).
+
+Run `nx affected:e2e` to execute the end-to-end tests affected by a change.
+
+## Understand your workspace
+
+Run `nx dep-graph` to see a diagram of the dependencies of your projects.
+
+## Further help
+
+Visit the [Nx Documentation](https://nx.dev/angular) to learn more.
diff --git a/Demos/Spring/client/angular.json b/Demos/Spring/client/angular.json
new file mode 100644
index 0000000..ce7271a
--- /dev/null
+++ b/Demos/Spring/client/angular.json
@@ -0,0 +1,140 @@
+{
+ "version": 1,
+ "projects": {
+ "annotation": {
+ "projectType": "application",
+ "schematics": {
+ "@nrwl/angular:component": {
+ "style": "less"
+ }
+ },
+ "root": "apps/annotation",
+ "sourceRoot": "apps/annotation/src",
+ "prefix": "client",
+ "architect": {
+ "build": {
+ "builder": "@angular-devkit/build-angular:browser",
+ "options": {
+ "outputPath": "../src/main/resources/static/angular/annotation",
+ "index": "apps/annotation/src/index.html",
+ "main": "apps/annotation/src/main.ts",
+ "polyfills": "apps/annotation/src/polyfills.ts",
+ "tsConfig": "apps/annotation/tsconfig.app.json",
+ "aot": true,
+ "assets": [
+ "apps/annotation/src/favicon.ico",
+ "apps/annotation/src/assets"
+ ],
+ "styles": ["apps/annotation/src/styles.less"],
+ "scripts": []
+ },
+ "configurations": {
+ "production": {
+ "fileReplacements": [
+ {
+ "replace": "apps/annotation/src/environments/environment.ts",
+ "with": "apps/annotation/src/environments/environment.prod.ts"
+ }
+ ],
+ "optimization": true,
+ "outputHashing": "all",
+ "sourceMap": false,
+ "extractCss": true,
+ "namedChunks": false,
+ "extractLicenses": true,
+ "vendorChunk": false,
+ "buildOptimizer": true,
+ "budgets": [
+ {
+ "type": "initial",
+ "maximumWarning": "2mb",
+ "maximumError": "5mb"
+ },
+ {
+ "type": "anyComponentStyle",
+ "maximumWarning": "6kb",
+ "maximumError": "10kb"
+ }
+ ]
+ }
+ }
+ },
+ "serve": {
+ "builder": "@angular-devkit/build-angular:dev-server",
+ "options": {
+ "browserTarget": "annotation:build"
+ },
+ "configurations": {
+ "production": {
+ "browserTarget": "annotation:build:production"
+ }
+ }
+ },
+ "extract-i18n": {
+ "builder": "@angular-devkit/build-angular:extract-i18n",
+ "options": {
+ "browserTarget": "annotation:build"
+ }
+ },
+ "lint": {
+ "builder": "@angular-devkit/build-angular:tslint",
+ "options": {
+ "tsConfig": [
+ "apps/annotation/tsconfig.app.json",
+ "apps/annotation/tsconfig.spec.json"
+ ],
+ "exclude": ["**/node_modules/**", "!apps/annotation/**"]
+ }
+ },
+ "test": {
+ "builder": "@nrwl/jest:jest",
+ "options": {
+ "jestConfig": "apps/annotation/jest.config.js",
+ "tsConfig": "apps/annotation/tsconfig.spec.json",
+ "setupFile": "apps/annotation/src/test-setup.ts"
+ }
+ }
+ }
+ },
+ "annotation-e2e": {
+ "root": "apps/annotation-e2e",
+ "sourceRoot": "apps/annotation-e2e/src",
+ "projectType": "application",
+ "architect": {
+ "e2e": {
+ "builder": "@nrwl/cypress:cypress",
+ "options": {
+ "cypressConfig": "apps/annotation-e2e/cypress.json",
+ "tsConfig": "apps/annotation-e2e/tsconfig.e2e.json",
+ "devServerTarget": "annotation:serve"
+ },
+ "configurations": {
+ "production": {
+ "devServerTarget": "annotation:serve:production"
+ }
+ }
+ },
+ "lint": {
+ "builder": "@angular-devkit/build-angular:tslint",
+ "options": {
+ "tsConfig": ["apps/annotation-e2e/tsconfig.e2e.json"],
+ "exclude": ["**/node_modules/**", "!apps/annotation-e2e/**"]
+ }
+ }
+ }
+ }
+ },
+ "cli": {
+ "defaultCollection": "@nrwl/angular"
+ },
+ "schematics": {
+ "@nrwl/angular:application": {
+ "unitTestRunner": "jest",
+ "e2eTestRunner": "cypress"
+ },
+ "@nrwl/angular:library": {
+ "unitTestRunner": "jest"
+ }
+ },
+ "defaultProject": "annotation"
+}
diff --git a/Demos/Spring/client/apps/.gitkeep b/Demos/Spring/client/apps/.gitkeep
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/Demos/Spring/client/apps/.gitkeep
@@ -0,0 +1 @@
+
diff --git a/Demos/Spring/client/apps/annotation-e2e/cypress.json b/Demos/Spring/client/apps/annotation-e2e/cypress.json
new file mode 100644
index 0000000..156cb77
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation-e2e/cypress.json
@@ -0,0 +1,12 @@
+{
+ "fileServerFolder": ".",
+ "fixturesFolder": "./src/fixtures",
+ "integrationFolder": "./src/integration",
+ "modifyObstructiveCode": false,
+ "pluginsFile": "./src/plugins/index",
+ "supportFile": "./src/support/index.ts",
+ "video": true,
+ "videosFolder": "../../dist/cypress/apps/annotation-e2e/videos",
+ "screenshotsFolder": "../../dist/cypress/apps/annotation-e2e/screenshots",
+ "chromeWebSecurity": false
+}
diff --git a/Demos/Spring/client/apps/annotation-e2e/src/fixtures/example.json b/Demos/Spring/client/apps/annotation-e2e/src/fixtures/example.json
new file mode 100644
index 0000000..294cbed
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation-e2e/src/fixtures/example.json
@@ -0,0 +1,4 @@
+{
+ "name": "Using fixtures to represent data",
+ "email": "hello@cypress.io"
+}
diff --git a/Demos/Spring/client/apps/annotation-e2e/src/integration/app.spec.ts b/Demos/Spring/client/apps/annotation-e2e/src/integration/app.spec.ts
new file mode 100644
index 0000000..e75549a
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation-e2e/src/integration/app.spec.ts
@@ -0,0 +1,13 @@
+import { getGreeting } from '../support/app.po';
+
+describe('annotation', () => {
+ beforeEach(() => cy.visit('/'));
+
+ it('should display welcome message', () => {
+ // Custom command example, see `../support/commands.ts` file
+ cy.login('my-email@something.com', 'myPassword');
+
+ // Function helper example, see `../support/app.po.ts` file
+ getGreeting().contains('Welcome to annotation!');
+ });
+});
diff --git a/Demos/Spring/client/apps/annotation-e2e/src/plugins/index.js b/Demos/Spring/client/apps/annotation-e2e/src/plugins/index.js
new file mode 100644
index 0000000..9067e75
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation-e2e/src/plugins/index.js
@@ -0,0 +1,22 @@
+// ***********************************************************
+// This example plugins/index.js can be used to load plugins
+//
+// You can change the location of this file or turn off loading
+// the plugins file with the 'pluginsFile' configuration option.
+//
+// You can read more here:
+// https://on.cypress.io/plugins-guide
+// ***********************************************************
+
+// This function is called when a project is opened or re-opened (e.g. due to
+// the project's config changing)
+
+const { preprocessTypescript } = require('@nrwl/cypress/plugins/preprocessor');
+
+module.exports = (on, config) => {
+ // `on` is used to hook into various events Cypress emits
+ // `config` is the resolved Cypress config
+
+ // Preprocess Typescript file using Nx helper
+ on('file:preprocessor', preprocessTypescript(config));
+};
diff --git a/Demos/Spring/client/apps/annotation-e2e/src/support/app.po.ts b/Demos/Spring/client/apps/annotation-e2e/src/support/app.po.ts
new file mode 100644
index 0000000..3293424
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation-e2e/src/support/app.po.ts
@@ -0,0 +1 @@
+export const getGreeting = () => cy.get('h1');
diff --git a/Demos/Spring/client/apps/annotation-e2e/src/support/commands.ts b/Demos/Spring/client/apps/annotation-e2e/src/support/commands.ts
new file mode 100644
index 0000000..61b3a3e
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation-e2e/src/support/commands.ts
@@ -0,0 +1,31 @@
+// ***********************************************
+// This example commands.js shows you how to
+// create various custom commands and overwrite
+// existing commands.
+//
+// For more comprehensive examples of custom
+// commands please read more here:
+// https://on.cypress.io/custom-commands
+// ***********************************************
+// eslint-disable-next-line @typescript-eslint/no-namespace
+declare namespace Cypress {
+ interface Chainable {
+ login(email: string, password: string): void;
+ }
+}
+//
+// -- This is a parent command --
+Cypress.Commands.add('login', (email, password) => {
+ console.log('Custom command example: Login', email, password);
+});
+//
+// -- This is a child command --
+// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
+//
+//
+// -- This is a dual command --
+// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
+//
+//
+// -- This will overwrite an existing command --
+// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
diff --git a/Demos/Spring/client/apps/annotation-e2e/src/support/index.ts b/Demos/Spring/client/apps/annotation-e2e/src/support/index.ts
new file mode 100644
index 0000000..3d469a6
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation-e2e/src/support/index.ts
@@ -0,0 +1,17 @@
+// ***********************************************************
+// This example support/index.js is processed and
+// loaded automatically before your test files.
+//
+// This is a great place to put global configuration and
+// behavior that modifies Cypress.
+//
+// You can change the location of this file or turn off
+// automatically serving support files with the
+// 'supportFile' configuration option.
+//
+// You can read more here:
+// https://on.cypress.io/configuration
+// ***********************************************************
+
+// Import commands.js using ES2015 syntax:
+import './commands';
diff --git a/Demos/Spring/client/apps/annotation-e2e/tsconfig.e2e.json b/Demos/Spring/client/apps/annotation-e2e/tsconfig.e2e.json
new file mode 100644
index 0000000..824748b
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation-e2e/tsconfig.e2e.json
@@ -0,0 +1,8 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "sourceMap": false,
+ "outDir": "../../dist/out-tsc"
+ },
+ "include": ["src/**/*.ts", "src/**/*.js"]
+}
diff --git a/Demos/Spring/client/apps/annotation-e2e/tsconfig.json b/Demos/Spring/client/apps/annotation-e2e/tsconfig.json
new file mode 100644
index 0000000..d8d4ea3
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation-e2e/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "types": ["cypress", "node"]
+ },
+ "include": ["**/*.ts", "**/*.js"]
+}
diff --git a/Demos/Spring/client/apps/annotation-e2e/tslint.json b/Demos/Spring/client/apps/annotation-e2e/tslint.json
new file mode 100644
index 0000000..8acd9a3
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation-e2e/tslint.json
@@ -0,0 +1 @@
+{ "extends": "../../tslint.json", "rules": {} }
diff --git a/Demos/Spring/client/apps/annotation/browserslist b/Demos/Spring/client/apps/annotation/browserslist
new file mode 100644
index 0000000..8084853
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/browserslist
@@ -0,0 +1,12 @@
+# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
+# For additional information regarding the format and rule options, please see:
+# https://github.com/browserslist/browserslist#queries
+
+# You can see what browsers were selected by your queries by running:
+# npx browserslist
+
+> 0.5%
+last 2 versions
+Firefox ESR
+not dead
+not IE 9-11 # For IE 9-11 support, remove 'not'.
\ No newline at end of file
diff --git a/Demos/Spring/client/apps/annotation/jest.config.js b/Demos/Spring/client/apps/annotation/jest.config.js
new file mode 100644
index 0000000..dd90dfa
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/jest.config.js
@@ -0,0 +1,10 @@
+module.exports = {
+ name: 'annotation',
+ preset: '../../jest.config.js',
+ coverageDirectory: '../../coverage/apps/annotation',
+ snapshotSerializers: [
+ 'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js',
+ 'jest-preset-angular/build/AngularSnapshotSerializer.js',
+ 'jest-preset-angular/build/HTMLCommentSerializer.js'
+ ]
+};
diff --git a/Demos/Spring/client/apps/annotation/src/app/app.component.html b/Demos/Spring/client/apps/annotation/src/app/app.component.html
new file mode 100644
index 0000000..557d7ad
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/src/app/app.component.html
@@ -0,0 +1 @@
+
diff --git a/Demos/Spring/client/apps/annotation/src/app/app.component.less b/Demos/Spring/client/apps/annotation/src/app/app.component.less
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Spring/client/apps/annotation/src/app/app.component.spec.ts b/Demos/Spring/client/apps/annotation/src/app/app.component.spec.ts
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Spring/client/apps/annotation/src/app/app.component.ts b/Demos/Spring/client/apps/annotation/src/app/app.component.ts
new file mode 100644
index 0000000..e6fb213
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/src/app/app.component.ts
@@ -0,0 +1,10 @@
+import { Component } from '@angular/core';
+
+@Component({
+ selector: 'client-root',
+ templateUrl: './app.component.html',
+ styleUrls: ['./app.component.less']
+})
+export class AppComponent {
+ title = 'annotation';
+}
diff --git a/Demos/Spring/client/apps/annotation/src/app/app.module.ts b/Demos/Spring/client/apps/annotation/src/app/app.module.ts
new file mode 100644
index 0000000..0507138
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/src/app/app.module.ts
@@ -0,0 +1,16 @@
+import {BrowserModule} from '@angular/platform-browser';
+import {NgModule} from '@angular/core';
+
+import {AppComponent} from './app.component';
+import {AnnotationModule} from "@groupdocs.examples.angular/annotation";
+
+import { TranslateModule } from '@ngx-translate/core';
+
+@NgModule({
+ declarations: [AppComponent],
+ imports: [BrowserModule, AnnotationModule, TranslateModule.forRoot()],
+ providers: [],
+ bootstrap: [AppComponent],
+})
+export class AppModule {
+}
diff --git a/Demos/Spring/client/apps/annotation/src/assets/.gitkeep b/Demos/Spring/client/apps/annotation/src/assets/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Spring/client/apps/annotation/src/environments/environment.prod.ts b/Demos/Spring/client/apps/annotation/src/environments/environment.prod.ts
new file mode 100644
index 0000000..3612073
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/src/environments/environment.prod.ts
@@ -0,0 +1,3 @@
+export const environment = {
+ production: true
+};
diff --git a/Demos/Spring/client/apps/annotation/src/environments/environment.ts b/Demos/Spring/client/apps/annotation/src/environments/environment.ts
new file mode 100644
index 0000000..7b4f817
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/src/environments/environment.ts
@@ -0,0 +1,16 @@
+// This file can be replaced during build by using the `fileReplacements` array.
+// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
+// The list of file replacements can be found in `angular.json`.
+
+export const environment = {
+ production: false
+};
+
+/*
+ * For easier debugging in development mode, you can import the following file
+ * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
+ *
+ * This import should be commented out in production mode because it will have a negative impact
+ * on performance if an error is thrown.
+ */
+// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
diff --git a/Demos/Spring/client/apps/annotation/src/favicon.ico b/Demos/Spring/client/apps/annotation/src/favicon.ico
new file mode 100644
index 0000000..317ebcb
Binary files /dev/null and b/Demos/Spring/client/apps/annotation/src/favicon.ico differ
diff --git a/Demos/Spring/client/apps/annotation/src/index.html b/Demos/Spring/client/apps/annotation/src/index.html
new file mode 100644
index 0000000..70c837f
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/src/index.html
@@ -0,0 +1,13 @@
+
+
+
+
+ Annotation
+
+
+
+
+
+
+
+
diff --git a/Demos/Spring/client/apps/annotation/src/main.ts b/Demos/Spring/client/apps/annotation/src/main.ts
new file mode 100644
index 0000000..fa4e0ae
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/src/main.ts
@@ -0,0 +1,13 @@
+import { enableProdMode } from '@angular/core';
+import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
+
+import { AppModule } from './app/app.module';
+import { environment } from './environments/environment';
+
+if (environment.production) {
+ enableProdMode();
+}
+
+platformBrowserDynamic()
+ .bootstrapModule(AppModule)
+ .catch(err => console.error(err));
diff --git a/Demos/Spring/client/apps/annotation/src/polyfills.ts b/Demos/Spring/client/apps/annotation/src/polyfills.ts
new file mode 100644
index 0000000..2f258e5
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/src/polyfills.ts
@@ -0,0 +1,62 @@
+/**
+ * This file includes polyfills needed by Angular and is loaded before the app.
+ * You can add your own extra polyfills to this file.
+ *
+ * This file is divided into 2 sections:
+ * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
+ * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
+ * file.
+ *
+ * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
+ * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
+ * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
+ *
+ * Learn more in https://angular.io/guide/browser-support
+ */
+
+/***************************************************************************************************
+ * BROWSER POLYFILLS
+ */
+
+/** IE10 and IE11 requires the following for NgClass support on SVG elements */
+// import 'classlist.js'; // Run `npm install --save classlist.js`.
+
+/**
+ * Web Animations `@angular/platform-browser/animations`
+ * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
+ * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
+ */
+// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
+
+/**
+ * By default, zone.js will patch all possible macroTask and DomEvents
+ * user can disable parts of macroTask/DomEvents patch by setting following flags
+ * because those flags need to be set before `zone.js` being loaded, and webpack
+ * will put import in the top of bundle, so user need to create a separate file
+ * in this directory (for example: zone-flags.ts), and put the following flags
+ * into that file, and then add the following code before importing zone.js.
+ * import './zone-flags.ts';
+ *
+ * The flags allowed in zone-flags.ts are listed here.
+ *
+ * The following flags will work for all browsers.
+ *
+ * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
+ * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
+ * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
+ *
+ * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
+ * with the following flag, it will bypass `zone.js` patch for IE/Edge
+ *
+ * (window as any).__Zone_enable_cross_context_check = true;
+ *
+ */
+
+/***************************************************************************************************
+ * Zone JS is required by default for Angular itself.
+ */
+import 'zone.js/dist/zone'; // Included with Angular CLI.
+
+/***************************************************************************************************
+ * APPLICATION IMPORTS
+ */
diff --git a/Demos/Spring/client/apps/annotation/src/styles.less b/Demos/Spring/client/apps/annotation/src/styles.less
new file mode 100644
index 0000000..90d4ee0
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/src/styles.less
@@ -0,0 +1 @@
+/* You can add global styles to this file, and also import other style files */
diff --git a/Demos/Spring/client/apps/annotation/src/test-setup.ts b/Demos/Spring/client/apps/annotation/src/test-setup.ts
new file mode 100644
index 0000000..8d88704
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/src/test-setup.ts
@@ -0,0 +1 @@
+import 'jest-preset-angular';
diff --git a/Demos/Spring/client/apps/annotation/tsconfig.app.json b/Demos/Spring/client/apps/annotation/tsconfig.app.json
new file mode 100644
index 0000000..12dc816
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/tsconfig.app.json
@@ -0,0 +1,10 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../dist/out-tsc",
+ "types": []
+ },
+ "files": ["src/main.ts", "src/polyfills.ts"],
+ "include": ["**/*.ts"],
+ "exclude": ["src/test-setup.ts", "**/*.spec.ts"]
+}
diff --git a/Demos/Spring/client/apps/annotation/tsconfig.json b/Demos/Spring/client/apps/annotation/tsconfig.json
new file mode 100644
index 0000000..e5decd5
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.json",
+ "compilerOptions": {
+ "types": ["node", "jest"]
+ },
+ "include": ["**/*.ts"]
+}
diff --git a/Demos/Spring/client/apps/annotation/tsconfig.spec.json b/Demos/Spring/client/apps/annotation/tsconfig.spec.json
new file mode 100644
index 0000000..cfff29a
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/tsconfig.spec.json
@@ -0,0 +1,10 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../../dist/out-tsc",
+ "module": "commonjs",
+ "types": ["jest", "node"]
+ },
+ "files": ["src/test-setup.ts"],
+ "include": ["**/*.spec.ts", "**/*.d.ts"]
+}
diff --git a/Demos/Spring/client/apps/annotation/tslint.json b/Demos/Spring/client/apps/annotation/tslint.json
new file mode 100644
index 0000000..df75834
--- /dev/null
+++ b/Demos/Spring/client/apps/annotation/tslint.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tslint.json",
+ "rules": {
+ "directive-selector": [true, "attribute", "client", "camelCase"],
+ "component-selector": [true, "element", "client", "kebab-case"]
+ }
+}
diff --git a/Demos/Spring/client/jest.config.js b/Demos/Spring/client/jest.config.js
new file mode 100644
index 0000000..ffd5ba2
--- /dev/null
+++ b/Demos/Spring/client/jest.config.js
@@ -0,0 +1,10 @@
+module.exports = {
+ testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
+ transform: {
+ '^.+\\.(ts|js|html)$': 'ts-jest'
+ },
+ resolver: '@nrwl/jest/plugins/resolver',
+ moduleFileExtensions: ['ts', 'js', 'html'],
+ coverageReporters: ['html'],
+ passWithNoTests: true
+};
diff --git a/Demos/Spring/client/libs/.gitkeep b/Demos/Spring/client/libs/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Spring/client/nx.json b/Demos/Spring/client/nx.json
new file mode 100644
index 0000000..dc5026e
--- /dev/null
+++ b/Demos/Spring/client/nx.json
@@ -0,0 +1,19 @@
+{
+ "npmScope": "client",
+ "implicitDependencies": {
+ "angular.json": "*",
+ "package.json": "*",
+ "tsconfig.json": "*",
+ "tslint.json": "*",
+ "nx.json": "*"
+ },
+ "projects": {
+ "annotation": {
+ "tags": []
+ },
+ "annotation-e2e": {
+ "tags": [],
+ "implicitDependencies": ["annotation"]
+ }
+ }
+}
diff --git a/Demos/Spring/client/package.json b/Demos/Spring/client/package.json
new file mode 100644
index 0000000..868dc0e
--- /dev/null
+++ b/Demos/Spring/client/package.json
@@ -0,0 +1,67 @@
+{
+ "name": "client",
+ "version": "0.0.0",
+ "license": "MIT",
+ "scripts": {
+ "ng": "ng",
+ "nx": "nx",
+ "start": "ng serve",
+ "build": "ng build",
+ "test": "ng test",
+ "lint": "nx workspace-lint && ng lint",
+ "e2e": "ng e2e",
+ "affected:apps": "nx affected:apps",
+ "affected:libs": "nx affected:libs",
+ "affected:build": "nx affected:build",
+ "affected:e2e": "nx affected:e2e",
+ "affected:test": "nx affected:test",
+ "affected:lint": "nx affected:lint",
+ "affected:dep-graph": "nx affected:dep-graph",
+ "affected": "nx affected",
+ "format": "nx format:write",
+ "format:write": "nx format:write",
+ "format:check": "nx format:check",
+ "update": "ng update @nrwl/workspace",
+ "workspace-schematic": "nx workspace-schematic",
+ "dep-graph": "nx dep-graph",
+ "help": "nx help"
+ },
+ "private": true,
+ "dependencies": {
+ "@angular/animations": "^8.2.4",
+ "@angular/common": "^8.2.4",
+ "@angular/compiler": "^8.2.4",
+ "@angular/core": "^8.2.4",
+ "@angular/forms": "^8.2.4",
+ "@angular/platform-browser": "^8.2.4",
+ "@angular/platform-browser-dynamic": "^8.2.4",
+ "@angular/router": "^8.2.4",
+ "@groupdocs.examples.angular/annotation": "^0.8.100",
+ "@nrwl/angular": "^8.12.11",
+ "common-components": "^1.0.5",
+ "core-js": "^2.6.11",
+ "rxjs": "~6.4.0",
+ "zone.js": "^0.9.1"
+ },
+ "devDependencies": {
+ "@angular-devkit/build-angular": "^0.800.1",
+ "@angular/cli": "8.1.1",
+ "@angular/compiler-cli": "^8.2.13",
+ "@angular/language-service": "^8.2.13",
+ "@nrwl/cypress": "8.12.11",
+ "@nrwl/jest": "8.12.11",
+ "@nrwl/workspace": "8.12.11",
+ "@types/jest": "24.0.9",
+ "@types/node": "~8.9.4",
+ "codelyzer": "~5.0.1",
+ "cypress": "~3.8.2",
+ "dotenv": "6.2.0",
+ "jest": "24.1.0",
+ "jest-preset-angular": "7.0.0",
+ "prettier": "1.18.2",
+ "ts-jest": "24.0.0",
+ "ts-node": "~7.0.0",
+ "tslint": "~5.11.0",
+ "typescript": "~3.4.5"
+ }
+}
diff --git a/Demos/Spring/client/tools/schematics/.gitkeep b/Demos/Spring/client/tools/schematics/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Spring/client/tools/tsconfig.tools.json b/Demos/Spring/client/tools/tsconfig.tools.json
new file mode 100644
index 0000000..82bd1f0
--- /dev/null
+++ b/Demos/Spring/client/tools/tsconfig.tools.json
@@ -0,0 +1,11 @@
+{
+ "extends": "../tsconfig.json",
+ "compilerOptions": {
+ "outDir": "../dist/out-tsc/tools",
+ "rootDir": ".",
+ "module": "commonjs",
+ "target": "es5",
+ "types": ["node"]
+ },
+ "include": ["**/*.ts"]
+}
diff --git a/Demos/Spring/client/tsconfig.json b/Demos/Spring/client/tsconfig.json
new file mode 100644
index 0000000..a5099b5
--- /dev/null
+++ b/Demos/Spring/client/tsconfig.json
@@ -0,0 +1,21 @@
+{
+ "compileOnSave": false,
+ "compilerOptions": {
+ "rootDir": ".",
+ "sourceMap": true,
+ "declaration": false,
+ "moduleResolution": "node",
+ "emitDecoratorMetadata": true,
+ "experimentalDecorators": true,
+ "importHelpers": true,
+ "target": "es2015",
+ "module": "esnext",
+ "typeRoots": ["node_modules/@types"],
+ "lib": ["es2017", "dom"],
+ "skipLibCheck": true,
+ "skipDefaultLibCheck": true,
+ "baseUrl": ".",
+ "paths": {}
+ },
+ "exclude": ["node_modules", "tmp"]
+}
diff --git a/Demos/Spring/client/tslint.json b/Demos/Spring/client/tslint.json
new file mode 100644
index 0000000..2533001
--- /dev/null
+++ b/Demos/Spring/client/tslint.json
@@ -0,0 +1,80 @@
+{
+ "rulesDirectory": [
+ "node_modules/@nrwl/workspace/src/tslint",
+ "node_modules/codelyzer"
+ ],
+ "rules": {
+ "arrow-return-shorthand": true,
+ "callable-types": true,
+ "class-name": true,
+ "deprecation": {
+ "severity": "warn"
+ },
+ "forin": true,
+ "import-blacklist": [true, "rxjs/Rx"],
+ "interface-over-type-literal": true,
+ "member-access": false,
+ "member-ordering": [
+ true,
+ {
+ "order": [
+ "static-field",
+ "instance-field",
+ "static-method",
+ "instance-method"
+ ]
+ }
+ ],
+ "no-arg": true,
+ "no-bitwise": true,
+ "no-console": [true, "debug", "info", "time", "timeEnd", "trace"],
+ "no-construct": true,
+ "no-debugger": true,
+ "no-duplicate-super": true,
+ "no-empty": false,
+ "no-empty-interface": true,
+ "no-eval": true,
+ "no-inferrable-types": [true, "ignore-params"],
+ "no-misused-new": true,
+ "no-non-null-assertion": true,
+ "no-shadowed-variable": true,
+ "no-string-literal": false,
+ "no-string-throw": true,
+ "no-switch-case-fall-through": true,
+ "no-unnecessary-initializer": true,
+ "no-unused-expression": true,
+ "no-var-keyword": true,
+ "object-literal-sort-keys": false,
+ "prefer-const": true,
+ "radix": true,
+ "triple-equals": [true, "allow-null-check"],
+ "unified-signatures": true,
+ "variable-name": false,
+ "nx-enforce-module-boundaries": [
+ true,
+ {
+ "allow": [],
+ "depConstraints": [
+ {
+ "sourceTag": "*",
+ "onlyDependOnLibsWithTags": ["*"]
+ }
+ ]
+ }
+ ],
+ "directive-selector": [true, "attribute", "app", "camelCase"],
+ "component-selector": [true, "element", "app", "kebab-case"],
+ "no-conflicting-lifecycle": true,
+ "no-host-metadata-property": true,
+ "no-input-rename": true,
+ "no-inputs-metadata-property": true,
+ "no-output-native": true,
+ "no-output-on-prefix": true,
+ "no-output-rename": true,
+ "no-outputs-metadata-property": true,
+ "template-banana-in-box": true,
+ "template-no-negated-async": true,
+ "use-lifecycle-interface": true,
+ "use-pipe-transform-interface": true
+ }
+}
diff --git a/Demos/Spring/configuration.yml b/Demos/Spring/configuration.yml
new file mode 100644
index 0000000..f270a61
--- /dev/null
+++ b/Demos/Spring/configuration.yml
@@ -0,0 +1,99 @@
+################################################
+# Server configurations
+################################################
+server:
+ connector:
+ # Changing port is available for embedded server only
+ # Is is not possible to change port for deploying application on external server
+ port: 8080
+
+
+################################################
+# Application (global) configurations
+################################################
+application:
+ # License path
+ # Absolute path to GroupDocs license file
+ licensePath:
+ # Host name or ip for server instance
+ hostAddress:
+
+
+################################################
+# Common configurations
+################################################
+common:
+ # File rewriting on document uploading
+ # Set false to keep both files
+ # Set true to replace files with same name
+ rewrite: true
+ # Page navigation
+ # Set false to disable document navigation (go to next, previous, last and first page)
+ pageSelector: true
+ # Document download
+ # Set false to disable document download
+ download: true
+ # Document upload
+ # Set false to disable document upload
+ upload: true
+ # Document print
+ # Set false to disable document print
+ print: true
+ # File browser
+ # Set false to disable document browse
+ browse: true
+ # Set false to disable right mouse click
+ enableRightClick: true
+
+################################################
+# GroupDocs.Annotation configurations
+################################################
+annotation:
+ # Files directory path
+ # Absolute path to files directory
+ filesDirectory: DocumentSamples
+ # Default document
+ # Absolute path to default document
+ defaultDocument:
+ # Pages preload
+ # How many pages from a document should be loaded, remaining pages will be loaded on page scrolling
+ # Set 0 to load all pages at once
+ preloadPageCount: 0
+ # Fonts path
+ # Absolute path to custom fonts directory
+ fontsDirectory:
+ # Enable/disable Text annotation
+ textAnnotation: true
+ # Enable/disable Area annotation
+ areaAnnotation: true
+ # Enable/disable Point annotation
+ pointAnnotation: true
+ # Enable/disable TextStrikeout annotation
+ textStrikeoutAnnotation: true
+ # Enable/disable Polyline annotation
+ polylineAnnotation: true
+ # Enable/disable TextField annotation
+ textFieldAnnotation: true
+ # Enable/disable Watermark annotation
+ watermarkAnnotation: true
+ # Enable/disable TextReplacement annotation
+ textReplacementAnnotation: true
+ # Enable/disable Arrow annotation
+ arrowAnnotation: true
+ # Enable/disable TextRedaction annotation
+ textRedactionAnnotation: true
+ # Enable/disable ResourcesRedaction annotation
+ resourcesRedactionAnnotation: true
+ # Enable/disable TextUnderline annotation
+ textUnderlineAnnotation: true
+ # Enable/disable Distance annotation
+ distanceAnnotation: true
+ # Enable/disable original document downloading
+ downloadOriginal: true
+ # Enable/disable signed document downloading
+ downloadAnnotated: true
+ # Enable/disable zoom
+ zoom: true
+ # Enable/disable fit width
+ # set true to zoom document pages fit width
+ fitWidth: true
diff --git a/Demos/Spring/pom.xml b/Demos/Spring/pom.xml
new file mode 100644
index 0000000..db09fbb
--- /dev/null
+++ b/Demos/Spring/pom.xml
@@ -0,0 +1,264 @@
+
+
+ 4.0.0
+
+ com.groupdocs.ui
+ annotation-spring
+ 1.12.28
+ ${packaging.type}
+
+ GroupDocs.Annotation for Java Spring Sample
+ https://groupdocs.com
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.0.4.RELEASE
+
+
+
+
+
+ jar
+
+
+ true
+
+
+ jar
+ compile
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.4.3
+
+
+ package
+
+ shade
+
+
+
+
+ META-INF/spring.handlers
+
+
+ META-INF/spring.factories
+
+
+ META-INF/spring.schemas
+
+
+
+ com.groupdocs.ui.Application
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+ war
+
+ war
+ provided
+
+
+
+
+
+ com.groupdocs.ui.Application
+ 1.8
+ UTF-8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+ 2.0.4.RELEASE
+
+
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+ 2.0.4.RELEASE
+ ${scope}
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ 2.0.4.RELEASE
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+ 2.0.4.RELEASE
+
+
+ com.groupdocs
+ groupdocs-annotation
+ 25.6
+
+
+ com.google.guava
+ guava
+ 11.0.2
+
+
+ commons-io
+ commons-io
+ 2.7
+
+
+
+
+
+ GroupDocsJavaAPI
+ GroupDocs Java API
+ https://artifact.groupdocs.com/repo/
+
+
+ aspose-central
+ repository.aspose.com-releases
+ https://repository.aspose.com/repo
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.0
+
+ 1.8
+ 1.8
+
+
+
+ com.github.eirslett
+ frontend-maven-plugin
+ 1.6
+
+ client
+
+
+
+
+ install node and npm
+
+ install-node-and-npm
+
+
+ v10.15.1
+
+
+
+ npm install
+
+ npm
+
+
+ install
+
+
+
+ npm update
+
+ npm
+
+
+ update
+
+
+
+ install client
+
+ npm
+
+
+ install
+
+
+
+ build client
+
+ npm
+
+
+ run build
+
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.2
+
+
+ default-prepare-agent
+
+ prepare-agent
+
+
+
+ default-report
+ prepare-package
+
+ report
+
+
+
+
+
+
+
+
+
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/Application.java b/Demos/Spring/src/main/java/com/groupdocs/ui/Application.java
new file mode 100644
index 0000000..a1b1071
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/Application.java
@@ -0,0 +1,88 @@
+package com.groupdocs.ui;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.config.YamlProcessor;
+import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.FileUrlResource;
+import org.springframework.util.StringUtils;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+import java.io.File;
+import java.net.MalformedURLException;
+
+@SpringBootApplication
+public class Application extends SpringBootServletInitializer {
+
+ private static final Logger logger = LoggerFactory.getLogger(Application.class);
+
+ private static final String DEFAULT_CONFIGURATION_FILE = "defaultConfiguration.yml";
+ private static String configurationFile = "configuration.yml";
+
+ public static void main(String[] args) {
+ if (args != null && args.length > 0) {
+ configurationFile = args[0];
+ }
+ SpringApplication.run(Application.class, args);
+ }
+
+ @Override
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+ return application.sources(Application.class);
+ }
+
+ @Bean
+ public static PropertySourcesPlaceholderConfigurer properties() {
+ PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
+ YamlPropertiesFactoryBean propertiesFactoryBean = getYamlPropertiesFactoryBean();
+
+ propertySourcesPlaceholderConfigurer.setProperties(propertiesFactoryBean.getObject());
+ return propertySourcesPlaceholderConfigurer;
+ }
+
+ public static YamlPropertiesFactoryBean getYamlPropertiesFactoryBean() {
+ YamlPropertiesFactoryBean propertiesFactoryBean = new YamlPropertiesFactoryBean();
+ ClassPathResource defaultResource = new ClassPathResource(DEFAULT_CONFIGURATION_FILE);
+
+ File file = StringUtils.isEmpty(configurationFile) ? null : new File(configurationFile);
+ if (file != null && file.exists()) {
+ try {
+ propertiesFactoryBean.setResolutionMethod(YamlProcessor.ResolutionMethod.OVERRIDE_AND_IGNORE);
+ propertiesFactoryBean.setResources(defaultResource, new FileUrlResource(file.toURI().toURL()));
+ } catch (MalformedURLException e) {
+ logger.info("Can not find external configuration file. Use default.");
+ propertiesFactoryBean.setResources(defaultResource);
+ }
+ } else {
+ logger.info("Can not find external configuration file. Use default.");
+ propertiesFactoryBean.setResources(defaultResource);
+ }
+ return propertiesFactoryBean;
+ }
+
+ /**
+ * Configure CORS parameters
+ * @return
+ */
+ @Bean
+ public WebMvcConfigurer corsConfigurer() {
+ return new WebMvcConfigurer() {
+ @Override
+ public void addCorsMappings(CorsRegistry registry) {
+ registry.addMapping("/**")
+ .allowedMethods("GET", "POST", "PUT", "DELETE")
+ .allowedOrigins("*")
+ .allowedHeaders("*");
+ }
+ };
+ }
+
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/ApplicationStartup.java b/Demos/Spring/src/main/java/com/groupdocs/ui/ApplicationStartup.java
new file mode 100644
index 0000000..1eb39cf
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/ApplicationStartup.java
@@ -0,0 +1,29 @@
+package com.groupdocs.ui;
+
+import com.groupdocs.ui.config.ServerConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.web.context.WebServerInitializedEvent;
+import org.springframework.context.ApplicationListener;
+import org.springframework.stereotype.Component;
+
+/**
+ * Component for listening ApplicationContext event
+ */
+@Component
+public class ApplicationStartup implements ApplicationListener {
+
+ @Autowired
+ private ServerConfiguration serverConfiguration;
+
+ /**
+ * This method is called during Spring's startup.
+ *
+ * @param event Event raised when an ApplicationContext gets initialized or
+ * refreshed.
+ */
+ public void onApplicationEvent(WebServerInitializedEvent event) {
+ // use this event for obtaining the local port of a running server
+ serverConfiguration.setHttpPort(event.getWebServer().getPort());
+ }
+
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/ServerPortCustomizer.java b/Demos/Spring/src/main/java/com/groupdocs/ui/ServerPortCustomizer.java
new file mode 100644
index 0000000..233ed55
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/ServerPortCustomizer.java
@@ -0,0 +1,23 @@
+package com.groupdocs.ui;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.web.server.ConfigurableWebServerFactory;
+import org.springframework.boot.web.server.WebServerFactoryCustomizer;
+import org.springframework.stereotype.Component;
+
+/**
+ * Customize port from configuration properties
+ */
+@Component
+public class ServerPortCustomizer implements WebServerFactoryCustomizer {
+
+ private static final int DEFAULT_PORT = 8080;
+
+ @Value("#{new Integer('${server.connector.port}')}")
+ private Integer port;
+
+ @Override
+ public void customize(ConfigurableWebServerFactory factory) {
+ factory.setPort(port != null ? port : DEFAULT_PORT);
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/AbstractTextAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/AbstractTextAnnotator.java
new file mode 100644
index 0000000..21dd199
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/AbstractTextAnnotator.java
@@ -0,0 +1,23 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.Point;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class AbstractTextAnnotator extends BaseAnnotator {
+
+ protected AbstractTextAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+ }
+
+ protected static java.util.List getPoints(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ List tmp0 = new ArrayList<>();
+ tmp0.add(new Point(annotationData.getLeft(), pageInfo.getHeight() - annotationData.getTop()));
+ tmp0.add(new Point(annotationData.getLeft() + annotationData.getWidth(), pageInfo.getHeight() - annotationData.getTop()));
+ tmp0.add(new Point(annotationData.getLeft(), pageInfo.getHeight() - annotationData.getTop() - annotationData.getHeight()));
+ tmp0.add(new Point(annotationData.getLeft() + annotationData.getWidth(), pageInfo.getHeight() - annotationData.getTop() - annotationData.getHeight()));
+ return tmp0;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/AnnotatorFactory.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/AnnotatorFactory.java
new file mode 100644
index 0000000..43ed974
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/AnnotatorFactory.java
@@ -0,0 +1,59 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+
+public class AnnotatorFactory {
+
+ /**
+ *
+ * Create annotator instance depending on type of annotation
+ *
+ *
+ * @return
+ * @param annotationData AnnotationDataEntity
+ * @param pageInfo PageInfo
+ */
+ public static BaseAnnotator createAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ AnnotationDataEntity roundedAnnotationData = roundCoordinates(annotationData);
+ switch (roundedAnnotationData.getType().toLowerCase()) { // addev .toLowerCase()
+ case "texthighlight": //textHighlight
+ return new TextHighlightAnnotator(roundedAnnotationData, pageInfo);
+ case "area":
+ return new AreaAnnotator(roundedAnnotationData, pageInfo);
+ case "point":
+ return new PointAnnotator(roundedAnnotationData, pageInfo);
+ case "textstrikeout": //textStrikeout
+ return new TextStrikeoutAnnotator(roundedAnnotationData, pageInfo);
+ case "polyline":
+ return new PolylineAnnotator(roundedAnnotationData, pageInfo);
+ case "textfield": //textField
+ return new TextFieldAnnotator(roundedAnnotationData, pageInfo);
+ case "watermark":
+ return new WatermarkAnnotator(roundedAnnotationData, pageInfo);
+ case "textreplacement": //textReplacement
+ return new TextReplacementAnnotator(roundedAnnotationData, pageInfo);
+ case "arrow":
+ return new ArrowAnnotator(roundedAnnotationData, pageInfo);
+ case "textredaction": //textRedaction
+ return new TextRedactionAnnotator(roundedAnnotationData, pageInfo);
+ case "resourcesredaction": //resourcesRedaction
+ return new ResourceRedactionAnnotator(roundedAnnotationData, pageInfo);
+ case "textunderline": //textUnderline
+ return new TextUnderlineAnnotator(roundedAnnotationData, pageInfo);
+ case "distance":
+ return new DistanceAnnotator(roundedAnnotationData, pageInfo);
+ default:
+ throw new TotalGroupDocsException("Wrong annotation data without annotation type!");
+ }
+ }
+
+ private static AnnotationDataEntity roundCoordinates(AnnotationDataEntity annotationData) {
+ annotationData.setHeight((float) Math.round(annotationData.getHeight()));
+ annotationData.setLeft((float) Math.round(annotationData.getLeft()));
+ annotationData.setTop((float) Math.round(annotationData.getTop()));
+ annotationData.setWidth((float) Math.round(annotationData.getWidth()));
+ return annotationData;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/AreaAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/AreaAnnotator.java
new file mode 100644
index 0000000..6edbf8a
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/AreaAnnotator.java
@@ -0,0 +1,55 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+
+public class AreaAnnotator extends BaseAnnotator {
+
+ private AreaAnnotation areaAnnotation;
+
+ public AreaAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ areaAnnotation = new AreaAnnotation();
+ areaAnnotation.setBox(getBox());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ areaAnnotation = (AreaAnnotation) initAnnotationBase(areaAnnotation);
+ return areaAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateWord();
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.AREA;
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/ArrowAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/ArrowAnnotator.java
new file mode 100644
index 0000000..d5b10bc
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/ArrowAnnotator.java
@@ -0,0 +1,90 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.ArrowAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.CommentsEntity;
+
+public class ArrowAnnotator extends BaseAnnotator {
+
+ private boolean withGuid = false;
+ private ArrowAnnotation arrowAnnotation;
+
+ public ArrowAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ this.arrowAnnotation = new ArrowAnnotation();
+ this.arrowAnnotation.setBox(getBox());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ withGuid = false;
+ arrowAnnotation = (ArrowAnnotation) initAnnotationBase(arrowAnnotation);
+ return arrowAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ withGuid = true;
+ arrowAnnotation = (ArrowAnnotation) initAnnotationBase(arrowAnnotation);
+ return arrowAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateWord();
+ }
+
+ @Override
+ protected Reply getAnnotationReplyInfo(CommentsEntity comment) {
+ Reply annotationReplyInfo = super.getAnnotationReplyInfo(comment);
+ if (withGuid) {
+ annotationReplyInfo.setParentReply(new Reply());
+ annotationReplyInfo.getParentReply().setId(annotationData.getId());
+ }
+ return annotationReplyInfo;
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.ARROW;
+ }
+
+ @Override
+ protected Rectangle getBox() {
+ String svgPath = annotationData.getSvgPath();
+
+ String startPoint = svgPath.replace("[a-zA-Z]+", "").split(" ")[0];
+ String endPoint = svgPath.replace("[a-zA-Z]+", "").split(" ")[1];
+
+ String[] start = startPoint.split(",");
+ float startX = Float.parseFloat(start.length > 0 ? start[0].replace("M", "").replace(",", ".") : "0");
+ float startY = Float.parseFloat(start.length > 0 ? start[1].replace("M", "").replace(",", ".") : "0");
+
+ String[] end = endPoint.split(",");
+ float endX = Float.parseFloat(end.length > 0 ? end[0].replace("L", "").replace(",", ".") : "0") - startX;
+ float endY = Float.parseFloat(end.length > 1 ? end[1].replace("L", "").replace(",", ".") : "0") - startY;
+
+ return new Rectangle(startX, startY, endX, endY);
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/BaseAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/BaseAnnotator.java
new file mode 100644
index 0000000..a02ae1b
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/BaseAnnotator.java
@@ -0,0 +1,225 @@
+package com.groupdocs.ui.annotation.annotator;
+
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.User;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.CommentsEntity;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Locale;
+import java.util.TimeZone;
+
+/**
+ *
+ * BaseSigner
+ *
+ */
+public abstract class BaseAnnotator {
+
+ public String Message = "Annotation of type {0} for this file type is not supported";
+ protected AnnotationDataEntity annotationData;
+ protected PageInfo pageInfo;
+
+ /**
+ *
+ * Constructor
+ *
+ *
+ * @param annotationData
+ * @param pageInfo
+ */
+ protected BaseAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ this.annotationData = annotationData;
+ this.pageInfo = pageInfo;
+ }
+
+ /**
+ *
+ * Add area annotation into the Word document
+ *
+ *
+ * @return AnnotationBase
+ */
+ public abstract AnnotationBase annotateWord();
+
+ /**
+ *
+ * Add area annotation into the pdf document
+ *
+ *
+ * @return AnnotationBase
+ */
+ public abstract AnnotationBase annotatePdf();
+
+ /////
+ ///// Add area annotation into the Excel document
+ /////
+ ///// AnnotationBase
+ public abstract AnnotationBase annotateCells();
+
+ /**
+ *
+ * Add area annotation into the Power Point document
+ *
+ *
+ * @return AnnotationBase
+ */
+ public abstract AnnotationBase annotateSlides();
+
+ /**
+ *
+ * Add area annotation into the image document
+ *
+ *
+ * @return AnnotationBase
+ */
+ public abstract AnnotationBase annotateImage();
+
+ /**
+ *
+ * Add area annotation into the document
+ *
+ *
+ * @return AnnotationBase
+ */
+ public abstract AnnotationBase annotateDiagram();
+
+ /**
+ *
+ * Initial for annotation info
+ *
+ *
+ * @param annotationBase
+ * @return AnnotationBase
+ */
+ protected final AnnotationBase initAnnotationBase(AnnotationBase annotationBase) {
+ // set page number to add annotation
+ annotationBase.setPageNumber(annotationData.getPageNumber());//-1
+ // set annotation type
+ annotationBase.setType(getType());
+ annotationBase.setCreatedOn(Date.from(Instant.now()));
+ annotationBase.setId(annotationData.getId());
+ // add replies
+ CommentsEntity[] comments = annotationData.getComments();
+ if (comments != null && comments.length != 0) {
+ java.util.List replies = new ArrayList<>();
+ for (int i = 0; i < comments.length; i++) {
+ Reply reply = getAnnotationReplyInfo(comments[i]);
+ replies.add(reply);
+ }
+ annotationBase.setReplies(replies);
+ }
+ return annotationBase;
+ }
+
+ /**
+ *
+ * Initial for reply annotation info
+ *
+ *
+ * @return AnnotationReplyInfo
+ * @param comment CommentsEntity
+ */
+ protected Reply getAnnotationReplyInfo(CommentsEntity comment) {
+ Reply reply = new Reply();
+ reply.setComment(comment.getText());
+ DateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss");
+ format.setTimeZone(TimeZone.getTimeZone("GMT"));
+ Date date;
+ try {
+ date = new Date(Long.parseLong(comment.getTime()));
+ } catch (Exception e) {
+ try {
+ date = format.parse(comment.getTime());
+ } catch (Exception exc) {
+ format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US);
+ try {
+ date = format.parse(comment.getTime());
+ } catch (ParseException ex) {
+ throw new TotalGroupDocsException(ex);
+ }
+ }
+ }
+ reply.setRepliedOn(date);
+ reply.setUser(new User());
+ reply.getUser().setName(comment.getUserName());
+ return reply;
+ }
+
+ /**
+ *
+ * Get rectangle
+ *
+ *
+ * @return Rectangle
+ */
+ protected Rectangle getBox() {
+ return new Rectangle(annotationData.getLeft(), annotationData.getTop(), annotationData.getWidth(), annotationData.getHeight());
+ }
+
+ /**
+ *
+ * Get type of annotation
+ *
+ *
+ * @return byte
+ */
+ protected abstract int getType();
+
+ /**
+ *
+ * Get Annotation info depending on document type
+ *
+ *
+ * @return AnnotationBase
+ * @param documentType string
+ */
+ public final AnnotationBase getAnnotationBase(String documentType) {
+ switch (documentType) {
+ case "Portable Document Format":
+ return annotatePdf();
+ case "Microsoft Word":
+ case "Open Document Text":
+ return annotateWord();
+ case "Rich Text Format":
+ return annotateWord();
+ case "Microsoft PowerPoint":
+ return annotateSlides();
+ case "image":
+ return annotateImage();
+ case "Microsoft Excel":
+ return annotateCells();
+ case "AutoCAD Drawing File Format":
+ return annotateDiagram();
+ default:
+ throw new TotalGroupDocsException("Wrong annotation data without document type!");
+ }
+ }
+
+ /**
+ *
+ * Check if the current annotatin is supported
+ *
+ *
+ * @return
+ * @param documentType string
+ */
+ public final boolean isSupported(String documentType) {
+ try {
+ AnnotatorFactory.createAnnotator(annotationData, pageInfo).getAnnotationBase(documentType);
+ return true;
+ } catch (java.lang.UnsupportedOperationException e) {
+ Message += annotationData.getType();
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/DistanceAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/DistanceAnnotator.java
new file mode 100644
index 0000000..1efc61b
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/DistanceAnnotator.java
@@ -0,0 +1,92 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.DistanceAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.CommentsEntity;
+
+public class DistanceAnnotator extends BaseAnnotator {
+
+ private DistanceAnnotation distanceAnnotation;
+
+ public DistanceAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ distanceAnnotation = new DistanceAnnotation();
+ distanceAnnotation.setBox(getBox());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ distanceAnnotation = (DistanceAnnotation) initAnnotationBaseDistanceAnnotator(distanceAnnotation);
+ return distanceAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateWord();
+ }
+
+ protected final AnnotationBase initAnnotationBaseDistanceAnnotator(AnnotationBase annotationBase) {
+ distanceAnnotation = (DistanceAnnotation) super.initAnnotationBase(annotationBase);
+ String tmp0 = annotationData.getText();
+ if (tmp0 == null) {
+ tmp0 = "";
+ }
+ // add replies
+ String text = tmp0;
+ CommentsEntity[] comments = annotationData.getComments();
+ if (comments != null && comments.length != 0) {
+ Reply reply = distanceAnnotation.getReplies().get(0);
+ if (reply != null) {
+ reply.setComment(String.format("%s %s", text, reply.getComment()));
+ }
+ }
+
+ return distanceAnnotation;
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.DISTANCE;
+ }
+
+ @Override
+ protected Rectangle getBox() {
+ String svgPath = annotationData.getSvgPath();
+
+ String startPoint = svgPath.replaceAll("[a-zA-Z]+", "").split(" ")[0];
+ String endPoint = svgPath.replaceAll("[a-zA-Z]+", "").split(" ")[1];
+ String[] start = startPoint.split(",");
+ float startX = Float.parseFloat(start.length > 0 ? start[0] : "0");
+ float startY = Float.parseFloat(start.length > 1 ? start[1] : "0");
+ String[] end = endPoint.split(",");
+ float endX = Float.parseFloat(end.length > 0 ? end[0] : "0") - startX;
+ float endY = Float.parseFloat(end.length > 1 ? end[1] : "0") - startY;
+ return new Rectangle(startX, startY, endX, endY);
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/PointAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/PointAnnotator.java
new file mode 100644
index 0000000..82c853f
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/PointAnnotator.java
@@ -0,0 +1,56 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.PointAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+
+
+public class PointAnnotator extends BaseAnnotator {
+
+ private PointAnnotation pointAnnotation;
+
+ public PointAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ pointAnnotation = new PointAnnotation();
+ pointAnnotation.setBox(getBox());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ pointAnnotation = (PointAnnotation) super.initAnnotationBase(pointAnnotation);
+ return pointAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateWord();
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.POINT;
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/PolylineAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/PolylineAnnotator.java
new file mode 100644
index 0000000..a554cb1
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/PolylineAnnotator.java
@@ -0,0 +1,79 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.User;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.PolylineAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.CommentsEntity;
+
+
+public class PolylineAnnotator extends BaseAnnotator {
+
+ private PolylineAnnotation polylineAnnotation;
+
+ public PolylineAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ this.polylineAnnotation = new PolylineAnnotation();
+ this.polylineAnnotation.setBox(getBox());
+ this.polylineAnnotation.setPenColor(1201033);
+ this.polylineAnnotation.setPenWidth((byte) 2);
+ this.polylineAnnotation.setSvgPath(annotationData.getSvgPath());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ polylineAnnotation = (PolylineAnnotation) initAnnotationBase(polylineAnnotation);
+ return polylineAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ polylineAnnotation = (PolylineAnnotation) initAnnotationBase(polylineAnnotation);
+ fillCreatorName(polylineAnnotation, annotationData);
+ return polylineAnnotation;
+ }
+
+ /**
+ *
+ * Fill creator name field in annotation info
+ *
+ *
+ * @param polylineAnnotation AnnotationBase
+ * @param annotationData
+ */
+ protected static void fillCreatorName(AnnotationBase polylineAnnotation, AnnotationDataEntity annotationData) {
+ CommentsEntity[] comments = annotationData.getComments();
+ if (comments != null && comments.length > 0 && comments[0] != null) {
+ polylineAnnotation.setUser(new User());
+ polylineAnnotation.getUser().setName(comments[0].getUserName());
+ }
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateSlides();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateSlides();
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.POLYLINE;
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/ResourceRedactionAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/ResourceRedactionAnnotator.java
new file mode 100644
index 0000000..4d66e9a
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/ResourceRedactionAnnotator.java
@@ -0,0 +1,57 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.ResourcesRedactionAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+
+
+public class ResourceRedactionAnnotator extends BaseAnnotator {
+
+ private ResourcesRedactionAnnotation resourcesRedactionAnnotation;
+
+ public ResourceRedactionAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ this.resourcesRedactionAnnotation = new ResourcesRedactionAnnotation();
+ this.resourcesRedactionAnnotation.setBox(getBox());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ resourcesRedactionAnnotation = (ResourcesRedactionAnnotation) initAnnotationBase(resourcesRedactionAnnotation);
+ return resourcesRedactionAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateWord();
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.RESOURCES_REDACTION;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextFieldAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextFieldAnnotator.java
new file mode 100644
index 0000000..4df87dc
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextFieldAnnotator.java
@@ -0,0 +1,61 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.TextFieldAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+
+
+public class TextFieldAnnotator extends BaseAnnotator {
+
+ private TextFieldAnnotation textFieldAnnotation;
+
+ public TextFieldAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ textFieldAnnotation = new TextFieldAnnotation();
+ textFieldAnnotation.setBox(getBox());
+
+ textFieldAnnotation.setFontFamily(annotationData.getFont() != null || !"".equals(annotationData.getFont()) ? annotationData.getFont() : "Arial");
+ textFieldAnnotation.setFontColor(annotationData.getFontColor());
+ textFieldAnnotation.setFontSize(annotationData.getFontSize() == 0 ? 12 : annotationData.getFontSize());
+ textFieldAnnotation.setText(annotationData.getText());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ textFieldAnnotation = (TextFieldAnnotation) initAnnotationBase(textFieldAnnotation);
+ return textFieldAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ return annotateWord();
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.TEXT_FIELD;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextHighlightAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextHighlightAnnotator.java
new file mode 100644
index 0000000..799716a
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextHighlightAnnotator.java
@@ -0,0 +1,57 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.HighlightAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+
+
+public class TextHighlightAnnotator extends AbstractTextAnnotator {
+
+ private HighlightAnnotation highlightAnnotation;
+
+ public TextHighlightAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ highlightAnnotation = new HighlightAnnotation();
+ highlightAnnotation.setPoints(getPoints(annotationData, pageInfo));
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ highlightAnnotation = (HighlightAnnotation) initAnnotationBase(highlightAnnotation);
+ return highlightAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.TEXT_HIGHLIGHT;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextRedactionAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextRedactionAnnotator.java
new file mode 100644
index 0000000..2d21db5
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextRedactionAnnotator.java
@@ -0,0 +1,56 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.TextRedactionAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+
+public class TextRedactionAnnotator extends TextHighlightAnnotator {
+
+ private TextRedactionAnnotation textRedactionAnnotation;
+
+ public TextRedactionAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ textRedactionAnnotation = new TextRedactionAnnotation();
+ textRedactionAnnotation.setPoints(getPoints(annotationData, pageInfo));
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotatePdf();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotatePdf();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ textRedactionAnnotation = (TextRedactionAnnotation) initAnnotationBase(textRedactionAnnotation);
+ return textRedactionAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ return annotatePdf();
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.TEXT_REDACTION;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextReplacementAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextReplacementAnnotator.java
new file mode 100644
index 0000000..1b81cc5
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextReplacementAnnotator.java
@@ -0,0 +1,58 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.ReplacementAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+
+
+public class TextReplacementAnnotator extends AbstractTextAnnotator {
+
+ private ReplacementAnnotation replacementAnnotation;
+
+ public TextReplacementAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ replacementAnnotation = new ReplacementAnnotation();
+ replacementAnnotation.setPoints(getPoints(annotationData, pageInfo));
+ replacementAnnotation.setTextToReplace(annotationData.getText());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ replacementAnnotation = (ReplacementAnnotation) initAnnotationBase(replacementAnnotation);
+ return replacementAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.TEXT_REPLACEMENT;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextStrikeoutAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextStrikeoutAnnotator.java
new file mode 100644
index 0000000..c8ed96c
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextStrikeoutAnnotator.java
@@ -0,0 +1,58 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.StrikeoutAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+
+public class TextStrikeoutAnnotator extends AbstractTextAnnotator {
+
+ private StrikeoutAnnotation strikeoutAnnotation;
+
+ public TextStrikeoutAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ strikeoutAnnotation = new StrikeoutAnnotation();
+ strikeoutAnnotation.setPoints(getPoints(annotationData, pageInfo));
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ strikeoutAnnotation = (StrikeoutAnnotation) initAnnotationBase(strikeoutAnnotation);
+ return strikeoutAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ strikeoutAnnotation = (StrikeoutAnnotation) initAnnotationBase(strikeoutAnnotation);
+ this.strikeoutAnnotation.setFontColor(0);
+ return strikeoutAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.TEXT_STRIKEOUT;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextUnderlineAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextUnderlineAnnotator.java
new file mode 100644
index 0000000..e3c2b31
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/TextUnderlineAnnotator.java
@@ -0,0 +1,60 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.UnderlineAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+
+
+public class TextUnderlineAnnotator extends AbstractTextAnnotator {
+
+ private UnderlineAnnotation underlineAnnotation;
+
+ public TextUnderlineAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ underlineAnnotation = new UnderlineAnnotation();
+ underlineAnnotation.setPoints(getPoints(annotationData, pageInfo));
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ underlineAnnotation = (UnderlineAnnotation) initAnnotationBase(underlineAnnotation);
+ underlineAnnotation.setFontColor(1201033);
+ return underlineAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ underlineAnnotation = (UnderlineAnnotation) initAnnotationBase(underlineAnnotation);
+ underlineAnnotation.setFontColor(0);
+ return underlineAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.TEXT_UNDERLINE;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/WatermarkAnnotator.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/WatermarkAnnotator.java
new file mode 100644
index 0000000..927d18a
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/annotator/WatermarkAnnotator.java
@@ -0,0 +1,60 @@
+package com.groupdocs.ui.annotation.annotator;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.WatermarkAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+
+public class WatermarkAnnotator extends BaseAnnotator {
+
+ private WatermarkAnnotation watermarkAnnotation;
+
+ public WatermarkAnnotator(AnnotationDataEntity annotationData, PageInfo pageInfo) {
+ super(annotationData, pageInfo);
+
+ watermarkAnnotation = new WatermarkAnnotation();
+ watermarkAnnotation.setBox(getBox());
+ watermarkAnnotation.setFontFamily(annotationData.getFont() != null || !"".equals(annotationData.getFont()) ? annotationData.getFont() : "Arial");
+ watermarkAnnotation.setFontColor(annotationData.getFontColor());
+ watermarkAnnotation.setFontSize(annotationData.getFontSize() == 0 ? 12 : annotationData.getFontSize());
+ watermarkAnnotation.setText(annotationData.getText());
+ }
+
+ @Override
+ public AnnotationBase annotateWord() {
+ watermarkAnnotation = (WatermarkAnnotation) initAnnotationBase(watermarkAnnotation);
+ return watermarkAnnotation;
+ }
+
+ @Override
+ public AnnotationBase annotatePdf() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateCells() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateSlides() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateImage() {
+ return annotateWord();
+ }
+
+ @Override
+ public AnnotationBase annotateDiagram() {
+ throw new TotalGroupDocsException(Message + annotationData.getType());
+ }
+
+ @Override
+ protected int getType() {
+ return AnnotationType.WATERMARK;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfiguration.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfiguration.java
new file mode 100644
index 0000000..73612cd
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/config/AnnotationConfiguration.java
@@ -0,0 +1,282 @@
+package com.groupdocs.ui.annotation.config;
+
+import com.groupdocs.ui.config.CommonConfiguration;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+import javax.annotation.PostConstruct;
+import static com.groupdocs.ui.config.DefaultDirectories.defaultAnnotationDirectory;
+import static com.groupdocs.ui.config.DefaultDirectories.relativePathToAbsolute;
+
+/**
+ *
+ * AnnotationConfiguration
+ *
+ */
+@Component
+public class AnnotationConfiguration extends CommonConfiguration {
+
+ @Value("${annotation.filesDirectory}")
+ private String filesDirectory;
+
+ @Value("${annotation.defaultDocument}")
+ private String defaultDocument;
+
+ @Value("#{new Integer('${annotation.preloadPageCount}')}")
+ private int preloadPageCount;
+
+ @Value("${annotation.fontsDirectory}")
+ private String fontsDirectory;
+
+ @Value("#{new Boolean('${annotation.textAnnotation}')}")
+ private boolean textAnnotation;
+
+ @Value("#{new Boolean('${annotation.areaAnnotation}')}")
+ private boolean areaAnnotation;
+
+ @Value("#{new Boolean('${annotation.pointAnnotation}')}")
+ private boolean pointAnnotation;
+
+ @Value("#{new Boolean('${annotation.textStrikeoutAnnotation}')}")
+ private boolean textStrikeoutAnnotation;
+
+ @Value("#{new Boolean('${annotation.polylineAnnotation}')}")
+ private boolean polylineAnnotation;
+
+ @Value("#{new Boolean('${annotation.textFieldAnnotation}')}")
+ private boolean textFieldAnnotation;
+
+ @Value("#{new Boolean('${annotation.watermarkAnnotation}')}")
+ private boolean watermarkAnnotation;
+
+ @Value("#{new Boolean('${annotation.textReplacementAnnotation}')}")
+ private boolean textReplacementAnnotation;
+
+ @Value("#{new Boolean('${annotation.arrowAnnotation}')}")
+ private boolean arrowAnnotation;
+
+ @Value("#{new Boolean('${annotation.textRedactionAnnotation}')}")
+ private boolean textRedactionAnnotation;
+
+ @Value("#{new Boolean('${annotation.resourcesRedactionAnnotation}')}")
+ private boolean resourcesRedactionAnnotation;
+
+ @Value("#{new Boolean('${annotation.textUnderlineAnnotation}')}")
+ private boolean textUnderlineAnnotation;
+
+ @Value("#{new Boolean('${annotation.distanceAnnotation}')}")
+ private boolean distanceAnnotation;
+
+ @Value("#{new Boolean('${annotation.downloadOriginal}')}")
+ private boolean downloadOriginal;
+
+ @Value("#{new Boolean('${annotation.downloadAnnotated}')}")
+ private boolean downloadAnnotated;
+
+ @Value("#{new Boolean('${annotation.zoom}')}")
+ private boolean zoom;
+
+ @Value("#{new Boolean('${annotation.fitWidth}')}")
+ private boolean fitWidth;
+
+ @PostConstruct
+ public void init() {
+ this.filesDirectory = StringUtils.isEmpty(this.filesDirectory) ? defaultAnnotationDirectory() : relativePathToAbsolute(this.filesDirectory);
+ }
+
+ public String getFilesDirectory() {
+ return filesDirectory;
+ }
+
+ public void setFilesDirectory(String filesDirectory) {
+ this.filesDirectory = filesDirectory;
+ }
+
+ public String getDefaultDocument() {
+ return defaultDocument;
+ }
+
+ public void setDefaultDocument(String defaultDocument) {
+ this.defaultDocument = defaultDocument;
+ }
+
+ public int getPreloadPageCount() {
+ return preloadPageCount;
+ }
+
+ public void setPreloadPageCount(int preloadPageCount) {
+ this.preloadPageCount = preloadPageCount;
+ }
+
+ public String getFontsDirectory() {
+ return fontsDirectory;
+ }
+
+ public void setFontsDirectory(String fontsDirectory) {
+ this.fontsDirectory = fontsDirectory;
+ }
+
+ public boolean getTextAnnotation() {
+ return textAnnotation;
+ }
+
+ public void setTextAnnotation(boolean textAnnotation) {
+ this.textAnnotation = textAnnotation;
+ }
+
+ public boolean getAreaAnnotation() {
+ return areaAnnotation;
+ }
+
+ public void setAreaAnnotation(boolean areaAnnotation) {
+ this.areaAnnotation = areaAnnotation;
+ }
+
+ public boolean getPointAnnotation() {
+ return pointAnnotation;
+ }
+
+ public void setPointAnnotation(boolean pointAnnotation) {
+ this.pointAnnotation = pointAnnotation;
+ }
+
+ public boolean getTextStrikeoutAnnotation() {
+ return textStrikeoutAnnotation;
+ }
+
+ public void setTextStrikeoutAnnotation(boolean textStrikeoutAnnotation) {
+ this.textStrikeoutAnnotation = textStrikeoutAnnotation;
+ }
+
+ public boolean getPolylineAnnotation() {
+ return polylineAnnotation;
+ }
+
+ public void setPolylineAnnotation(boolean polylineAnnotation) {
+ this.polylineAnnotation = polylineAnnotation;
+ }
+
+ public boolean getTextFieldAnnotation() {
+ return textFieldAnnotation;
+ }
+
+ public void setTextFieldAnnotation(boolean textFieldAnnotation) {
+ this.textFieldAnnotation = textFieldAnnotation;
+ }
+
+ public boolean getWatermarkAnnotation() {
+ return watermarkAnnotation;
+ }
+
+ public void setWatermarkAnnotation(boolean watermarkAnnotation) {
+ this.watermarkAnnotation = watermarkAnnotation;
+ }
+
+ public boolean getTextReplacementAnnotation() {
+ return textReplacementAnnotation;
+ }
+
+ public void setTextReplacementAnnotation(boolean textReplacementAnnotation) {
+ this.textReplacementAnnotation = textReplacementAnnotation;
+ }
+
+ public boolean getArrowAnnotation() {
+ return arrowAnnotation;
+ }
+
+ public void setArrowAnnotation(boolean arrowAnnotation) {
+ this.arrowAnnotation = arrowAnnotation;
+ }
+
+ public boolean getTextRedactionAnnotation() {
+ return textRedactionAnnotation;
+ }
+
+ public void setTextRedactionAnnotation(boolean textRedactionAnnotation) {
+ this.textRedactionAnnotation = textRedactionAnnotation;
+ }
+
+ public boolean getResourcesRedactionAnnotation() {
+ return resourcesRedactionAnnotation;
+ }
+
+ public void setResourcesRedactionAnnotation(boolean resourcesRedactionAnnotation) {
+ this.resourcesRedactionAnnotation = resourcesRedactionAnnotation;
+ }
+
+ public boolean getTextUnderlineAnnotation() {
+ return textUnderlineAnnotation;
+ }
+
+ public void setTextUnderlineAnnotation(boolean textUnderlineAnnotation) {
+ this.textUnderlineAnnotation = textUnderlineAnnotation;
+ }
+
+ public boolean getDistanceAnnotation() {
+ return distanceAnnotation;
+ }
+
+ public void setDistanceAnnotation(boolean distanceAnnotation) {
+ this.distanceAnnotation = distanceAnnotation;
+ }
+
+ public boolean getDownloadOriginal() {
+ return downloadOriginal;
+ }
+
+ public void setDownloadOriginal(boolean downloadOriginal) {
+ this.downloadOriginal = downloadOriginal;
+ }
+
+ public boolean getDownloadAnnotated() {
+ return downloadAnnotated;
+ }
+
+ public void setDownloadAnnotated(boolean downloadAnnotated) {
+ this.downloadAnnotated = downloadAnnotated;
+ }
+
+ public boolean getZoom() {
+ return zoom;
+ }
+
+ public void setZoom(boolean zoom) {
+ this.zoom = zoom;
+ }
+
+ public boolean getFitWidth() {
+ return fitWidth;
+ }
+
+ public void setFitWidth(boolean fitWidth) {
+ this.fitWidth = fitWidth;
+ }
+
+ @Override
+ public String toString() {
+ return super.toString()
+ + "AnnotationConfiguration{"
+ + "filesDirectory='" + filesDirectory + '\''
+ + ", defaultDocument='" + defaultDocument + '\''
+ + ", preloadPageCount=" + preloadPageCount
+ + ", fontsDirectory='" + fontsDirectory + '\''
+ + ", textAnnotation=" + textAnnotation
+ + ", areaAnnotation=" + areaAnnotation
+ + ", pointAnnotation=" + pointAnnotation
+ + ", textStrikeoutAnnotation=" + textStrikeoutAnnotation
+ + ", polylineAnnotation=" + polylineAnnotation
+ + ", textFieldAnnotation=" + textFieldAnnotation
+ + ", watermarkAnnotation=" + watermarkAnnotation
+ + ", textReplacementAnnotation=" + textReplacementAnnotation
+ + ", arrowAnnotation=" + arrowAnnotation
+ + ", textRedactionAnnotation=" + textRedactionAnnotation
+ + ", resourcesRedactionAnnotation=" + resourcesRedactionAnnotation
+ + ", textUnderlineAnnotation=" + textUnderlineAnnotation
+ + ", distanceAnnotation=" + distanceAnnotation
+ + ", downloadOriginal=" + downloadOriginal
+ + ", downloadAnnotated=" + downloadAnnotated
+ + ", zoom=" + zoom
+ + ", fitWidth=" + fitWidth
+ + '}';
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/controller/AnnotationController.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/controller/AnnotationController.java
new file mode 100644
index 0000000..5ec5e73
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/controller/AnnotationController.java
@@ -0,0 +1,176 @@
+package com.groupdocs.ui.annotation.controller;
+
+import com.groupdocs.ui.annotation.config.AnnotationConfiguration;
+import com.groupdocs.ui.annotation.entity.web.AnnotatedDocumentEntity;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.AnnotationPostedDataEntity;
+import com.groupdocs.ui.annotation.entity.web.PageDataDescriptionEntity;
+import com.groupdocs.ui.annotation.service.AnnotationService;
+import com.groupdocs.ui.config.GlobalConfiguration;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+import com.groupdocs.ui.model.request.FileTreeRequest;
+import com.groupdocs.ui.model.request.LoadDocumentPageRequest;
+import com.groupdocs.ui.model.request.LoadDocumentRequest;
+import com.groupdocs.ui.model.response.FileDescriptionEntity;
+import com.groupdocs.ui.model.response.UploadedDocumentEntity;
+import com.groupdocs.ui.util.Utils;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import javax.annotation.Nullable;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+import static com.groupdocs.ui.util.Utils.setLocalPort;
+import static com.groupdocs.ui.util.Utils.uploadFile;
+import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
+import static org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE;
+
+/**
+ * AnnotationController
+ *
+ * @author Aspose Pty Ltd
+ */
+@Controller
+@RequestMapping(value = "/annotation")
+public class AnnotationController {
+
+ private static final Logger logger = LoggerFactory.getLogger(AnnotationController.class);
+
+ @Autowired
+ private AnnotationService annotationService;
+
+ /**
+ * Get annotation page
+ *
+ * @param request
+ * @param model model data for template
+ * @return template name
+ */
+ @RequestMapping(method = RequestMethod.GET)
+ public String getView(HttpServletRequest request, Map model) {
+ GlobalConfiguration globalConfiguration = annotationService.getGlobalConfiguration();
+
+ setLocalPort(request, globalConfiguration.getServer());
+
+ model.put("globalConfiguration", globalConfiguration);
+
+ AnnotationConfiguration annotationConfiguration = annotationService.getAnnotationConfiguration();
+ logger.debug("annotation config: {}", annotationConfiguration);
+ model.put("annotationConfiguration", annotationConfiguration);
+ return "annotation";
+ }
+
+ @RequestMapping(method = RequestMethod.GET, value = "/loadConfig", produces = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public AnnotationConfiguration loadConfig() {
+ return annotationService.getAnnotationConfiguration();
+ }
+
+ /**
+ * Get files and directories
+ *
+ * @param fileTreeRequest request's object with specified path
+ * @return files and directories list
+ */
+ @RequestMapping(value = "/loadFileTree", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public List loadFileTree(@RequestBody FileTreeRequest fileTreeRequest) {
+ return annotationService.getFileList(fileTreeRequest);
+ }
+
+ /**
+ * Get document description
+ *
+ * @param loadDocumentRequest
+ * @return document description
+ */
+ @RequestMapping(value = "/loadDocumentDescription", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public AnnotatedDocumentEntity loadDocumentDescription(@RequestBody LoadDocumentRequest loadDocumentRequest) {
+ return annotationService.getDocumentDescription(loadDocumentRequest);
+ }
+
+ /**
+ * Get document page
+ *
+ * @param loadDocumentPageRequest
+ * @return document page
+ */
+ @RequestMapping(value = "/loadDocumentPage", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public PageDataDescriptionEntity loadDocumentPage(@RequestBody LoadDocumentPageRequest loadDocumentPageRequest) {
+ return annotationService.getDocumentPage(loadDocumentPageRequest);
+ }
+
+ /**
+ * Download document
+ *
+ * @param documentGuid path to document parameter
+ * @param response http response
+ */
+ @RequestMapping(value = {"/downloadDocument", "/downloadAnnotated"}, method = RequestMethod.GET)
+ public void downloadDocument(@RequestParam("path") String documentGuid, HttpServletResponse response) {
+ // get document path
+ String fileName = FilenameUtils.getName(documentGuid);
+
+ // set response content info
+ Utils.addFileDownloadHeaders(response, fileName, null);
+
+ long length;
+ try (InputStream inputStream = new BufferedInputStream(new FileInputStream(documentGuid));
+ ServletOutputStream outputStream = response.getOutputStream()) {
+ // download the document
+ length = IOUtils.copyLarge(inputStream, outputStream);
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+
+ Utils.addFileDownloadLengthHeader(response, length);
+ }
+
+ /**
+ * Upload document
+ *
+ * @param content file data
+ * @param url url for document
+ * @param rewrite flag for rewriting file
+ * @return uploaded document object (the object contains uploaded document guid)
+ */
+ @RequestMapping(value = "/uploadDocument", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE, consumes = MULTIPART_FORM_DATA_VALUE)
+ @ResponseBody
+ public UploadedDocumentEntity uploadDocument(@Nullable @RequestParam("file") MultipartFile content,
+ @RequestParam(value = "url", required = false) String url,
+ @RequestParam("rewrite") Boolean rewrite) {
+ // get documents storage path
+ String documentStoragePath = annotationService.getAnnotationConfiguration().getFilesDirectory();
+ // save the file
+ String pathname = uploadFile(documentStoragePath, content, url, rewrite);
+ // create response data
+ UploadedDocumentEntity uploadedDocument = new UploadedDocumentEntity();
+ uploadedDocument.setGuid(pathname);
+ return uploadedDocument;
+ }
+
+ /**
+ * Annotate document
+ *
+ * @param annotateDocumentRequest
+ * @return annotated document info
+ */
+ @RequestMapping(value = "/annotate", method = RequestMethod.POST, produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public AnnotatedDocumentEntity annotate(@RequestBody AnnotationPostedDataEntity annotateDocumentRequest) {
+ return annotationService.annotate(annotateDocumentRequest);
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/Annotations.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/Annotations.java
new file mode 100644
index 0000000..0fe8b6e
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/Annotations.java
@@ -0,0 +1,75 @@
+package com.groupdocs.ui.annotation.entity;
+
+public class Annotations {
+
+ public String[] Cells = {
+ "textHighlight"
+ };
+ public String[] Diagram = {
+ "area",
+ "point",
+ "polyline",
+ "textField",
+ "arrow",
+ "textRedaction",
+ "resourcesRedaction",
+ "distance"
+ };
+ public String[] Word = {
+ "area",
+ "point",
+ "textStrikeout",
+ "polyline",
+ "textField",
+ "watermark",
+ "textReplacement",
+ "arrow",
+ "textRedaction",
+ "resourcesRedaction",
+ "textUnderline",
+ "distance",
+ "textHighlight"
+ };
+ public String[] Pdf = {
+ "area",
+ "point",
+ "textStrikeout",
+ "polyline",
+ "textField",
+ "watermark",
+ "textReplacement",
+ "arrow",
+ "textRedaction",
+ "resourcesRedaction",
+ "textUnderline",
+ "distance",
+ "textHighlight"
+ };
+ public String[] Image = {
+ "area",
+ "point",
+ "textStrikeout",
+ "polyline",
+ "textField",
+ "watermark",
+ "arrow",
+ "textRedaction",
+ "resourcesRedaction",
+ "textUnderline",
+ "distance",
+ "textHighlight"
+ };
+ public String[] Slides = {
+ "area",
+ "point",
+ "textStrikeout",
+ "polyline",
+ "textField",
+ "watermark",
+ "arrow",
+ "textRedaction",
+ "resourcesRedaction",
+ "textUnderline",
+ "textHighlight"
+ };
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/request/PostedDataEntity.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/request/PostedDataEntity.java
new file mode 100644
index 0000000..fc5703c
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/request/PostedDataEntity.java
@@ -0,0 +1,180 @@
+package com.groupdocs.ui.annotation.entity.request;
+
+import java.util.List;
+
+/**
+ *
+ * DTO-class, representes document with its pages posted from the front-end.
+ *
+ */
+public class PostedDataEntity {
+
+ /**
+ *
+ * Absolute path to the posted document.
+ *
+ * @return
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ *
+ * Absolute path to the posted document.
+ *
+ * @param value
+ */
+ public void setPath(String value) {
+ path = value;
+ }
+ private String path;
+
+ /**
+ *
+ * Absolute path to the document.
+ *
+ * @return
+ */
+ public String getGuid() {
+ return guid;
+ }
+
+ /**
+ *
+ * Absolute path to the document.
+ *
+ * @param value
+ */
+ public void setGuid(String value) {
+ guid = value;
+ }
+ private String guid;
+
+ /**
+ *
+ * Document password.
+ *
+ * @return
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ /**
+ *
+ * Document password.
+ *
+ * @param value
+ */
+ public void setPassword(String value) {
+ password = value;
+ }
+ private String password;
+
+ /**
+ *
+ * Url of the posted file.
+ *
+ * @return
+ */
+ public String getUrl() {
+ return url;
+ }
+
+ /**
+ *
+ * Url of the posted file.
+ *
+ * @param value
+ */
+ public void setUrl(String value) {
+ url = value;
+ }
+ private String url;
+
+ /**
+ *
+ * Page number.
+ *
+ * @return
+ */
+ public int getPage() {
+ return page;
+ }
+
+ /**
+ *
+ * Page number.
+ *
+ * @param value
+ */
+ public void setPage(int value) {
+ page = value;
+ }
+ private int page;
+
+ /**
+ *
+ * Page rotation angle.
+ *
+ * @return
+ */
+ public int getAngle() {
+ return angle;
+ }
+
+ /**
+ *
+ * Page rotation angle.
+ *
+ * @param value
+ */
+ public void setAngle(int value) {
+ angle = value;
+ }
+ private int angle;
+
+ /**
+ *
+ * Collection of the document pages with their data.
+ *
+ * @return
+ */
+ public List getPages() {
+ return pages;
+ }
+
+ /**
+ *
+ * Collection of the document pages with their data.
+ *
+ * @param value
+ */
+ public void setPages(List value) {
+ pages = value;
+ }
+
+ private List pages;
+
+ /**
+ *
+ * Flag indicating whether the file should be overwritten.
+ *
+ * @return
+ */
+ public boolean getRewrite() {
+ return rewrite;
+ }
+
+ /**
+ *
+ * Flag indicating whether the file should be overwritten.
+ *
+ * @param value
+ */
+ public void setRewrite(boolean value) {
+ rewrite = value;
+ }
+ private boolean rewrite;
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/request/TextCoordinatesRequest.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/request/TextCoordinatesRequest.java
new file mode 100644
index 0000000..47122b0
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/request/TextCoordinatesRequest.java
@@ -0,0 +1,31 @@
+package com.groupdocs.ui.annotation.entity.request;
+
+public class TextCoordinatesRequest extends PostedDataEntity {
+
+ public final String getGuid_Rename_Namesake() {
+ return guid;
+ }
+
+ public final void setQuid_Rename_Namesake(String value) {
+ guid = value;
+ }
+ private String guid;
+
+ public final String getPassword_Rename_Namesake() {
+ return password;
+ }
+
+ public final void setPassword_Rename_Namesake(String value) {
+ password = value;
+ }
+ private String password;
+
+ public final int getPageNumber() {
+ return pageNumber;
+ }
+
+ public final void setPageNumber(int value) {
+ pageNumber = value;
+ }
+ private int pageNumber;
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotatedDocumentEntity.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotatedDocumentEntity.java
new file mode 100644
index 0000000..8877196
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotatedDocumentEntity.java
@@ -0,0 +1,45 @@
+package com.groupdocs.ui.annotation.entity.web;
+
+import com.groupdocs.ui.model.response.PageDescriptionEntity;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AnnotatedDocumentEntity extends PageDescriptionEntity {
+
+ /**
+ * Document Guid
+ */
+ private String guid;
+ /**
+ * List of supported types of annotations
+ */
+ public String[] supportedAnnotations;
+ /**
+ * list of pages
+ */
+ private List pages = new ArrayList<>();
+
+ public String getGuid() {
+ return guid;
+ }
+
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ public String[] getSupportedAnnotations() {
+ return supportedAnnotations;
+ }
+
+ public void setSupportedAnnotations(String[] supportedAnnotations) {
+ this.supportedAnnotations = supportedAnnotations;
+ }
+
+ public List getPages() {
+ return pages;
+ }
+
+ public void setPages(List pages) {
+ this.pages = pages;
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotationDataEntity.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotationDataEntity.java
new file mode 100644
index 0000000..8a51dd4
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotationDataEntity.java
@@ -0,0 +1,139 @@
+package com.groupdocs.ui.annotation.entity.web;
+
+public class AnnotationDataEntity {
+
+ public final int getId() {
+ return id;
+ }
+
+ public final void setId(int value) {
+ id = value;
+ }
+ private int id;
+
+ public final int getPageNumber() {
+ return pageNumber;
+ }
+
+ public final void setPageNumber(int value) {
+ pageNumber = value;
+ }
+ private int pageNumber;
+
+ public final int getFontColor() {
+ return fontColor;
+ }
+
+ public final void setFontColor(int value) {
+ fontColor = value;
+ }
+ private int fontColor;
+
+ public final Double getFontSize() {
+ return fontSize;
+ }
+
+ public final void setFontSize(Double value) {
+ fontSize = value;
+ }
+ private Double fontSize;
+
+ public final float getLeft() {
+ return left;
+ }
+
+ public final void setLeft(float value) {
+ left = value;
+ }
+ private float left;
+
+ public final float getTop() {
+ return top;
+ }
+
+ public final void setTop(float value) {
+ top = value;
+ }
+ private float top;
+
+ public final float getWidth() {
+ return width;
+ }
+
+ public final void setWidth(float value) {
+ width = value;
+ }
+ private float width;
+
+ public final float getHeight() {
+ return height;
+ }
+
+ public final void setHeight(float value) {
+ height = value;
+ }
+ private float height;
+
+ public final String getSvgPath() {
+ return svgPath;
+ }
+
+ public final void setSvgPath(String value) {
+ svgPath = value;
+ }
+ private String svgPath;
+
+ public final String getType() {
+ return type;
+ }
+
+ public final void setType(String value) {
+ type = value;
+ }
+ private String type;
+
+ public final String getDocumentType() {
+ return documentType;
+ }
+
+ public final void setDocumentType(String value) {
+ documentType = value;
+ }
+ private String documentType;
+
+ public final String getText() {
+ return text;
+ }
+
+ public final void setText(String value) {
+ text = value;
+ }
+ private String text;
+
+ public final String getFont() {
+ return font;
+ }
+
+ public final void setFont(String value) {
+ font = value;
+ }
+ private String font;
+
+ public final boolean getImported() {
+ return imported;
+ }
+
+ public final void setImported(boolean value) {
+ imported = value;
+ }
+ private boolean imported;
+
+ public final CommentsEntity[] getComments() {
+ return comments;
+ }
+
+ public final void setComments(CommentsEntity[] value) {
+ comments = value;
+ }
+ private CommentsEntity[] comments;
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotationPostedDataEntity.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotationPostedDataEntity.java
new file mode 100644
index 0000000..cb53d67
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/AnnotationPostedDataEntity.java
@@ -0,0 +1,39 @@
+package com.groupdocs.ui.annotation.entity.web;
+
+import com.groupdocs.ui.annotation.entity.request.PostedDataEntity;
+
+
+/**
+ *
+ * SignaturePostedDataEntity
+ *
+ */
+public class AnnotationPostedDataEntity extends PostedDataEntity {
+
+ public final String getDocumentType() {
+ return documentType;
+ }
+
+ public final void setDocumentType(String value) {
+ documentType = value;
+ }
+ private String documentType;
+
+ public final AnnotationDataEntity[] getAnnotationsData() {
+ return annotationsData;
+ }
+
+ public final void setAnnotationsData(AnnotationDataEntity[] value) {
+ annotationsData = value;
+ }
+ private AnnotationDataEntity[] annotationsData;
+
+ public final boolean getPrint() {
+ return print;
+ }
+
+ public final void setPrint(boolean value) {
+ print = value;
+ }
+ private boolean print;
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/CommentsEntity.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/CommentsEntity.java
new file mode 100644
index 0000000..68d39b2
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/CommentsEntity.java
@@ -0,0 +1,31 @@
+package com.groupdocs.ui.annotation.entity.web;
+
+public class CommentsEntity {
+
+ public final String getTime() {
+ return time;
+ }
+
+ public final void setTime(String value) {
+ time = value;
+ }
+ private String time;
+
+ public final String getText() {
+ return text;
+ }
+
+ public final void setText(String value) {
+ text = value;
+ }
+ private String text;
+
+ public final String getUserName() {
+ return userName;
+ }
+
+ public final void setUserName(String value) {
+ userName = value;
+ }
+ private String userName;
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/PageDataDescriptionEntity.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/PageDataDescriptionEntity.java
new file mode 100644
index 0000000..a975af8
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/PageDataDescriptionEntity.java
@@ -0,0 +1,19 @@
+package com.groupdocs.ui.annotation.entity.web;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.groupdocs.ui.model.response.PageDescriptionEntity;
+import java.util.List;
+
+public class PageDataDescriptionEntity extends PageDescriptionEntity {
+
+ @JsonProperty
+ private List annotations; // AnnotationDataEntity[] => List
+
+ public final void setAnnotations(List annotations) {
+ this.annotations = annotations;
+ }
+
+ public final List getAnnotations() {
+ return annotations;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/TextRowEntity.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/TextRowEntity.java
new file mode 100644
index 0000000..746dff7
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/entity/web/TextRowEntity.java
@@ -0,0 +1,33 @@
+package com.groupdocs.ui.annotation.entity.web;
+
+import java.util.List;
+
+public class TextRowEntity {
+
+ public final List getTextCoordinates() {
+ return textCoordinates;
+ }
+
+ public final void setTextCoordinates(List value) {
+ textCoordinates = value;
+ }
+ private List textCoordinates;
+
+ public final double getLineTop() {
+ return lineTop;
+ }
+
+ public final void setLineTop(double value) {
+ lineTop = value;
+ }
+ private double lineTop;
+
+ public final double getLineHeight() {
+ return lineHeight;
+ }
+
+ public final void setLineHeight(double value) {
+ lineHeight = value;
+ }
+ private double lineHeight;
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/service/AnnotationService.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/service/AnnotationService.java
new file mode 100644
index 0000000..7c7e5cf
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/service/AnnotationService.java
@@ -0,0 +1,72 @@
+package com.groupdocs.ui.annotation.service;
+
+import com.groupdocs.ui.annotation.config.AnnotationConfiguration;
+import com.groupdocs.ui.annotation.entity.web.AnnotatedDocumentEntity;
+import com.groupdocs.ui.annotation.entity.web.AnnotationPostedDataEntity;
+import com.groupdocs.ui.annotation.entity.web.PageDataDescriptionEntity;
+import com.groupdocs.ui.config.GlobalConfiguration;
+import com.groupdocs.ui.model.request.FileTreeRequest;
+import com.groupdocs.ui.model.request.LoadDocumentPageRequest;
+import com.groupdocs.ui.model.request.LoadDocumentRequest;
+import com.groupdocs.ui.model.response.FileDescriptionEntity;
+import java.io.InputStream;
+import java.util.List;
+
+/**
+ * Service for annotating documents
+ */
+public interface AnnotationService {
+ /**
+ * Get global configuration
+ *
+ * @return global configuration
+ */
+ GlobalConfiguration getGlobalConfiguration();
+
+ /**
+ * Get annotation configuration
+ *
+ * @return annotation configuration
+ */
+ AnnotationConfiguration getAnnotationConfiguration();
+
+ /**
+ * Get list of files and folders
+ *
+ * @param fileTreeRequest request object with path for loading list of files
+ * @return list of files and folders
+ */
+ List getFileList(FileTreeRequest fileTreeRequest);
+
+ /**
+ * Get document information
+ *
+ * @param loadDocumentRequest request object with document guid
+ * @return document with list of pages
+ */
+ AnnotatedDocumentEntity getDocumentDescription(LoadDocumentRequest loadDocumentRequest);
+
+ /**
+ * Load document page
+ *
+ * @param loadDocumentPageRequest request object with document guid and page number
+ * @return document page data
+ */
+ PageDataDescriptionEntity getDocumentPage(LoadDocumentPageRequest loadDocumentPageRequest);
+
+ /**
+ * Annotate document
+ *
+ * @param annotateDocumentRequest request object with document guid and annotations data
+ * @return annotated document
+ */
+ AnnotatedDocumentEntity annotate(AnnotationPostedDataEntity annotateDocumentRequest);
+
+ /**
+ * Annotate document by streams
+ *
+ * @param annotateDocumentRequest request object with document guid and annotations data
+ * @return stream of annotated document
+ */
+ InputStream annotateByStream(AnnotationPostedDataEntity annotateDocumentRequest);
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/service/AnnotationServiceImpl.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/service/AnnotationServiceImpl.java
new file mode 100644
index 0000000..5bb8d64
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/service/AnnotationServiceImpl.java
@@ -0,0 +1,539 @@
+package com.groupdocs.ui.annotation.service;
+
+import com.groupdocs.annotation.licenses.License;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.IDocumentInfo;
+import com.groupdocs.annotation.exceptions.AnnotatorException;
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.options.LoadOptions;
+import com.groupdocs.annotation.options.pagepreview.PreviewFormats;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.annotation.options.export.SaveOptions;
+import com.groupdocs.annotation.options.pagepreview.CreatePageStream;
+import com.groupdocs.annotation.options.pagepreview.PreviewOptions;
+import com.groupdocs.ui.annotation.annotator.AnnotatorFactory;
+import com.groupdocs.ui.annotation.annotator.BaseAnnotator;
+import com.groupdocs.ui.annotation.config.AnnotationConfiguration;
+import com.groupdocs.ui.annotation.entity.web.AnnotatedDocumentEntity;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.AnnotationPostedDataEntity;
+import com.groupdocs.ui.annotation.entity.web.PageDataDescriptionEntity;
+import com.groupdocs.ui.annotation.util.AnnotationMapper;
+import com.groupdocs.ui.annotation.util.DocumentTypesConverter;
+import com.groupdocs.ui.annotation.util.SupportedAnnotations;
+import com.groupdocs.ui.config.GlobalConfiguration;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+import com.groupdocs.ui.model.request.FileTreeRequest;
+import com.groupdocs.ui.model.request.LoadDocumentPageRequest;
+import com.groupdocs.ui.model.request.LoadDocumentRequest;
+import com.groupdocs.ui.model.response.FileDescriptionEntity;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+import javax.annotation.PostConstruct;
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Iterator;
+
+@Service
+public class AnnotationServiceImpl implements AnnotationService {
+
+ private static final Logger logger = LoggerFactory.getLogger(AnnotationServiceImpl.class);
+ private final List SupportedImageFormats = new ArrayList<>();
+
+ @Autowired
+ private GlobalConfiguration globalConfiguration;
+
+ @Autowired
+ private AnnotationConfiguration annotationConfiguration;
+
+ private final List annotationPageDescriptionEntityList = new ArrayList<>();
+
+ @PostConstruct
+ public void init() {
+ try {
+ SupportedImageFormats.add(".bmp");
+ SupportedImageFormats.add(".jpeg");
+ SupportedImageFormats.add(".jpg");
+ SupportedImageFormats.add(".tiff");
+ SupportedImageFormats.add(".tif");
+ SupportedImageFormats.add(".png");
+ SupportedImageFormats.add(".dwg");
+ SupportedImageFormats.add(".dcm");
+ SupportedImageFormats.add(".dxf");
+
+ // set GroupDocs license
+ License license = new License();
+ license.setLicense(globalConfiguration.getApplication().getLicensePath());
+ } catch (Throwable exc) {
+ logger.error("Can not verify Annotation license!");
+ }
+ }
+
+ @Override
+ public GlobalConfiguration getGlobalConfiguration() {
+ return globalConfiguration;
+ }
+
+ @Override
+ public AnnotationConfiguration getAnnotationConfiguration() {
+ return annotationConfiguration;
+ }
+
+ @Override
+ public List getFileList(FileTreeRequest fileTreeRequest) {
+ String path = fileTreeRequest.getPath();
+ if (StringUtils.isEmpty(path)) {
+ path = annotationConfiguration.getFilesDirectory();
+ }
+ try {
+ File directory = new File(path);
+ List filesList = Arrays.asList(directory.listFiles());
+
+ List fileList = getFileDescriptionEntities(filesList);
+ return fileList;
+ } catch (Exception ex) {
+ logger.error("Exception in getting file list", ex);
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+
+ public List getFileDescriptionEntities(List filesList) {
+ List fileList = new ArrayList<>();
+ for (File file : filesList) {
+ String guid = file.getAbsolutePath();
+ String extension = FilenameUtils.getExtension(guid);
+ if (file.isDirectory() || (!StringUtils.isEmpty(extension))) {
+ FileDescriptionEntity fileDescription = new FileDescriptionEntity();
+ fileDescription.setGuid(guid);
+ fileDescription.setName(file.getName());
+ fileDescription.setDirectory(file.isDirectory());
+ fileDescription.setSize(file.length());
+ fileList.add(fileDescription);
+ }
+ }
+ return fileList;
+ }
+
+ @Override
+ public AnnotatedDocumentEntity getDocumentDescription(LoadDocumentRequest loadDocumentRequest) {
+ try {
+ return loadDocument(
+ loadDocumentRequest,
+ annotationConfiguration.getPreloadPageCount() == 0
+ );
+ } catch (Throwable ex) {
+ throw new TotalGroupDocsException(ex);
+ }
+ }
+
+ public final AnnotatedDocumentEntity loadDocument(LoadDocumentRequest loadDocumentRequest, boolean loadAllPages) {
+ Annotator annotator = null;
+ AnnotatedDocumentEntity description = new AnnotatedDocumentEntity();
+ String guid = loadDocumentRequest.getGuid();
+ String password = loadDocumentRequest.getPassword();
+ LoadOptions loadOptions = new LoadOptions();
+ loadOptions.setPassword(password);
+
+ try {
+ annotator = new Annotator(guid, loadOptions);
+
+ IDocumentInfo info = annotator.getDocument().getDocumentInfo();
+ List annotations = annotator.get();
+
+ description.setGuid(loadDocumentRequest.getGuid());
+
+ String documentType = "";
+ if (info.getFileType() != null) {
+ documentType = SupportedImageFormats.contains(info.getFileType().getExtension()) ? "image" : info.getFileType().toString();
+ } else {
+ documentType = "Portable Document Format";
+ }
+
+ description.supportedAnnotations = SupportedAnnotations.getSupportedAnnotations(documentType);
+
+ List pagesContent = new ArrayList<>();
+
+ if (loadAllPages) {
+ pagesContent = getAllPagesContent(password, guid, info);
+ }
+
+ for (int i = 0; i < info.getPageCount(); i++) {
+ PageDataDescriptionEntity page = new PageDataDescriptionEntity();
+ page.setNumber(i + 1);
+ page.setHeight(info.getPagesInfo().get(i).getHeight());
+ page.setWidth(info.getPagesInfo().get(i).getWidth());
+
+ if (annotations != null && annotations.size() > 0) {
+ page.setAnnotations(AnnotationMapper.mapForPage(annotations, i + 1, info.getPagesInfo().get(i)));
+ }
+
+ if (pagesContent.size() > 0) {
+ page.setData(pagesContent.get(i));
+ }
+ description.getPages().add(page);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+
+ description.setGuid(guid);
+ // return document description
+ return description;
+ }
+
+ public static String getStringFromStream(InputStream inputStream) throws IOException {
+ inputStream.reset();
+ inputStream.skip(0);
+
+ byte[] bytes = IOUtils.toByteArray(inputStream);
+ // encode ByteArray into String
+ return Base64.getEncoder().encodeToString(bytes);
+ }
+
+ @Override
+ public PageDataDescriptionEntity getDocumentPage(LoadDocumentPageRequest loadDocumentPageRequest) {
+ String password = "";
+ try {
+ // get/set parameters
+ String documentGuid = loadDocumentPageRequest.getGuid();
+ int pageNumber = loadDocumentPageRequest.getPage();
+ password = loadDocumentPageRequest.getPassword();
+ PageDataDescriptionEntity loadedPage = new PageDataDescriptionEntity();
+
+ // get page image
+ byte[] bytes;
+
+ final Annotator annotator = new Annotator(documentGuid, getLoadOptions(password));
+ try {
+ final OutputStream renderPage = renderPageToMemoryStream(pageNumber, documentGuid, password);
+
+ ByteArrayOutputStream bufferRenderPage = (ByteArrayOutputStream) renderPage;
+ byte[] bytesRenderPage = bufferRenderPage.toByteArray();
+ InputStream streamRenderPage = new ByteArrayInputStream(bytesRenderPage);
+
+ try {
+ bytes = IOUtils.toByteArray(streamRenderPage);
+ } finally {
+ if (streamRenderPage != null) {
+ streamRenderPage.close();
+ }
+ }
+
+ IDocumentInfo info = annotator.getDocument().getDocumentInfo();
+ List annotations = annotator.get();
+
+ if (annotations != null && annotations.size() > 0) {
+ loadedPage.setAnnotations(AnnotationMapper.mapForPage(annotations, pageNumber, info.getPagesInfo().get(pageNumber - 1)));
+ }
+
+ String encodedImage = Base64.getEncoder().encodeToString(bytes);
+ loadedPage.setData(encodedImage);
+
+ loadedPage.setHeight(info.getPagesInfo().get(pageNumber - 1).getHeight());
+ loadedPage.setWidth(info.getPagesInfo().get(pageNumber - 1).getWidth());
+ loadedPage.setNumber(pageNumber);
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+
+ // return loaded page object
+ return loadedPage;
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex);
+ }
+ }
+
+ private static OutputStream renderPageToMemoryStream(int pageNumberToRender, String documentGuid, String password) {
+ try {
+ OutputStream result = new ByteArrayOutputStream();
+ InputStream inputStream = new FileInputStream(documentGuid);
+ try {
+ final Annotator annotator = new Annotator(inputStream, getLoadOptions(password));
+ try {
+ PreviewOptions previewOptions = new PreviewOptions(
+ new CreatePageStream() {
+ @Override
+ public OutputStream invoke(int pageNumber) {
+ return result;
+ }
+ }
+ );
+ previewOptions.setPreviewFormat(PreviewFormats.PNG);
+ previewOptions.setPageNumbers(new int[]{pageNumberToRender});
+ previewOptions.setRenderComments(false);
+
+ annotator.getDocument().generatePreview(previewOptions);
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+ return result;
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex);
+ }
+ }
+
+ private static LoadOptions getLoadOptions(String password) {
+ LoadOptions loadOptions = new LoadOptions();
+ loadOptions.setPassword(password);
+ return loadOptions;
+ }
+
+ public InputStream annotateDocument(String documentGuid, String documentType, List annotations) throws FileNotFoundException {
+ Annotator annotator = new Annotator(documentGuid);
+
+ SaveOptions saveOptions = new SaveOptions();
+ saveOptions.setAnnotationTypes(AnnotationType.NONE);
+
+ annotator.save(documentGuid, saveOptions);
+
+ if (annotations.size() > 0) {
+ annotator.add(annotations);
+ annotator.save(documentGuid, new SaveOptions());
+ }
+
+ return new FileInputStream(documentGuid);
+ }
+
+ @Override
+ public AnnotatedDocumentEntity annotate(AnnotationPostedDataEntity annotateDocumentRequest) {
+ AnnotatedDocumentEntity annotatedDocument = new AnnotatedDocumentEntity();
+ try {
+ // get/set parameters
+ String documentGuid = annotateDocumentRequest.getGuid();
+ String password = annotateDocumentRequest.getPassword();
+
+ String documentType = SupportedImageFormats.contains(
+ FilenameUtils.getExtension(annotateDocumentRequest.getGuid())
+ ) ? "image" : annotateDocumentRequest.getDocumentType();
+
+ String tempPath = getTempPath(documentGuid);
+
+ AnnotationDataEntity[] annotationsData = annotateDocumentRequest.getAnnotationsData();
+ // initiate list of annotations to add
+ List annotations = new ArrayList<>();
+
+ final Annotator annotator = new Annotator(documentGuid, getLoadOptions(password));
+ try {
+ IDocumentInfo info = annotator.getDocument().getDocumentInfo();
+
+ for (int i = 0; i < annotationsData.length; i++) {
+ AnnotationDataEntity annotationData = annotationsData[i];
+ PageInfo pageInfo = info.getPagesInfo().get(annotationsData[i].getPageNumber() - 1);//-1
+ // add annotation, if current annotation type isn't supported by the current document type it will be ignored
+ try {
+ BaseAnnotator baseAnnotator = AnnotatorFactory.createAnnotator(annotationData, pageInfo);
+ if (baseAnnotator.isSupported(documentType)) {
+ annotations.add(baseAnnotator.getAnnotationBase(documentType));
+ }
+ } catch (java.lang.RuntimeException ex) {
+ throw new AnnotatorException(ex.getMessage(), ex);
+ }
+ }
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+
+ // Add annotation to the document
+ removeAnnotations(documentGuid, password);
+ // check if annotations array contains at least one annotation to add
+ if (annotations.size() != 0) {
+ final Annotator annotator1 = new Annotator(documentGuid, getLoadOptions(password));
+ try {
+ //foreach to while statements conversion
+ Iterator tmp0 = (annotations).iterator();
+
+ while (tmp0.hasNext()) {
+ AnnotationBase annotation = (AnnotationBase) tmp0.next();
+ annotator1.add(annotation);
+ }
+
+ annotator1.save(tempPath);
+ } finally {
+ if (annotator1 != null) {
+ annotator1.dispose();
+ }
+ }
+
+ try (OutputStream fileStream = new FileOutputStream(documentGuid)) {
+ InputStream inputStream1 = new FileInputStream(tempPath);
+ IOUtils.copyLarge(inputStream1, fileStream);
+ }
+ }
+
+ annotatedDocument = new AnnotatedDocumentEntity();
+ annotatedDocument.setGuid(documentGuid);
+ if (annotateDocumentRequest.getPrint()) {
+ annotatedDocument.setPages(getAnnotatedPagesForPrint(password, documentGuid));
+ Files.move(Paths.get(documentGuid), Paths.get(annotateDocumentRequest.getGuid()));
+ }
+ } catch (Exception ex) {
+ // set exception message
+ throw new TotalGroupDocsException(ex);
+ }
+
+ return annotatedDocument;
+
+ }
+
+ private List getAnnotatedPagesForPrint(String password, String documentGuid) {
+ AnnotatedDocumentEntity description = new AnnotatedDocumentEntity();
+ try {
+ InputStream outputStream = new FileInputStream(documentGuid);
+ try {
+ final Annotator annotator = new Annotator(outputStream, getLoadOptions(password));
+ try {
+ IDocumentInfo info = annotator.getDocument().getDocumentInfo();
+ List pagesContent = getAllPagesContent(password, documentGuid, info);
+
+ for (int i = 0; i < info.getPageCount(); i++) {
+ PageDataDescriptionEntity page = new PageDataDescriptionEntity();
+
+ if (pagesContent.size() > 0) {
+ page.setData(pagesContent.get(i));
+ }
+
+ description.getPages().add(page);
+ }
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+ } finally {
+ if (outputStream != null) {
+ outputStream.close();
+ }
+ }
+
+ return description.getPages();
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+
+ private static String getTempPath(String documentGuid) {
+ File fileName = new File(documentGuid);
+ return fileName.getParentFile().getPath() + "//tmp_" + fileName.getName();
+ }
+
+ public static void removeAnnotations(String documentGuid, String password) {
+ String tempPath = getTempPath(documentGuid);
+
+ try {
+ final InputStream inputStream = new FileInputStream(documentGuid);
+ //final Stream inputStream = File.open(documentGuid, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
+ try {
+ final Annotator annotator = new Annotator(inputStream, getLoadOptions(password));
+ try {
+ SaveOptions tmp0 = new SaveOptions();
+ tmp0.setAnnotationTypes(AnnotationType.NONE);
+ annotator.save(tempPath, tmp0);
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+
+
+ try (PrintWriter writer = new PrintWriter(documentGuid)) {
+ writer.print("");
+ }
+
+ try (OutputStream fileStream = new FileOutputStream(documentGuid)) {
+ InputStream inputStream1 = new FileInputStream(tempPath);
+ IOUtils.copyLarge(inputStream1, fileStream);
+ }
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+
+ private List getAllPagesContent(String password, String documentGuid, IDocumentInfo pages) {
+ List allPages = new ArrayList<>();
+
+ for (int i = 0; i < pages.getPageCount(); i++) {
+ byte[] bytes;
+ try (OutputStream memoryStream = renderPageToMemoryStream(i + 1, documentGuid, password)) {
+ ByteArrayOutputStream bos = (ByteArrayOutputStream) memoryStream;
+ bytes = bos.toByteArray();
+ } catch (IOException ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+
+ String encodedImage = new String(Base64.getEncoder().encode(bytes));
+ allPages.add(encodedImage);
+ }
+
+ return allPages;
+ }
+
+ public List getAnnotationInfos(AnnotationPostedDataEntity annotateDocumentRequest, String documentType) {
+ try {
+ AnnotationDataEntity[] annotationsData = annotateDocumentRequest.getAnnotationsData();
+ // get document info - required to get document page height and calculate annotation top position
+
+ List annotations = new ArrayList<>();
+ for (AnnotationDataEntity annotationData : annotationsData) {
+ // create annotator
+ // add annotation, if current annotation type isn't supported by the current document type it will be ignored
+ PageDataDescriptionEntity pageData = annotationPageDescriptionEntityList.get(annotationData.getPageNumber() - 1);//-1
+
+ PageInfo pageInfo = new PageInfo();
+ pageInfo.setHeight((int) pageData.getHeight());
+ pageInfo.setWidth((int) pageData.getWidth());
+
+ try {
+ annotations.add(AnnotatorFactory.createAnnotator(annotationData, pageInfo).getAnnotationBase(documentType));
+ } catch (Throwable ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+ return annotations;
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+
+ @Override
+ public InputStream annotateByStream(AnnotationPostedDataEntity annotateDocumentRequest) {
+ String documentGuid = annotateDocumentRequest.getGuid();
+ String documentType = DocumentTypesConverter.checkedDocumentType(documentGuid, annotateDocumentRequest.getDocumentType());
+ List annotations = getAnnotationInfos(annotateDocumentRequest, documentType);
+ try {
+ return annotateDocument(documentGuid, documentType, annotations);
+ } catch (FileNotFoundException ex) {
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/service/IPageStreamFactory.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/service/IPageStreamFactory.java
new file mode 100644
index 0000000..4c5b8ae
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/service/IPageStreamFactory.java
@@ -0,0 +1,13 @@
+package com.groupdocs.ui.annotation.service;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ *
+ * @author AlexT
+ */
+public interface IPageStreamFactory {
+ OutputStream createPageStream(int pageNumber);
+ void closePageStream(int pageNumber, InputStream pageStream);
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/service/StreamFactoryClass.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/service/StreamFactoryClass.java
new file mode 100644
index 0000000..ab43242
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/service/StreamFactoryClass.java
@@ -0,0 +1,65 @@
+package com.groupdocs.ui.annotation.service;
+
+import com.groupdocs.ui.annotation.entity.web.PageDataDescriptionEntity;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import javax.imageio.ImageIO;
+import org.apache.commons.io.IOUtils;
+
+/**
+ *
+ * @author AlexT
+ */
+public class StreamFactoryClass implements IPageStreamFactory {
+ public List AnnotationPageDescriptionEntityList = new ArrayList<>();
+
+ @Override
+ public OutputStream createPageStream(int pageNumber) {
+ //ByteArrayInputStream;
+ //ByteArrayOutputStream;
+ //return new MemoryStream();
+ return new ByteArrayOutputStream();
+ }
+
+ @Override
+ public void closePageStream(int pageNumber, InputStream pageStream) {
+ try {
+ PageDataDescriptionEntity page = new PageDataDescriptionEntity();
+
+ BufferedImage imBuff;
+ try {
+ imBuff = ImageIO.read(pageStream);
+ page.setHeight(imBuff.getHeight());
+ page.setWidth(imBuff.getWidth());
+ page.setNumber(pageNumber);
+ } catch (IOException ex) {
+ throw new TotalGroupDocsException(ex);
+ }
+ page.setData(getStringFromStream(pageStream));
+ AnnotationPageDescriptionEntityList.add(page);
+ pageStream.close();
+ } catch (Exception ex) {
+ throw new TotalGroupDocsException(ex);
+ }
+ }
+
+ public static String getStringFromStream(InputStream inputStream) throws IOException {
+ return new String(IOUtils.toByteArray(inputStream), StandardCharsets.UTF_8);
+// byte[] bytes = null;
+// //try (MemoryStream memoryStream = new MemoryStream()) {
+// try (ByteArrayOutputStream memoryStream = new ByteArrayOutputStream()) {
+// memoryStream = IOUtils.toByteArray(inputStream);
+// inputStream.CopyTo(memoryStream);
+// bytes = memoryStream.toByteArray();
+// }
+// // encode ByteArray into String
+// return Convert.ToBase64String(bytes);
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/AnnotationMapper.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/AnnotationMapper.java
new file mode 100644
index 0000000..9937505
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/AnnotationMapper.java
@@ -0,0 +1,148 @@
+package com.groupdocs.ui.annotation.util;
+
+import com.groupdocs.annotation.models.PageInfo;
+import com.groupdocs.annotation.models.Point;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.IBox;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.IFontColor;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.IFontFamily;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.IFontSize;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.IPoints;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.ISvgPath;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.IText;
+import com.groupdocs.annotation.models.annotationmodels.interfaces.properties.ITextToReplace;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.ui.annotation.entity.web.AnnotationDataEntity;
+import com.groupdocs.ui.annotation.entity.web.CommentsEntity;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AnnotationMapper {
+
+ private AnnotationMapper() {
+ }
+
+ /**
+ *
+ * Map AnnotationInfo instances into AnnotationDataEntity
+ *
+ *
+ * @param pageInfo
+ * @return
+ * @param annotations AnnotationInfo[]
+ * @param pageNumber int
+ */
+ // AnnotationDataEntity[] => List
+ public static List mapForPage(List annotations, int pageNumber, PageInfo pageInfo) { //AnnotationBase[] => List
+ // initiate annotations data array
+ List pageAnnotations = new ArrayList<>();
+ // each annotation data - this functionality used since annotations data returned by the
+ // GroupDocs.Annotation library are obfuscated
+ for (int n = 0; n < annotations.size(); n++) {
+ AnnotationBase annotationInfo = annotations.get(n);
+ if (pageNumber == annotationInfo.getPageNumber()) {//+1
+ AnnotationDataEntity annotation = mapAnnotationDataEntity(annotationInfo, pageInfo);
+ pageAnnotations.add(annotation);
+ }
+ }
+
+ return pageAnnotations;
+ }
+
+ /**
+ *
+ * Map AnnotationInfo instances into AnnotationDataEntity
+ *
+ *
+ * @param pageInfo
+ * @return AnnotationDataEntity
+ * @param annotationInfo AnnotationInfo
+ */
+ public static AnnotationDataEntity mapAnnotationDataEntity(AnnotationBase annotationInfo, PageInfo pageInfo) {
+ String annotationTypeName = AnnotationType.getName(annotationInfo.getType());
+ float maxY = 0, minY = Float.MAX_VALUE, maxX = 0, minX = Float.MAX_VALUE; // minY = 0, minX = 0
+ float boxX = 0, boxY = 0, boxHeight = 0, boxWidth = 0;
+ String svgPath = "";
+
+ if (annotationInfo instanceof IPoints) {
+ List points = ((IPoints)annotationInfo).getPoints();
+ for (Point point : points) {
+ maxY = point.getY() > maxY ? point.getY(): maxY;
+ maxX = point.getX() > maxX ? point.getX(): maxX;
+ minY = point.getY() < minY ? point.getY(): minY;
+ minX = point.getX() < minX ? point.getX(): minX;
+ }
+ }
+
+ if (annotationInfo instanceof IBox) {
+ Rectangle box = ((IBox)annotationInfo).getBox();
+ boxX = box.getX();
+ boxY = box.getY();
+ boxHeight = box.getHeight();
+ boxWidth = box.getWidth();
+
+ StringBuilder builder = new StringBuilder().
+ append("M").append(box.getX()).
+ append(",").append(box.getY()).
+ append("L").append(box.getWidth()).
+ append(",").append(box.getHeight());
+
+ svgPath = builder.toString();
+ }
+
+ AnnotationDataEntity annotation = new AnnotationDataEntity();
+ annotation.setFont(annotationInfo instanceof IFontFamily ? ((IFontFamily)annotationInfo).getFontFamily() : "");
+
+ Double fontSize = annotationInfo instanceof IFontSize ? (((IFontSize)annotationInfo).getFontSize() == null) ? 0.0 : ((IFontSize)annotationInfo).getFontSize() : 0.0;
+
+ annotation.setFontSize(fontSize);
+
+ annotation.setFontColor(
+ annotationInfo instanceof IFontColor ?
+ ((((IFontColor) annotationInfo).getFontColor() == null) ? 0 : (int)((IFontColor) annotationInfo).getFontColor())
+ : 0
+ );
+ annotation.setHeight(annotationInfo instanceof IBox ? boxHeight : (annotationInfo instanceof IPoints ? (maxY - minY) : 0));
+ annotation.setLeft(annotationInfo instanceof IBox ? boxX : (annotationInfo instanceof IPoints ? minX : 0));
+
+ annotation.setPageNumber((int)annotationInfo.getPageNumber());//+1
+ annotation.setSvgPath(annotationInfo instanceof ISvgPath ? (((ISvgPath)annotationInfo).getSvgPath().replace("l", "L")) : svgPath);
+
+ String text = "";
+ if (annotationInfo.getMessage() == null && annotationInfo instanceof ITextToReplace) {
+ text = ((ITextToReplace) annotationInfo).getTextToReplace();
+ } else if (annotationInfo instanceof IText && ((IText) annotationInfo).getText() != null) {
+ text = ((IText) annotationInfo).getText();
+ } else if (annotationInfo.getMessage() != null) {
+ text = annotationInfo.getMessage();
+ }
+ annotation.setText(text);
+
+ // TODO: remove comment after check all annotations types on main formats
+ annotation.setTop(annotationInfo instanceof IBox ? boxY : (annotationInfo instanceof IPoints ? pageInfo.getHeight() - maxY : 0));
+ annotation.setType(annotationTypeName.toLowerCase());
+ annotation.setWidth(annotationInfo instanceof IBox ? boxWidth : (annotationInfo instanceof IPoints ? (maxX - minX) : 0));
+ // each reply data
+ List replies = annotationInfo.getReplies();
+ if (replies != null && replies.size() > 0) {
+ CommentsEntity[] comments = new CommentsEntity[replies.size()];
+ for (int m = 0; m < replies.size(); m++) {
+ CommentsEntity comment = new CommentsEntity();
+ Reply reply = replies.get(m);
+ comment.setText(reply.getComment());
+ DateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss"); //"yyyy-MM-dd HH:mm:ss"
+ comment.setTime(format.format(reply.getRepliedOn()));
+
+ comment.setUserName(reply.getUser().getName());
+ comments[m] = comment;
+ }
+ annotation.setComments(comments);
+ }
+
+ return annotation;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/DocumentTypesConverter.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/DocumentTypesConverter.java
new file mode 100644
index 0000000..7a1a906
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/DocumentTypesConverter.java
@@ -0,0 +1,63 @@
+package com.groupdocs.ui.annotation.util;
+
+import com.groupdocs.annotation.models.DocumentType;
+import java.util.List;
+import com.google.common.collect.Lists;
+import static com.groupdocs.ui.util.Utils.parseFileExtension;
+
+public class DocumentTypesConverter {
+
+ private static final List supportedImageFormats = Lists.newArrayList("bmp", "jpeg", "jpg", "tiff", "tif", "png", "gif", "emf", "wmf", "dwg", "dicom", "djvu");
+ private static final List supportedDiagramFormats = Lists.newArrayList(".vsd", ".vdx", ".vss", ".vsx", ".vst", ".vtx", ".vsdx", ".vdw", ".vstx", ".vssx");
+
+ /**
+ *
+ * Convert document type from string into int
+ *
+ *
+ * @return int
+ * @param documentType string
+ */
+// public static int getDocumentType(String documentType) {
+// switch (documentType) {
+// case "Portable Document Format":
+// case "PDF":
+// return DocumentType.Pdf;
+// case "Microsoft Word":
+// case "WORDS":
+// case "Microsoft Word Open XML format (.docx)":
+// return DocumentType.Words;
+// case "Microsoft PowerPoint":
+// case "SLIDES":
+// return DocumentType.Slides;
+// case "image":
+// return DocumentType.Images;
+// case "Microsoft Excel":
+// case "CELLS":
+// return DocumentType.Cells;
+// case "AutoCAD Drawing File Format":
+// case "diagram":
+// return DocumentType.Diagram;
+// default:
+// return DocumentType.Undefined;
+// }
+// }
+
+ /**
+ * Check image and diagram document types
+ *
+ * @param documentGuid document name
+ * @param documentType string value of document type
+ * @return correct document type
+ */
+ public static String checkedDocumentType(String documentGuid, String documentType) {
+ String fileExtension = parseFileExtension(documentGuid);
+ // check if document type is image
+ if (supportedImageFormats.contains(fileExtension)) {
+ documentType = "image";
+ } else if (supportedDiagramFormats.contains(fileExtension)) {
+ documentType = "diagram";
+ }
+ return documentType;
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/SupportedAnnotations.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/SupportedAnnotations.java
new file mode 100644
index 0000000..33e2eb5
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/SupportedAnnotations.java
@@ -0,0 +1,31 @@
+package com.groupdocs.ui.annotation.util;
+
+import com.groupdocs.ui.annotation.entity.Annotations;
+
+public class SupportedAnnotations {
+
+ public static final String[] getSupportedAnnotations(String documentType) {
+ Annotations annotations = new Annotations();
+ switch (documentType) {
+ case "Portable Document Format":
+ case "PDF":
+ return annotations.Pdf;
+ case "Microsoft Word":
+ case "WORDS":
+ return annotations.Word;
+ case "Microsoft PowerPoint":
+ case "SLIDES":
+ return annotations.Slides;
+ case "image":
+ return annotations.Image;
+ case "Microsoft Excel":
+ case "CELLS":
+ return annotations.Cells;
+ case "AutoCAD Drawing File Format":
+ case "diagram":
+ return annotations.Diagram;
+ default:
+ return annotations.Pdf;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/directory/DirectoryUtils.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/directory/DirectoryUtils.java
new file mode 100644
index 0000000..9f65c7d
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/directory/DirectoryUtils.java
@@ -0,0 +1,19 @@
+package com.groupdocs.ui.annotation.util.directory;
+
+import com.groupdocs.ui.annotation.config.AnnotationConfiguration;
+
+public class DirectoryUtils {
+
+ public FilesDirectoryUtils FilesDirectory;
+
+ /**
+ *
+ * Constructor
+ *
+ *
+ * @param annotationConfiguration AnnotationConfiguration
+ */
+ public DirectoryUtils(AnnotationConfiguration annotationConfiguration) {
+ FilesDirectory = new FilesDirectoryUtils(annotationConfiguration);
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/directory/FilesDirectoryUtils.java b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/directory/FilesDirectoryUtils.java
new file mode 100644
index 0000000..970dde1
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/annotation/util/directory/FilesDirectoryUtils.java
@@ -0,0 +1,30 @@
+package com.groupdocs.ui.annotation.util.directory;
+
+import com.groupdocs.ui.annotation.config.AnnotationConfiguration;
+
+public class FilesDirectoryUtils { /*implements IDirectoryUtils { */
+
+ private final AnnotationConfiguration AnnotationConfiguration;
+
+ /**
+ *
+ * Constructor
+ *
+ *
+ * @param annotationConfiguration
+ */
+ public FilesDirectoryUtils(AnnotationConfiguration annotationConfiguration) {
+ AnnotationConfiguration = annotationConfiguration;
+ }
+
+ /**
+ *
+ * Get path
+ *
+ *
+ * @return string
+ */
+ public final String getPath() {
+ return AnnotationConfiguration.getFilesDirectory();
+ }
+}
\ No newline at end of file
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/config/ApplicationConfiguration.java b/Demos/Spring/src/main/java/com/groupdocs/ui/config/ApplicationConfiguration.java
new file mode 100644
index 0000000..b8f9055
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/config/ApplicationConfiguration.java
@@ -0,0 +1,62 @@
+package com.groupdocs.ui.config;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import javax.annotation.PostConstruct;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+import static com.groupdocs.ui.config.DefaultDirectories.defaultLicenseDirectory;
+import static com.groupdocs.ui.config.DefaultDirectories.relativePathToAbsolute;
+
+@Component
+public class ApplicationConfiguration {
+ private static final Logger logger = LoggerFactory.getLogger(ApplicationConfiguration.class);
+
+ @Value("${application.hostAddress}")
+ private String hostAddress;
+ @Value("${application.licensePath}")
+ private String licensePath;
+
+ @PostConstruct
+ public void init() {
+ if (StringUtils.isEmpty(hostAddress)) {
+ try {
+ hostAddress = InetAddress.getLocalHost().getHostAddress();
+ } catch (UnknownHostException e) {
+ logger.error("Can not get host address ", e);
+ hostAddress = "localhost";
+ }
+ }
+ this.licensePath = StringUtils.isEmpty(this.licensePath) ? defaultLicenseDirectory() : relativePathToAbsolute(this.licensePath);
+ }
+
+ public String getLicensePath() {
+ return licensePath;
+ }
+
+ public void setLicensePath(String licensePath) {
+ this.licensePath = licensePath;
+ }
+
+ public String getHostAddress() {
+ return hostAddress;
+ }
+
+ public void setHostAddress(String hostAddress) {
+ this.hostAddress = hostAddress;
+ }
+
+ @Override
+ public String toString() {
+ return "ApplicationConfiguration{" +
+ "licensePath='" + licensePath + '\'' +
+ ", hostAddress='" + hostAddress + '\'' +
+ '}';
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/config/CommonConfiguration.java b/Demos/Spring/src/main/java/com/groupdocs/ui/config/CommonConfiguration.java
new file mode 100644
index 0000000..8817a31
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/config/CommonConfiguration.java
@@ -0,0 +1,103 @@
+package com.groupdocs.ui.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * CommonConfiguration
+ *
+ * @author Aspose Pty Ltd
+ */
+@Component
+public class CommonConfiguration {
+
+ @Value("#{new Boolean('${common.pageSelector}')}")
+ private boolean pageSelector;
+
+ @Value("#{new Boolean('${common.download}')}")
+ private Boolean download;
+
+ @Value("#{new Boolean('${common.upload}')}")
+ private Boolean upload;
+
+ @Value("#{new Boolean('${common.print}')}")
+ private Boolean print;
+
+ @Value("#{new Boolean('${common.browse}')}")
+ private Boolean browse;
+
+ @Value("#{new Boolean('${common.rewrite}')}")
+ private Boolean rewrite;
+
+ @Value("#{new Boolean('${common.enableRightClick}')}")
+ private Boolean enableRightClick;
+
+ public boolean isPageSelector() {
+ return pageSelector;
+ }
+
+ public void setPageSelector(boolean pageSelector) {
+ this.pageSelector = pageSelector;
+ }
+
+ public boolean isDownload() {
+ return download;
+ }
+
+ public void setDownload(boolean download) {
+ this.download = download;
+ }
+
+ public boolean isUpload() {
+ return upload;
+ }
+
+ public void setUpload(boolean upload) {
+ this.upload = upload;
+ }
+
+ public boolean isPrint() {
+ return print;
+ }
+
+ public void setPrint(boolean print) {
+ this.print = print;
+ }
+
+ public boolean isBrowse() {
+ return browse;
+ }
+
+ public void setBrowse(boolean browse) {
+ this.browse = browse;
+ }
+
+ public boolean isRewrite() {
+ return rewrite;
+ }
+
+ public void setRewrite(boolean rewrite) {
+ this.rewrite = rewrite;
+ }
+
+ public Boolean getEnableRightClick() {
+ return enableRightClick;
+ }
+
+ public void setEnableRightClick(Boolean enableRightClick) {
+ this.enableRightClick = enableRightClick;
+ }
+
+ @Override
+ public String toString() {
+ return "CommonConfiguration{" +
+ "pageSelector=" + pageSelector +
+ ", download=" + download +
+ ", upload=" + upload +
+ ", print=" + print +
+ ", browse=" + browse +
+ ", rewrite=" + rewrite +
+ ", enableRightClick=" + enableRightClick +
+ '}';
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/config/DefaultDirectories.java b/Demos/Spring/src/main/java/com/groupdocs/ui/config/DefaultDirectories.java
new file mode 100644
index 0000000..d1a602c
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/config/DefaultDirectories.java
@@ -0,0 +1,76 @@
+package com.groupdocs.ui.config;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.util.StringUtils;
+
+import java.io.File;
+import java.nio.file.FileSystems;
+import java.nio.file.Path;
+
+public class DefaultDirectories {
+ private static final Logger logger = LoggerFactory.getLogger(DefaultDirectories.class);
+
+ public static final String LIC = ".lic";
+ public static final String LICENSES = "Licenses";
+ public static final String DOCUMENT_SAMPLES = "DocumentSamples";
+
+ public static String defaultLicenseDirectory() {
+ Path defaultLicFolder = FileSystems.getDefault().getPath(LICENSES).toAbsolutePath();
+ File licFolder = defaultLicFolder.toFile();
+ if (licFolder.exists()) {
+ Path defaultLicFile = getDefaultLicFile(licFolder);
+ if (defaultLicFile != null) {
+ return defaultLicFile.toString();
+ }
+ }
+ licFolder.mkdirs();
+ logger.info("License file path is incorrect, application launched in trial mode");
+ return "";
+ }
+
+ public static String defaultAnnotationDirectory() {
+ return getDefaultFilesDir("");
+ }
+
+ public static String getDefaultFilesDir(String folder) {
+ String dir = DOCUMENT_SAMPLES + File.separator + folder;
+ Path path = FileSystems.getDefault().getPath(dir).toAbsolutePath();
+ makeDirs(path.toFile());
+ return path.toString();
+ }
+
+ private static void makeDirs(File file) {
+ if (!file.exists()) {
+ file.mkdirs();
+ }
+ }
+
+ public static String relativePathToAbsolute(String path) {
+ Iterable rootDirectories = FileSystems.getDefault().getRootDirectories();
+
+ if (StringUtils.isEmpty(path)) {
+ return FileSystems.getDefault().getPath("").toAbsolutePath().toString();
+ }
+
+ for (Path root : rootDirectories) {
+ if (path.startsWith(root.toString())) {
+ makeDirs(new File(path));
+ return path;
+ }
+ }
+
+ Path absolutePath = FileSystems.getDefault().getPath(path).toAbsolutePath();
+ makeDirs(absolutePath.toFile());
+ return absolutePath.toString();
+ }
+
+ public static Path getDefaultLicFile(File licFolder) {
+ for (File file : licFolder.listFiles()) {
+ if (file.getName().endsWith(LIC)) {
+ return FileSystems.getDefault().getPath(LICENSES + File.separator + file.getName()).toAbsolutePath();
+ }
+ }
+ return null;
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/config/GlobalConfiguration.java b/Demos/Spring/src/main/java/com/groupdocs/ui/config/GlobalConfiguration.java
new file mode 100644
index 0000000..aaea4f7
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/config/GlobalConfiguration.java
@@ -0,0 +1,38 @@
+package com.groupdocs.ui.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class GlobalConfiguration {
+
+ @Autowired
+ private ServerConfiguration server;
+
+ @Autowired
+ private ApplicationConfiguration application;
+
+ public ServerConfiguration getServer() {
+ return server;
+ }
+
+ public void setServer(ServerConfiguration server) {
+ this.server = server;
+ }
+
+ public ApplicationConfiguration getApplication() {
+ return application;
+ }
+
+ public void setApplication(ApplicationConfiguration application) {
+ this.application = application;
+ }
+
+ @Override
+ public String toString() {
+ return "GlobalConfiguration{" +
+ "server=" + server +
+ ", application=" + application +
+ '}';
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/config/ServerConfiguration.java b/Demos/Spring/src/main/java/com/groupdocs/ui/config/ServerConfiguration.java
new file mode 100644
index 0000000..bfefb72
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/config/ServerConfiguration.java
@@ -0,0 +1,36 @@
+package com.groupdocs.ui.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServerConfiguration {
+
+ private Integer httpPort;
+ @Value("#{servletContext.contextPath}")
+ private String applicationContextPath;
+
+ public Integer getHttpPort() {
+ return httpPort;
+ }
+
+ public void setHttpPort(Integer httpPort) {
+ this.httpPort = httpPort;
+ }
+
+ public String getApplicationContextPath() {
+ return applicationContextPath;
+ }
+
+ public void setApplicationContextPath(String applicationContextPath) {
+ this.applicationContextPath = applicationContextPath;
+ }
+
+ @Override
+ public String toString() {
+ return "ServerConfiguration{" +
+ "httpPort=" + httpPort +
+ ", applicationContextPath='" + applicationContextPath + '\'' +
+ '}';
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/exception/GroupDocsExceptionHandler.java b/Demos/Spring/src/main/java/com/groupdocs/ui/exception/GroupDocsExceptionHandler.java
new file mode 100644
index 0000000..48261a3
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/exception/GroupDocsExceptionHandler.java
@@ -0,0 +1,32 @@
+package com.groupdocs.ui.exception;
+
+import com.groupdocs.ui.model.response.ExceptionEntity;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
+
+import static com.groupdocs.ui.exception.PasswordExceptions.INCORRECT_PASSWORD;
+import static com.groupdocs.ui.exception.PasswordExceptions.PASSWORD_REQUIRED;
+
+@ControllerAdvice
+public class GroupDocsExceptionHandler extends ResponseEntityExceptionHandler {
+
+ @ExceptionHandler(TotalGroupDocsException.class)
+ protected ResponseEntity handleTotalGroupDocsException(TotalGroupDocsException exception) {
+ ExceptionEntity exceptionEntity = new ExceptionEntity();
+ String message = exception.getMessage();
+ exceptionEntity.setMessage(message);
+ if (PASSWORD_REQUIRED.equals(message) || INCORRECT_PASSWORD.equals(message)) {
+ return new ResponseEntity<>(exceptionEntity, HttpStatus.OK);
+ }
+ if (logger.isDebugEnabled()) {
+ exception.printStackTrace();
+ exceptionEntity.setException(exception);
+ }
+ logger.error(exception.getCause() != null? exception.getCause().getLocalizedMessage() : message);
+ return new ResponseEntity<>(exceptionEntity, HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/exception/PasswordExceptions.java b/Demos/Spring/src/main/java/com/groupdocs/ui/exception/PasswordExceptions.java
new file mode 100644
index 0000000..64d2044
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/exception/PasswordExceptions.java
@@ -0,0 +1,6 @@
+package com.groupdocs.ui.exception;
+
+public class PasswordExceptions {
+ public static final String PASSWORD_REQUIRED = "Password Required";
+ public static final String INCORRECT_PASSWORD = "Incorrect password";
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/exception/TotalGroupDocsException.java b/Demos/Spring/src/main/java/com/groupdocs/ui/exception/TotalGroupDocsException.java
new file mode 100644
index 0000000..d393e55
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/exception/TotalGroupDocsException.java
@@ -0,0 +1,19 @@
+package com.groupdocs.ui.exception;
+
+/**
+ * Wrapper for application's exceptions
+ */
+public class TotalGroupDocsException extends RuntimeException {
+
+ public TotalGroupDocsException(String message) {
+ super(message);
+ }
+
+ public TotalGroupDocsException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public TotalGroupDocsException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/model/request/FileTreeRequest.java b/Demos/Spring/src/main/java/com/groupdocs/ui/model/request/FileTreeRequest.java
new file mode 100644
index 0000000..1c644d5
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/model/request/FileTreeRequest.java
@@ -0,0 +1,13 @@
+package com.groupdocs.ui.model.request;
+
+public class FileTreeRequest {
+ private String path;
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/model/request/LoadDocumentPageRequest.java b/Demos/Spring/src/main/java/com/groupdocs/ui/model/request/LoadDocumentPageRequest.java
new file mode 100644
index 0000000..dbb726b
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/model/request/LoadDocumentPageRequest.java
@@ -0,0 +1,13 @@
+package com.groupdocs.ui.model.request;
+
+public class LoadDocumentPageRequest extends LoadDocumentRequest {
+ private Integer page;
+
+ public Integer getPage() {
+ return page;
+ }
+
+ public void setPage(Integer page) {
+ this.page = page;
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/model/request/LoadDocumentRequest.java b/Demos/Spring/src/main/java/com/groupdocs/ui/model/request/LoadDocumentRequest.java
new file mode 100644
index 0000000..7ba768d
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/model/request/LoadDocumentRequest.java
@@ -0,0 +1,23 @@
+package com.groupdocs.ui.model.request;
+
+public class LoadDocumentRequest {
+
+ private String guid;
+ private String password;
+
+ public String getGuid() {
+ return guid;
+ }
+
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/ExceptionEntity.java b/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/ExceptionEntity.java
new file mode 100644
index 0000000..3106451
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/ExceptionEntity.java
@@ -0,0 +1,57 @@
+package com.groupdocs.ui.model.response;
+
+/**
+ * ExceptionEntity
+ *
+ * @author Aspose Pty Ltd
+ */
+public class ExceptionEntity {
+ private String message;
+ private Exception exception;
+
+ public ExceptionEntity() {
+ }
+
+ public ExceptionEntity(String message) {
+ this.message = message;
+ }
+
+ public ExceptionEntity(String message, Exception exception) {
+ this.message = message;
+ this.exception = exception;
+ }
+
+ /**
+ * Get exception message
+ * @return message
+ */
+ public String getMessage() {
+ return message;
+ }
+
+ /**
+ * Set exception message
+ * @param message message
+ */
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ /**
+ * Get exception
+ * @return exception
+ */
+ public Exception getException() {
+ return exception;
+ }
+
+ /**
+ * Set exception
+ * @param exception exception
+ */
+ public void setException(Exception exception) {
+ this.exception = exception;
+ }
+
+}
+
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/FileDescriptionEntity.java b/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/FileDescriptionEntity.java
new file mode 100644
index 0000000..17eeffa
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/FileDescriptionEntity.java
@@ -0,0 +1,95 @@
+package com.groupdocs.ui.model.response;
+
+/**
+ * FileDescriptionEntity
+ *
+ * @author Aspose Pty Ltd
+ */
+public class FileDescriptionEntity {
+ private String guid;
+ private String name;
+ private String docType;
+ private Boolean isDirectory;
+ private Long size;
+
+ /**
+ * Get guid (file id)
+ * @return guid
+ */
+ public String getGuid() {
+ return guid.replace("\\", "//");
+ }
+
+ /**
+ * Set guid (File id)
+ * @param guid guid
+ */
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ /**
+ * Get file name
+ * @return file name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set file name
+ * @param name file name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Get document type
+ * @return document type
+ */
+ public String getDocType() {
+ return docType;
+ }
+
+ /**
+ * Set document type
+ * @param docType document type
+ */
+ public void setDocType(String docType) {
+ this.docType = docType;
+ }
+
+ /**
+ * Check if path is directory
+ * @return true/false flag
+ */
+ public Boolean isDirectory() {
+ return isDirectory;
+ }
+
+ /**
+ * Set is directory flag
+ * @param directory true/false flag
+ */
+ public void setDirectory(Boolean directory) {
+ isDirectory = directory;
+ }
+
+ /**
+ * Get file size
+ * @return file size
+ */
+ public Long getSize() {
+ return size;
+ }
+
+ /**
+ * Set file size
+ * @param size file size
+ */
+ public void setSize(Long size) {
+ this.size = size;
+ }
+
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/LoadDocumentEntity.java b/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/LoadDocumentEntity.java
new file mode 100644
index 0000000..27ad028
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/LoadDocumentEntity.java
@@ -0,0 +1,30 @@
+package com.groupdocs.ui.model.response;
+
+import java.util.List;
+
+public class LoadDocumentEntity {
+ /**
+ * Document Guid
+ */
+ private String guid;
+ /**
+ * list of pages
+ */
+ private List pages;
+
+ public String getGuid() {
+ return guid;
+ }
+
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ public List getPages() {
+ return pages;
+ }
+
+ public void setPages(List pages) {
+ this.pages = pages;
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/PageDescriptionEntity.java b/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/PageDescriptionEntity.java
new file mode 100644
index 0000000..4193475
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/PageDescriptionEntity.java
@@ -0,0 +1,57 @@
+package com.groupdocs.ui.model.response;
+
+/**
+ * PageDescriptionEntity
+ *
+ * @author Aspose Pty Ltd
+ */
+public class PageDescriptionEntity {
+ /**
+ * Page data
+ */
+ private String data;
+ private int angle;
+ private double width;
+ private double height;
+ private int number;
+
+ public int getAngle() {
+ return angle;
+ }
+
+ public void setAngle(int angle) {
+ this.angle = angle;
+ }
+
+ public double getWidth() {
+ return width;
+ }
+
+ public void setWidth(double width) {
+ this.width = width;
+ }
+
+ public double getHeight() {
+ return height;
+ }
+
+ public void setHeight(double height) {
+ this.height = height;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public String getData() {
+ return data;
+ }
+
+ public void setData(String data) {
+ this.data = data;
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/UploadedDocumentEntity.java b/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/UploadedDocumentEntity.java
new file mode 100644
index 0000000..65d744f
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/model/response/UploadedDocumentEntity.java
@@ -0,0 +1,26 @@
+package com.groupdocs.ui.model.response;
+
+/**
+ * UploadedDocumentEntity
+ *
+ * @author Aspose Pty Ltd
+ */
+public class UploadedDocumentEntity {
+ private String guid;
+
+ /**
+ * Get guid (file id)
+ * @return guid
+ */
+ public String getGuid() {
+ return guid;
+ }
+
+ /**
+ * Set guid (file id)
+ * @param guid guid
+ */
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+}
diff --git a/Demos/Spring/src/main/java/com/groupdocs/ui/util/Utils.java b/Demos/Spring/src/main/java/com/groupdocs/ui/util/Utils.java
new file mode 100644
index 0000000..8074c34
--- /dev/null
+++ b/Demos/Spring/src/main/java/com/groupdocs/ui/util/Utils.java
@@ -0,0 +1,261 @@
+package com.groupdocs.ui.util;
+
+import com.groupdocs.ui.config.ServerConfiguration;
+import com.groupdocs.ui.exception.TotalGroupDocsException;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.util.StringUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.Base64;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
+import static org.springframework.http.HttpHeaders.CONTENT_LENGTH;
+
+public class Utils {
+ private static final Logger logger = LoggerFactory.getLogger(Utils.class);
+
+ public static final FileNameComparator FILE_NAME_COMPARATOR = new FileNameComparator();
+ public static final FileTypeComparator FILE_TYPE_COMPARATOR = new FileTypeComparator();
+
+ /**
+ * Set local port from request to config
+ *
+ * @param request
+ * @param server
+ */
+ public static void setLocalPort(HttpServletRequest request, ServerConfiguration server) {
+ if (server.getHttpPort() == null) {
+ server.setHttpPort(request.getLocalPort());
+ }
+ }
+
+ /**
+ * Read stream and convert to string
+ *
+ * @param inputStream
+ * @return
+ * @throws IOException
+ */
+ public static String getStringFromStream(InputStream inputStream) throws IOException {
+ byte[] bytes = IOUtils.toByteArray(inputStream);
+ // encode ByteArray into String
+ return Base64.getEncoder().encodeToString(bytes);
+ }
+
+ /**
+ * Parse extension of the file's name
+ *
+ * @param documentGuid path to file
+ * @return extension of the file's name
+ */
+ public static String parseFileExtension(String documentGuid) {
+ String extension = FilenameUtils.getExtension(documentGuid);
+ return extension == null ? null : extension.toLowerCase();
+ }
+
+ /**
+ * Fill header HTTP response with file data
+ */
+ public static void addFileDownloadHeaders(HttpServletResponse response, String fileName, Long fileLength) {
+ HttpHeaders fileDownloadHeaders = createFileDownloadHeaders(fileName, fileLength, MediaType.APPLICATION_OCTET_STREAM);
+ for (Map.Entry> entry : fileDownloadHeaders.entrySet()) {
+ for (String value : entry.getValue()) {
+ response.addHeader(entry.getKey(), value);
+ }
+ }
+ }
+
+ /**
+ * Set "Content-Length" header into response
+ *
+ * @param response http response
+ * @param length the length of file
+ */
+ public static void addFileDownloadLengthHeader(HttpServletResponse response, Long length) {
+ if (length != null) {
+ response.setHeader(CONTENT_LENGTH, Long.toString(length));
+ }
+ }
+
+ /**
+ * Upload the file
+ *
+ * @param documentStoragePath path for uploading the file
+ * @param content file data
+ * @param url url of file
+ * @param rewrite flag of rewriting the file
+ * @return path to uploaded file
+ */
+ public static String uploadFile(String documentStoragePath, MultipartFile content, String url, Boolean rewrite) {
+ String filePath;
+ try {
+ String fileName;
+ // save from file content
+ if (StringUtils.isEmpty(url)) {
+ fileName = content.getOriginalFilename();
+ try (InputStream inputStream = content.getInputStream()) {
+ filePath = uploadFileInternal(inputStream, documentStoragePath, fileName, rewrite);
+ } catch (Exception ex) {
+ logger.error("Exception occurred while uploading document", ex);
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ } else { // save from url
+ URL fileUrl = new URL(url);
+ try (InputStream inputStream = fileUrl.openStream()) {
+ fileName = FilenameUtils.getName(fileUrl.getPath());
+ filePath = uploadFileInternal(inputStream, documentStoragePath, fileName, rewrite);
+ } catch (Exception ex) {
+ logger.error("Exception occurred while uploading document", ex);
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ }
+ } catch (Exception ex) {
+ logger.error("Exception occurred while uploading document", ex);
+ throw new TotalGroupDocsException(ex.getMessage(), ex);
+ }
+ return filePath;
+ }
+
+ /**
+ * Upload file from input stream
+ *
+ * @param uploadedInputStream input stream of file
+ * @param documentStoragePath path to storage
+ * @param fileName name of file
+ * @param rewrite flag for rewriting
+ * @return path to file
+ * @throws IOException
+ */
+ public static String uploadFileInternal(InputStream uploadedInputStream, String documentStoragePath, String fileName, boolean rewrite) throws IOException {
+ String filePath = String.format("%s%s%s", documentStoragePath, File.separator, fileName);
+ File file = new File(filePath);
+ // check rewrite mode
+ if (rewrite) {
+ // save file with rewrite if exists
+ Files.copy(uploadedInputStream, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
+ return filePath;
+ } else {
+ if (file.exists()) {
+ // get file with new name
+ file = getFreeFileName(documentStoragePath, fileName);
+ }
+ // save file without rewriting
+ Path path = file.toPath();
+ Files.copy(uploadedInputStream, path);
+ return path.toString();
+ }
+ }
+
+ /**
+ * Get headers for downloading files
+ */
+ private static HttpHeaders createFileDownloadHeaders(String fileName, Long fileLength, MediaType mediaType) {
+ HttpHeaders httpHeaders = new HttpHeaders();
+ httpHeaders.setContentDispositionFormData("attachment", fileName);
+ httpHeaders.setContentType(mediaType);
+ httpHeaders.set("Content-Description", "File Transfer");
+ httpHeaders.set("Content-Transfer-Encoding", "binary");
+ httpHeaders.setExpires(0);
+ httpHeaders.setCacheControl("must-revalidate");
+ httpHeaders.setPragma("public");
+ if (fileLength != null) {
+ httpHeaders.setContentLength(fileLength);
+ }
+ return httpHeaders;
+ }
+
+ /**
+ * Rename file if exist
+ *
+ * @param directory directory where files are located
+ * @param fileName file name
+ * @return new file with new file name
+ */
+ public static File getFreeFileName(String directory, String fileName) {
+ File file = null;
+ try {
+ File folder = new File(directory);
+ File[] listOfFiles = folder.listFiles();
+ for (int i = 0; i < listOfFiles.length; i++) {
+ int number = i + 1;
+ String newFileName = FilenameUtils.removeExtension(fileName) + "-Copy(" + number + ")." + FilenameUtils.getExtension(fileName);
+ file = new File(directory + File.separator + newFileName);
+ if (file.exists()) {
+ continue;
+ } else {
+ break;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return file;
+ }
+
+ /**
+ * FileNameComparator
+ * Compare and sort file names alphabetically
+ *
+ * @author Aspose Pty Ltd
+ */
+ static class FileNameComparator implements Comparator {
+
+ /**
+ * Compare two file names
+ *
+ * @param file1
+ * @param file2
+ * @return int
+ */
+ @Override
+ public int compare(File file1, File file2) {
+ return String.CASE_INSENSITIVE_ORDER.compare(file1.getName(),
+ file2.getName());
+ }
+ }
+
+ /**
+ * FileTypeComparator
+ * Compare and sort file types - folders first
+ *
+ * @author Aspose Pty Ltd
+ */
+ static class FileTypeComparator implements Comparator {
+ /**
+ * Compare two file types
+ *
+ * @param file1
+ * @param file2
+ * @return
+ */
+ @Override
+ public int compare(File file1, File file2) {
+ if (file1.isDirectory() && file2.isFile()) {
+ return -1;
+ }
+ if (file1.isDirectory() && file2.isDirectory()) {
+ return 0;
+ }
+ if (file1.isFile() && file2.isFile()) {
+ return 0;
+ }
+ return 1;
+ }
+ }
+}
diff --git a/Demos/Spring/src/main/resources/application.properties b/Demos/Spring/src/main/resources/application.properties
new file mode 100644
index 0000000..ad1fc0d
--- /dev/null
+++ b/Demos/Spring/src/main/resources/application.properties
@@ -0,0 +1,5 @@
+spring.servlet.multipart.max-file-size=10Mb
+spring.servlet.multipart.max-request-size=10Mb
+#Logging
+logging.level.org.springframework.web=ERROR
+logging.level.com.groupdocs.ui=DEBUG
diff --git a/Demos/Spring/src/main/resources/defaultConfiguration.yml b/Demos/Spring/src/main/resources/defaultConfiguration.yml
new file mode 100644
index 0000000..6543f7e
--- /dev/null
+++ b/Demos/Spring/src/main/resources/defaultConfiguration.yml
@@ -0,0 +1,99 @@
+################################################
+# Server configurations
+################################################
+server:
+ connector:
+ # Changing port is available for embedded server only
+ # Is is not possible to change port for deploying application on external server
+ port: 8080
+
+
+################################################
+# Application (global) configurations
+################################################
+application:
+ # License path
+ # Absolute or relative path to GroupDocs license file
+ licensePath:
+ # Host name or ip for server instance
+ hostAddress:
+
+
+################################################
+# Common configurations
+################################################
+common:
+ # File rewriting on document uploading
+ # Set false to keep both files
+ # Set true to replace files with same name
+ rewrite: true
+ # Page navigation
+ # Set false to disable document navigation (go to next, previous, last and first page)
+ pageSelector: true
+ # Document download
+ # Set false to disable document download
+ download: true
+ # Document upload
+ # Set false to disable document upload
+ upload: true
+ # Document print
+ # Set false to disable document print
+ print: true
+ # File browser
+ # Set false to disable document browse
+ browse: true
+ # Set false to disable right mouse click
+ enableRightClick: true
+
+################################################
+# GroupDocs.Annotation configurations
+################################################
+annotation:
+ # Files directory path
+ # Absolute or relative path to files directory
+ filesDirectory: DocumentSamples
+ # Default document
+ # Absolute path to default document
+ defaultDocument:
+ # Pages preload
+ # How many pages from a document should be loaded, remaining pages will be loaded on page scrolling
+ # Set 0 to load all pages at once
+ preloadPageCount: 0
+ # Fonts path
+ # Absolute path to custom fonts directory
+ fontsDirectory:
+ # Enable/disable Text annotation
+ textAnnotation: true
+ # Enable/disable Area annotation
+ areaAnnotation: true
+ # Enable/disable Point annotation
+ pointAnnotation: true
+ # Enable/disable TextStrikeout annotation
+ textStrikeoutAnnotation: true
+ # Enable/disable Polyline annotation
+ polylineAnnotation: true
+ # Enable/disable TextField annotation
+ textFieldAnnotation: true
+ # Enable/disable Watermark annotation
+ watermarkAnnotation: true
+ # Enable/disable TextReplacement annotation
+ textReplacementAnnotation: true
+ # Enable/disable Arrow annotation
+ arrowAnnotation: true
+ # Enable/disable TextRedaction annotation
+ textRedactionAnnotation: true
+ # Enable/disable ResourcesRedaction annotation
+ resourcesRedactionAnnotation: true
+ # Enable/disable TextUnderline annotation
+ textUnderlineAnnotation: true
+ # Enable/disable Distance annotation
+ distanceAnnotation: true
+ # Enable/disable original document downloading
+ downloadOriginal: true
+ # Enable/disable signed document downloading
+ downloadAnnotated: true
+ # Enable/disable zoom
+ zoom: true
+ # Enable/disable fit width
+ # set true to zoom document pages fit width
+ fitWidth: true
diff --git a/Demos/Spring/src/main/resources/static/.gitkeep b/Demos/Spring/src/main/resources/static/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/Demos/Spring/src/main/resources/templates/annotation.html b/Demos/Spring/src/main/resources/templates/annotation.html
new file mode 100644
index 0000000..eaed300
--- /dev/null
+++ b/Demos/Spring/src/main/resources/templates/annotation.html
@@ -0,0 +1,23 @@
+
+
+
+
+ GroupDocs.Annotation for Java Spring
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Demos/Spring/src/main/webapp/META-INF/context.xml b/Demos/Spring/src/main/webapp/META-INF/context.xml
new file mode 100644
index 0000000..600c069
--- /dev/null
+++ b/Demos/Spring/src/main/webapp/META-INF/context.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/Demos/Spring/src/test/java/com/groupdocs/ui/annotation/controller/AnnotationControllerTest.java b/Demos/Spring/src/test/java/com/groupdocs/ui/annotation/controller/AnnotationControllerTest.java
new file mode 100644
index 0000000..b9ba16c
--- /dev/null
+++ b/Demos/Spring/src/test/java/com/groupdocs/ui/annotation/controller/AnnotationControllerTest.java
@@ -0,0 +1,63 @@
+package com.groupdocs.ui.annotation.controller;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view;
+import static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;
+
+//@RunWith(SpringRunner.class)
+//@SpringBootTest
+public class AnnotationControllerTest {
+// MockMvc mvc;
+//
+// @Autowired
+// protected WebApplicationContext wac;
+//
+// @Autowired
+// AnnotationController controller;
+//
+// @Before
+// public void setUp() throws Exception {
+// InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
+// viewResolver.setPrefix("/templates/");
+// viewResolver.setSuffix(".html");
+//
+// this.mvc = standaloneSetup(this.controller).setViewResolvers(viewResolver).build();
+// }
+//
+// @Test
+// public void getView() throws Exception {
+// mvc.perform(get("/annotation")).andExpect(status().isOk()).andExpect(view().name("annotation"));
+// }
+//
+// public void loadFileTree() {
+// }
+//
+// public void loadDocumentDescription() {
+// }
+//
+// public void loadDocumentPage() {
+// }
+//
+// public void downloadDocument() {
+// }
+//
+// public void uploadDocument() {
+// }
+//
+// public void textCoordinates() {
+// }
+//
+// public void annotate() {
+// }
+}
\ No newline at end of file
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/.gitignore b/Examples/GroupDocs.Annotation.Examples.Java/.gitignore
deleted file mode 100644
index b83d222..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/target/
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/OutputFiles/annotated.pdf b/Examples/GroupDocs.Annotation.Examples.Java/Data/OutputFiles/annotated.pdf
deleted file mode 100644
index b5fff29..0000000
Binary files a/Examples/GroupDocs.Annotation.Examples.Java/Data/OutputFiles/annotated.pdf and /dev/null differ
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/Screenshots/code.PNG b/Examples/GroupDocs.Annotation.Examples.Java/Data/Screenshots/code.PNG
deleted file mode 100644
index 55d9dda..0000000
Binary files a/Examples/GroupDocs.Annotation.Examples.Java/Data/Screenshots/code.PNG and /dev/null differ
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/Screenshots/folder.PNG b/Examples/GroupDocs.Annotation.Examples.Java/Data/Screenshots/folder.PNG
deleted file mode 100644
index 32b6fc9..0000000
Binary files a/Examples/GroupDocs.Annotation.Examples.Java/Data/Screenshots/folder.PNG and /dev/null differ
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/README.md b/Examples/GroupDocs.Annotation.Examples.Java/README.md
deleted file mode 100644
index e026112..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/README.md
+++ /dev/null
@@ -1,26 +0,0 @@
-# GroupDocs_Annotation_Java
-
-This package contains [Examples](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java/tree/master/Examples) that will help you in understanding the API's working and writing your own applications.
-
-GroupDocs.Annotation is essentially devised to add annotations in documents within a Java applications. API comes with an extensive number of markup tools. These tools permit users to highlight, strikeout, and comment on text and images. This doesn't end up here user can avail numerous properties to control annotation's appearance in the document.
-
-
-
-
-
-
-
-
-Directory | Description
---------- | -----------
-[Examples](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java/tree/master/Examples) | Contains the package of all Java examples and sample files that will help you learn how to use product features.
-## Resources
-
-+ **Website:** [www.groupdocs.com](http://www.groupdocs.com)
-+ **Product Home:** [GroupDocs.Annotation for Java](#)
-+ **Product API:** [API of GroupDocs.Annotation for Java](#)
-+ **Download:** [Download GroupDocs.Annotation for Java](#)
-+ **Documentation:** [GroupDocs.Annotation for Java Documentation](#)
-+ **Forum:** [GroupDocs.Annotation for Java Forum](#)
-+ **Blog:** [GroupDocs.Annotation for Java Blog](#)
-
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/pom.xml b/Examples/GroupDocs.Annotation.Examples.Java/pom.xml
index 25f2f4a..ac47014 100644
--- a/Examples/GroupDocs.Annotation.Examples.Java/pom.xml
+++ b/Examples/GroupDocs.Annotation.Examples.Java/pom.xml
@@ -1,70 +1,70 @@
- 4.0.0
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ 4.0.0
- GroupDocs.Annotation.Examples.Java
- GroupDocs.Annotation.Examples.Java
- 0.0.1-SNAPSHOT
- jar
+ GroupDocs.Annotation.Examples.Java
+ GroupDocs.Annotation.Examples.Java
+ 0.0.1-SNAPSHOT
+ jar
- GroupDocs.Annotation.Examples.Java
- http://maven.apache.org
+ GroupDocs.Annotation.Examples.Java
+ http://maven.apache.org
-
- UTF-8
-
+
+ UTF-8
+
-
-
- com.groupdocs
- groupdocs-annotation
- 18.10
-
-
- commons-io
- commons-io
- 2.4
-
-
- com.fasterxml.jackson.dataformat
- jackson-dataformat-xml
- 2.9.7
-
-
-
-
- GroupDocsJavaAPI
- GroupDocs Java API
- http://artifact.groupdocs.com/repo/
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- 1.3.2
-
-
-
- java
-
-
-
-
- com.groupdocs.annotation.sample.Main
- false
- maven
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
- 1.6
- 1.6
-
-
-
-
-
+
+
+ com.groupdocs
+ groupdocs-annotation
+ 19.7
+
+
+ commons-io
+ commons-io
+ 2.7
+
+
+ com.fasterxml.jackson.dataformat
+ jackson-dataformat-xml
+ 2.9.7
+
+
+
+
+ GroupDocsJavaAPI
+ GroupDocs Java API
+ http://repository.groupdocs.com/repo/
+
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.3.2
+
+
+
+ java
+
+
+
+
+ com.groupdocs.annotation.sample.Main
+ false
+ maven
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.6
+ 1.6
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/CellsAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/CellsAnnotation.java
deleted file mode 100644
index 5dd1f87..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/CellsAnnotation.java
+++ /dev/null
@@ -1,58 +0,0 @@
-
-package GroupDocs.Annotation.Examples.Java;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-
-import com.groupdocs.annotation.domain.AnnotationInfo;
-import com.groupdocs.annotation.domain.Point;
-import com.groupdocs.annotation.domain.config.AnnotationConfig;
-import com.groupdocs.annotation.handler.AnnotationImageHandler;
-
-public class CellsAnnotation {
-
- // region initialize document name
-
- /*
- * document name
- */
-
- public static String fileName = "excel.xlsx";
-
- // region Working with Annotations in Cells
-
- /*
- * add annotation in Cells
- */
-
- public static void addAnnotationInCells() {
- //ExStart:addAnnotationInCells
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream inputStream = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Add bookmark to 3rd cell in 3rd row on 1st page
- final AnnotationInfo annotationInfo = new AnnotationInfo();
- annotationInfo.setPageNumber(1);
- annotationInfo.setAnnotationPosition(new Point(3, 3));
- annotationInfo.setFieldText("Hello!");
- annotations.add(annotationInfo);
- // Export annotations to Cells document
- InputStream resultStream = annotator.exportAnnotationsToDocument(inputStream, annotations);
- System.out.println(resultStream.available());
- IOUtils.copy(resultStream,
- new FileOutputStream(Utilities.outputPath + File.separator + "cells-annotated.xlsx"));
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addAnnotationInCells
- }
-}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/DataStorage.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/DataStorage.java
deleted file mode 100644
index 527da72..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/DataStorage.java
+++ /dev/null
@@ -1,681 +0,0 @@
-package GroupDocs.Annotation.Examples.Java;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-
-import com.groupdocs.annotation.common.exception.AnnotatorException;
-import com.groupdocs.annotation.domain.AnnotationInfo;
-import com.groupdocs.annotation.domain.AnnotationReplyInfo;
-import com.groupdocs.annotation.domain.AnnotationReviewerRights;
-import com.groupdocs.annotation.domain.AnnotationSizeInfo;
-import com.groupdocs.annotation.domain.AnnotationType;
-import com.groupdocs.annotation.domain.DocumentType;
-import com.groupdocs.annotation.domain.Point;
-import com.groupdocs.annotation.domain.Rectangle;
-import com.groupdocs.annotation.domain.ReviewerInfo;
-import com.groupdocs.annotation.domain.TextFieldInfo;
-import com.groupdocs.annotation.domain.config.AnnotationConfig;
-import com.groupdocs.annotation.domain.results.AddReplyResult;
-import com.groupdocs.annotation.domain.results.CreateAnnotationResult;
-import com.groupdocs.annotation.domain.results.DeleteAnnotationResult;
-import com.groupdocs.annotation.domain.results.DeleteReplyResult;
-import com.groupdocs.annotation.domain.results.EditReplyResult;
-import com.groupdocs.annotation.domain.results.GetAnnotationResult;
-import com.groupdocs.annotation.domain.results.GetCollaboratorsResult;
-import com.groupdocs.annotation.domain.results.ListAnnotationsResult;
-import com.groupdocs.annotation.domain.results.ListRepliesResult;
-import com.groupdocs.annotation.domain.results.MoveAnnotationResult;
-import com.groupdocs.annotation.domain.results.ResizeAnnotationResult;
-import com.groupdocs.annotation.domain.results.SaveAnnotationTextResult;
-import com.groupdocs.annotation.domain.results.SetCollaboratorsResult;
-import com.groupdocs.annotation.handler.AnnotationImageHandler;
-import com.groupdocs.annotation.handler.input.IDocumentDataHandler;
-import com.groupdocs.annotation.handler.input.IUserDataHandler;
-import com.groupdocs.annotation.handler.input.dataobjects.Document;
-import com.groupdocs.annotation.handler.input.dataobjects.User;
-
-public class DataStorage {
-
- // document name
- public static String fileName = "sample.pdf";
-
- // Creates a document data object in the storage
- public static void createDocument() {
- //ExStart:createDocument
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create document data object in storage
- Document document = documentRepository.getDocument(fileName);
- long documentId = document == null ? annotator.createDocument(fileName) : document.getId();
- System.out.println("Document ID: " + documentId);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:createDocument
- }
-
- // Assign document access rights
- public static void setDocumentAccessRights() {
- //ExStart:setDocumentAccessRights
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create document data object in storage
- Document document = documentRepository.getDocument(fileName);
- long documentId = document == null ? annotator.createDocument(fileName) : document.getId();
- // Set document access rights
- annotator.setDocumentAccessRights(documentId, AnnotationReviewerRights.All);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:setDocumentAccessRights
- }
-
- // Maps annotations and creates dcocument data object in the storage
- public static GetAnnotationResult createAndGetAnnotations() {
- //ExStart:createAndGetAnnotations
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create document data object in storage
- Document document = documentRepository.getDocument(fileName);
- long documentId = document == null ? annotator.createDocument(fileName) : document.getId();
- // Create annotation object
- AnnotationInfo pointAnnotation = new AnnotationInfo();
- pointAnnotation.setAnnotationPosition(new Point(852.0, 81.0));
- pointAnnotation.setBox(new Rectangle(212f, 81f, 142f, 0.0f));
- pointAnnotation.setType(AnnotationType.Point);
- pointAnnotation.setPageNumber(0);
- pointAnnotation.setCreatorName("Anonym A.");
- pointAnnotation.setDocumentGuid(documentId);
- // Add annotation to storage
- CreateAnnotationResult createPointAnnotationResult = annotator.createAnnotation(pointAnnotation);
- // Get annotation from storage
- GetAnnotationResult result = annotator.getAnnotation(createPointAnnotationResult.getGuid());
- return result;
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- return null;
- }
- //ExEnd:createAndGetAnnotations
- }
-
- // Gets annotations from the storage file
- public static void getAllAnnotations() {
- //ExStart:getAllAnnotations
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- Document document = documentRepository.getDocument(fileName);
- long documentId = document == null ? annotator.createDocument(fileName) : document.getId();
- // Create annotation object
- AnnotationInfo pointAnnotation = new AnnotationInfo();
- pointAnnotation.setAnnotationPosition(new Point(852.0, 81.0));
- pointAnnotation.setBox(new Rectangle(212f, 81f, 142f, 0.0f));
- pointAnnotation.setType(AnnotationType.Point);
- pointAnnotation.setPageNumber(0);
- pointAnnotation.setCreatorName("Anonym A.");
- pointAnnotation.setDocumentGuid(documentId);
- // Add annotation to storage
- CreateAnnotationResult createPointAnnotationResult = annotator.createAnnotation(pointAnnotation);
- System.out.println(createPointAnnotationResult);
- // Get all annotations from storage
- ListAnnotationsResult listAnnotationsResult = annotator.getAnnotations(documentId);
- System.out.println(listAnnotationsResult);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:getAllAnnotations
- }
-
- // Resize annotation result
- public static void resizeAnnotationResult() {
- //ExStart:resizeAnnotationResult
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create document data object in storage.
- Document document = documentRepository.getDocument(fileName);
- long documentId = document == null ? annotator.createDocument(fileName) : document.getId();
- // Create annotation object
- AnnotationInfo areaAnnotation = new AnnotationInfo();
- areaAnnotation.setAnnotationPosition(new Point(852.0, 271.7));
- areaAnnotation.setBackgroundColor(3355443);
- areaAnnotation.setBox(new Rectangle(466f, 271f, 69f, 62f));
- areaAnnotation.setPageNumber(0);
- areaAnnotation.setPenColor(3355443);
- areaAnnotation.setType(AnnotationType.Area);
- areaAnnotation.setCreatorName("Anonym A.");
- areaAnnotation.setDocumentGuid(documentId);
- // Add annotation to storage
- CreateAnnotationResult createAreaAnnotationResult = annotator.createAnnotation(areaAnnotation);
- // Resize annotation
- final AnnotationSizeInfo annotationSizeInfo = new AnnotationSizeInfo();
- annotationSizeInfo.setHeight(80);
- annotationSizeInfo.setWidth(60);
- ResizeAnnotationResult resizeResult = annotator.resizeAnnotation(createAreaAnnotationResult.getId(),
- annotationSizeInfo);
- System.out.println(resizeResult);
- // Check data
- GetAnnotationResult resizedAnnotation = annotator.getAnnotation(createAreaAnnotationResult.getGuid());
- System.out.println(resizedAnnotation);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:resizeAnnotationResult
- }
-
- // Moves annotation marker
- public static void moveAnnotationResult() {
- //ExStart:moveAnnotationResult
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create document data object in storage.
- Document document = documentRepository.getDocument(fileName);
- long documentId = document == null ? annotator.createDocument(fileName) : document.getId();
- // Create annotation object
- AnnotationInfo areaAnnotation = new AnnotationInfo();
- areaAnnotation.setAnnotationPosition(new Point(852.0, 271.7));
- areaAnnotation.setBackgroundColor(3355443);
- areaAnnotation.setBox(new Rectangle(466f, 271f, 69f, 62f));
- areaAnnotation.setPageNumber(0);
- areaAnnotation.setPenColor(3355443);
- areaAnnotation.setType(AnnotationType.Area);
- areaAnnotation.setCreatorName("Anonym A.");
- areaAnnotation.setDocumentGuid(documentId);
- // Add annotation to storage
- CreateAnnotationResult createAreaAnnotationResult = annotator.createAnnotation(areaAnnotation);
- // Move annotation marker
- MoveAnnotationResult moveAnnotationResult = annotator.moveAnnotationMarker(
- createAreaAnnotationResult.getId(), new Point(200, 200), /* NewPageNumber */ 1);
- System.out.println(moveAnnotationResult);
- System.out.println(moveAnnotationResult);
- // Check data
- GetAnnotationResult resizedAnnotation = annotator.getAnnotation(createAreaAnnotationResult.getGuid());
- System.out.println(resizedAnnotation);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:moveAnnotationResult
- }
-
- // Sets background color of annotation
- public static void setBackgroundColor() {
- //ExStart:setBackgroundColor
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create document data object in storage.
- Document document = documentRepository.getDocument(fileName);
- long documentId = document == null ? annotator.createDocument(fileName) : document.getId();
- // Create annotation object
- AnnotationInfo areaAnnotation = new AnnotationInfo();
- areaAnnotation.setAnnotationPosition(new Point(852.0, 271.7));
- areaAnnotation.setBackgroundColor(3355443);
- areaAnnotation.setBox(new Rectangle(466f, 271f, 69f, 62f));
- areaAnnotation.setPageNumber(0);
- areaAnnotation.setPenColor(3355443);
- areaAnnotation.setType(AnnotationType.Area);
- areaAnnotation.setCreatorName("Anonym A.");
- areaAnnotation.setDocumentGuid(documentId);
- // Add annotation to storage
- CreateAnnotationResult createAreaAnnotationResult = annotator.createAnnotation(areaAnnotation);
- // Set background color of annotation
- SaveAnnotationTextResult setBackgroundColorResult = annotator
- .setAnnotationBackgroundColor(createAreaAnnotationResult.getId(), 16711680);
- System.out.println(setBackgroundColorResult);
- // Check data
- GetAnnotationResult resizedAnnotation = annotator.getAnnotation(createAreaAnnotationResult.getGuid());
- System.out.println(resizedAnnotation);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:setBackgroundColor
- }
-
- // Updates the text in the annotation
- public static void editTextFieldAnnotations() {
- //ExStart:editTextFieldAnnotations
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create document data object in storage.
- Document document = documentRepository.getDocument(fileName);
- long documentId = document == null ? annotator.createDocument(fileName) : document.getId();
- // Create annotation object
- AnnotationInfo textFieldAnnotation = new AnnotationInfo();
- textFieldAnnotation.setAnnotationPosition(new Point(852.0, 201.0));
- textFieldAnnotation.setFieldText("text in the box");
- textFieldAnnotation.setFontFamily("Arial");
- textFieldAnnotation.setFontSize(10);
- textFieldAnnotation.setBox(new Rectangle(66f, 201f, 64f, 37f));
- textFieldAnnotation.setPageNumber(0);
- textFieldAnnotation.setType(AnnotationType.TextField);
- textFieldAnnotation.setCreatorName("Anonym A.");
- textFieldAnnotation.setDocumentGuid(documentId);
- final CreateAnnotationResult createTextFieldAnnotationResult = annotator
- .createAnnotation(textFieldAnnotation);
- // Update text in the annotation
- final TextFieldInfo textFieldInfo = new TextFieldInfo();
- textFieldInfo.setFieldText("new text");
- textFieldInfo.setFontFamily("Colibri");
- textFieldInfo.setFontSize(12);
- SaveAnnotationTextResult saveTextFieldResult = annotator
- .saveTextField(createTextFieldAnnotationResult.getId(), textFieldInfo);
- System.out.println(saveTextFieldResult);
- // Set text field color
- SaveAnnotationTextResult saveTextFieldColorResult = annotator
- .setTextFieldColor(createTextFieldAnnotationResult.getId(), 16753920);
- System.out.println(saveTextFieldColorResult);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:editTextFieldAnnotations
- }
-
- // Removes annotations
- public static void removeAnnotation() {
- //ExStart:removeAnnotation
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create document data object in storage.
- Document document = documentRepository.getDocument(fileName);
- long documentId = document == null ? annotator.createDocument(fileName) : document.getId();
- // Create annotation object
- AnnotationInfo pointAnnotation = new AnnotationInfo();
- pointAnnotation.setAnnotationPosition(new Point(852.0, 81.0));
- pointAnnotation.setBox(new Rectangle(212f, 81f, 142f, 0.0f));
- pointAnnotation.setType(AnnotationType.Point);
- pointAnnotation.setPageNumber(0);
- pointAnnotation.setCreatorName("Anonym A.");
- pointAnnotation.setDocumentGuid(documentId);
- // Add annotation to storage
- CreateAnnotationResult createPointAnnotationResult = annotator.createAnnotation(pointAnnotation);
- // Get all annotations from storage
- ListAnnotationsResult listAnnotationsResult = annotator.getAnnotations(documentId);
- // Get annotation
- GetAnnotationResult annotation = annotator
- .getAnnotation(listAnnotationsResult.getAnnotations()[0].getGuid());
- // Delete annotation
- DeleteAnnotationResult deleteAnnotationResult = annotator.deleteAnnotation(annotation.getId());
- // Delete all annotations
- annotator.deleteAnnotations(documentId);
- System.out.println(deleteAnnotationResult);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:removeAnnotation
- }
-
- // Adds reply to the annotation, edits reply, creates child reply
- public static void addAnnotationReply() {
- //ExStart:addAnnotationReply
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create document data object in storage
- final Document document = documentRepository.getDocument(fileName);
- long documentId = document == null ? annotator.createDocument(fileName) : document.getId();
- // Create annotation object
- AnnotationInfo pointAnnotation = new AnnotationInfo();
- pointAnnotation.setAnnotationPosition(new Point(852.0, 81.0));
- pointAnnotation.setBox(new Rectangle(212f, 81f, 142f, 0.0f));
- pointAnnotation.setType(AnnotationType.Point);
- pointAnnotation.setPageNumber(0);
- pointAnnotation.setCreatorName("Anonym A.");
- pointAnnotation.setDocumentGuid(documentId);
- // Add annotation to storage
- CreateAnnotationResult createPointAnnotationResult = annotator.createAnnotation(pointAnnotation);
- // Add simple reply to created annotation
- AddReplyResult addSimpleReplyResult = annotator.createAnnotationReply(createPointAnnotationResult.getId(),
- "first question");
- // Edit created reply
- EditReplyResult editReplyResult = annotator.editAnnotationReply(addSimpleReplyResult.getReplyGuid(),
- "changed question");
- System.out.println(editReplyResult);
- // Create child reply. This reply will be linked to previously
- // created reply.
- AddReplyResult addChildReplyResult = annotator.createAnnotationReply(createPointAnnotationResult.getId(),
- "answer", addSimpleReplyResult.getReplyGuid());
- System.out.println(addChildReplyResult);
- // Delete annotation reply by guid
- DeleteReplyResult deleteReplyResult = annotator.deleteAnnotationReply(addChildReplyResult.getReplyGuid());
- System.out.println(deleteReplyResult);
- // Delete all replies from annotation
- annotator.deleteAnnotationReplies(createPointAnnotationResult.getId());
- // List of replies after deleting all replies
- ListRepliesResult listRepliesResultAfterDeleteAll = annotator
- .listAnnotationReplies(createPointAnnotationResult.getId());
- System.out.println(listRepliesResultAfterDeleteAll);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addAnnotationReply
- }
-
- // Adds document collaborator
- public static void addCollaborator() {
- //ExStart:addCollaborator
- try {
- // Create instance of the annotation handler
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IUserDataHandler userRepository = annotator.getUserDataHandler();
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create owner.
- User owner = userRepository.getUserByEmail("john@doe.com");
- if (owner == null) {
- final User user = new User();
- user.setFirstName("John");
- user.setLastName("Doe");
- user.setEmail("john@doe.com");
- userRepository.add(user);
- owner = userRepository.getUserByEmail("john@doe.com");
- }
- // Create document data object in storage
- Document document = documentRepository.getDocument(fileName);
- if (document != null && document.getOwnerId() != owner.getId()) {
- documentRepository.remove(document);
- document = null;
- }
- long documentId = document == null ? annotator.createDocument(fileName, DocumentType.Pdf, owner.getId())
- : document.getId();
- // Create reviewer.
- ReviewerInfo reviewerInfo = new ReviewerInfo();
- reviewerInfo.setPrimaryEmail("judy@doe.com");
- reviewerInfo.setFirstName("Judy");
- reviewerInfo.setLastName("Doe");
- reviewerInfo.setAccessRights(AnnotationReviewerRights.All);
- // Add collaborator to the document. If user with UserName equals to
- // reviewers PrimaryEmail is absent it will be created.
- SetCollaboratorsResult addCollaboratorResult = annotator.addCollaborator(documentId, reviewerInfo);
- System.out.println(addCollaboratorResult);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addCollaborator
- }
-
- // Gets document collaborator
- public static void getCollaborator() {
- //ExStart:getCollaborator
- try {
- // Create instance of the annotation handler
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IUserDataHandler userRepository = annotator.getUserDataHandler();
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create owner.
- User owner = userRepository.getUserByEmail("john@doe.com");
- if (owner == null) {
- final User user = new User();
- user.setFirstName("John");
- user.setLastName("Doe");
- user.setEmail("john@doe.com");
- userRepository.add(user);
- owner = userRepository.getUserByEmail("john@doe.com");
- }
- // Create document data object in storage
- Document document = documentRepository.getDocument(fileName);
- if (document != null && document.getOwnerId() != owner.getId()) {
- documentRepository.remove(document);
- document = null;
- }
- long documentId = document == null ? annotator.createDocument(fileName, DocumentType.Pdf, owner.getId())
- : document.getId();
- // Create reviewer.
- ReviewerInfo reviewerInfo = new ReviewerInfo();
- reviewerInfo.setPrimaryEmail("judy@doe.com");
- reviewerInfo.setFirstName("Judy");
- reviewerInfo.setLastName("Doe");
- reviewerInfo.setAccessRights(AnnotationReviewerRights.All);
- // Get document collaborators
- GetCollaboratorsResult getCollaboratorsResult = annotator.getCollaborators(documentId);
- System.out.println(getCollaboratorsResult);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:getCollaborator
- }
-
- // Updates document collaborator
- public static void updateCollaborator() {
- //ExStart:updateCollaborator
- try {
- // Create instance of the annotation handler
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IUserDataHandler userRepository = annotator.getUserDataHandler();
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create owner.
- User owner = userRepository.getUserByEmail("john@doe.com");
- if (owner == null) {
- final User user = new User();
- user.setFirstName("John");
- user.setLastName("Doe");
- user.setEmail("john@doe.com");
- userRepository.add(user);
- owner = userRepository.getUserByEmail("john@doe.com");
- }
- // Create document data object in storage
- Document document = documentRepository.getDocument(fileName);
- if (document != null && document.getOwnerId() != owner.getId()) {
- documentRepository.remove(document);
- document = null;
- }
- long documentId = document == null ? annotator.createDocument(fileName, DocumentType.Pdf, owner.getId())
- : document.getId();
- // Create reviewer.
- ReviewerInfo reviewerInfo = new ReviewerInfo();
- reviewerInfo.setPrimaryEmail("judy@doe.com");
- reviewerInfo.setFirstName("Judy");
- reviewerInfo.setLastName("Doe");
- reviewerInfo.setAccessRights(AnnotationReviewerRights.All);
- // Update collaborator. Only color and access rights will be
- // updated.
- reviewerInfo.setColor(3355443L);
- SetCollaboratorsResult updateCollaboratorResult = annotator.updateCollaborator(documentId, reviewerInfo);
- System.out.println(updateCollaboratorResult);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:updateCollaborator
- }
-
- // Deletes document collaborator
- public static void deleteCollaborator() {
- //ExStart:deleteCollaborator
- try {
- // Create instance of the annotation handler
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IUserDataHandler userRepository = annotator.getUserDataHandler();
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create owner.
- User owner = userRepository.getUserByEmail("john@doe.com");
- if (owner == null) {
- final User user = new User();
- user.setFirstName("John");
- user.setLastName("Doe");
- user.setEmail("john@doe.com");
- userRepository.add(user);
- owner = userRepository.getUserByEmail("john@doe.com");
- }
- // Create document data object in storage
- Document document = documentRepository.getDocument(fileName);
- if (document != null && document.getOwnerId() != owner.getId()) {
- documentRepository.remove(document);
- document = null;
- }
- long documentId = document == null ? annotator.createDocument(fileName, DocumentType.Pdf, owner.getId())
- : document.getId();
- // Create reviewer.
- ReviewerInfo reviewerInfo = new ReviewerInfo();
- reviewerInfo.setPrimaryEmail("judy@doe.com");
- reviewerInfo.setFirstName("Judy");
- reviewerInfo.setLastName("Doe");
- reviewerInfo.setAccessRights(AnnotationReviewerRights.All);
- // Delete collaborator
- SetCollaboratorsResult deleteCollaboratorResult = annotator.deleteCollaborator(documentId,
- reviewerInfo.getPrimaryEmail());
- System.out.println(deleteCollaboratorResult);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:deleteCollaborator
- }
-
- // Manages user rights
- public static void managesCollaboratorRights() {
- //ExStart:managesCollaboratorRights
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IUserDataHandler userRepository = annotator.getUserDataHandler();
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
- // Create owner.
- User johnOwner = userRepository.getUserByEmail("john@doe.com");
- if (johnOwner == null) {
- final User user = new User();
- user.setFirstName("John");
- user.setLastName("Doe");
- user.setEmail("john@doe.com");
- userRepository.add(user);
- johnOwner = userRepository.getUserByEmail("john@doe.com");
- }
- // Create document data object in storage
- Document document = documentRepository.getDocument(fileName);
- long documentId = document == null ? annotator.createDocument(fileName, DocumentType.Pdf, johnOwner.getId())
- : document.getId();
- // Create reviewer.
- ReviewerInfo reviewerInfo = new ReviewerInfo();
- reviewerInfo.setPrimaryEmail("judy@doe.com");
- reviewerInfo.setFirstName("Judy");
- reviewerInfo.setLastName("Doe");
- reviewerInfo.setAccessRights(AnnotationReviewerRights.CanView);
- // Add collaborator to the document. If user with UserName equals
- // to reviewers PrimaryEmail is absent it will be created.
- SetCollaboratorsResult addCollaboratorResult = annotator.addCollaborator(documentId, reviewerInfo);
- // Get document collaborators
- GetCollaboratorsResult getCollaboratorsResult = annotator.getCollaborators(documentId);
- User judy = userRepository.getUserByEmail("judy@doe.com");
- // Create annotation object
- AnnotationInfo pointAnnotation = new AnnotationInfo();
- pointAnnotation.setAnnotationPosition(new Point(852.0, 81.0));
- pointAnnotation.setBox(new Rectangle(212f, 81f, 142f, 0.0f));
- pointAnnotation.setType(AnnotationType.Point);
- pointAnnotation.setPageNumber(0);
- pointAnnotation.setCreatorName("Anonym A.");
- // John try to add annotations
- CreateAnnotationResult johnResult = annotator.createAnnotation(pointAnnotation, documentId,
- johnOwner.getId());
- System.out.println(johnResult);
- // Judy try to add annotations
- try {
- CreateAnnotationResult judyResult = annotator.createAnnotation(pointAnnotation, documentId,
- judy.getId());
- System.out.println(judyResult);
- } catch (AnnotatorException e) {
- System.out.println(e.getMessage());
- }
- // Allow Judy create annotations.
- reviewerInfo.setAccessRights(AnnotationReviewerRights.CanAnnotate);
- SetCollaboratorsResult updateCollaboratorResult = annotator.updateCollaborator(documentId, reviewerInfo);
- System.out.println(updateCollaboratorResult);
- // Judy try to add annotations
- CreateAnnotationResult judyResultCanAnnotate = annotator.createAnnotation(pointAnnotation, documentId,
- judy.getId());
- System.out.println(judyResultCanAnnotate);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:managesCollaboratorRights
- }
-
- // Export Annotations
- public static void exportAnnotations() {
- //ExStart:exportAnnotations
- try {
- // Create instance of annotator.
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- // Get stream of document(in code sample document previously was
- // added to embedded
- // resources of the assembly. You can get stream of the document in
- // other ways.)
- InputStream manifestResourceStream = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Area annotation with 2 replies
- AnnotationInfo areaAnnnotation = new AnnotationInfo();
- areaAnnnotation.setAnnotationPosition(new Point(852.0, 59.0));
- AnnotationReplyInfo[] annotationReplyInfos = new AnnotationReplyInfo[2];
- annotationReplyInfos[0] = new AnnotationReplyInfo();
- annotationReplyInfos[0].setMessage("Hello!");
- annotationReplyInfos[0].setRepliedOn(Calendar.getInstance().getTime());
- annotationReplyInfos[0].setUserEmail("John");
- annotationReplyInfos[1] = new AnnotationReplyInfo();
- annotationReplyInfos[1].setMessage("Hi!");
- annotationReplyInfos[1].setRepliedOn(Calendar.getInstance().getTime());
- annotationReplyInfos[1].setUserEmail("Judy");
- areaAnnnotation.setReplies(annotationReplyInfos);
- areaAnnnotation.setBackgroundColor(11111111);
- areaAnnnotation.setBox(new Rectangle(300f, 200f, 88f, 37f));
- areaAnnnotation.setPageNumber(0);
- areaAnnnotation.setPenColor(2222222);
- areaAnnnotation.setPenStyle((byte) 1);
- areaAnnnotation.setPenWidth((byte) 1);
- areaAnnnotation.setType(AnnotationType.Area);
- areaAnnnotation.setCreatorName("Anonym A.");
- annotations.add(areaAnnnotation);
- // Add annotation to the document. Annotator will return stream with
- // annotated document.
- InputStream stream = annotator.exportAnnotationsToDocument(manifestResourceStream, annotations,
- DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "document-annotated.pdf");
- IOUtils.copy(stream, fileStream);
- System.out.println("Document exported!");
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:exportAnnotations
- }
-}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/EmailAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/EmailAnnotation.java
deleted file mode 100644
index 89ac389..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/EmailAnnotation.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package GroupDocs.Annotation.Examples.Java;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-
-import com.groupdocs.annotation.domain.AnnotationInfo;
-import com.groupdocs.annotation.domain.AnnotationType;
-import com.groupdocs.annotation.domain.DocumentType;
-import com.groupdocs.annotation.domain.Rectangle;
-import com.groupdocs.annotation.domain.config.AnnotationConfig;
-import com.groupdocs.annotation.handler.AnnotationImageHandler;
-
-public class EmailAnnotation {
- public static void differentAnnotationsForEmail(String fileName) throws Throwable, Throwable{
- //ExStart:differentAnnotationsForEmail
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- //there can be also documents of Emlx Msg formats
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName); //"../../ClearEmailDocument.eml"
-
- List annotations = new ArrayList();
-
- AnnotationInfo textAnnotation = new AnnotationInfo();
- textAnnotation.setPageNumber(0);
- textAnnotation.setSvgPath("[{\"x\":186.698,\"y\":706.196},{\"x\":318.41201,\"y\":706.196},{\"x\":186.698,\"y\":697.196},{\"x\":318.41201,\"y\":697.196}]");
- textAnnotation.setType(AnnotationType.Text);
-
- AnnotationInfo areaAnnnotation = new AnnotationInfo();
- areaAnnnotation.setBackgroundColor(11111111);
- areaAnnnotation.setBox(new Rectangle(87.9f, 276.5f, 435.7f, 87f));
- areaAnnnotation.setPageNumber(0);
- areaAnnnotation.setType(AnnotationType.Area);
-
- AnnotationInfo strikeoutAnnotation = new AnnotationInfo();
- strikeoutAnnotation.setBox(new Rectangle(87.9f, 276.5f, 435.7f, 87f));
- strikeoutAnnotation.setPageNumber(0);
- strikeoutAnnotation.setPenColor(1201033);
- strikeoutAnnotation.setSvgPath("[{\"x\":208.392,\"y\":313.088},{\"x\":519.659,\"y\":313.088},{\"x\":208.392,\"y\":304.088},{\"x\":519.659,\"y\":304.088}]");
- strikeoutAnnotation.setType(AnnotationType.TextStrikeout);
-
- AnnotationInfo textFieldAnnotation = new AnnotationInfo();
- textFieldAnnotation.setFieldText("text in the box");
- textFieldAnnotation.setFontFamily("Arial");
- textFieldAnnotation.setFontSize(10);
- textFieldAnnotation.setBox(new Rectangle(92f, 73f, 106f, 45f));
- textFieldAnnotation.setPageNumber(0);
- textFieldAnnotation.setType(AnnotationType.TextField);
-
- AnnotationInfo textReplacementAnnotation = new AnnotationInfo();
- textReplacementAnnotation.setFieldText(" \"REPLACED TEXT\" ");
- textReplacementAnnotation.setFontSize(10);
- textReplacementAnnotation.setSvgPath("[{\"x\":251.224,\"y\":637.20401},{\"x\":327.89,\"y\":637.20401},{\"x\":251.224,\"y\":628.20401},{\"x\":327.89,\"y\":628.20401}]");
- textReplacementAnnotation.setPageNumber(0);
- textReplacementAnnotation.setType(AnnotationType.TextReplacement);
-
- AnnotationInfo arrowAnnotation = new AnnotationInfo();
- arrowAnnotation.setBox(new Rectangle(479f, 218f, -261f, -89f));
- arrowAnnotation.setPageNumber(0);
- arrowAnnotation.setType(AnnotationType.Arrow);
-
- AnnotationInfo textRedactionAnnotation = new AnnotationInfo();
- textRedactionAnnotation.setPageNumber(0);
- textRedactionAnnotation.setSvgPath("[{\"x\":72,\"y\":676.07},{\"x\":196.427,\"y\":676.074},{\"x\":72,\"y\":662.674},{\"x\":196.427,\"y\":662.674}]");
- textRedactionAnnotation.setType(AnnotationType.TextRedaction);
-
- AnnotationInfo resourceRedactionAnnotation = new AnnotationInfo();
- resourceRedactionAnnotation.setBox(new Rectangle(69f, 337f, 449f, 118f));
- resourceRedactionAnnotation.setPageNumber(0);
- resourceRedactionAnnotation.setType(AnnotationType.ResourcesRedaction);
-
- AnnotationInfo underlineAnnotation = new AnnotationInfo();
- underlineAnnotation.setPageNumber(0);
- underlineAnnotation.setSvgPath("[{\"x\":415.17499,\"y\":628.874},{\"x\":511.85101,\"y\":628.874},{\"x\":415.17499,\"y\":619.874},{\"x\":511.85101,\"y\":619.874}]");
- underlineAnnotation.setType(AnnotationType.TextUnderline);
-
- annotations.add(textAnnotation);
- annotations.add(areaAnnnotation);
- annotations.add(strikeoutAnnotation);
- annotations.add(textFieldAnnotation);
- annotations.add(textReplacementAnnotation);
- annotations.add(arrowAnnotation);
- annotations.add(textRedactionAnnotation);
- annotations.add(resourceRedactionAnnotation);
- annotations.add(underlineAnnotation);
-
- // Add annotation to the document
- 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);
- }
- //ExEnd:differentAnnotationsForEmail
- }
-}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/HtmlAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/HtmlAnnotation.java
deleted file mode 100644
index 52aaf45..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/HtmlAnnotation.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package GroupDocs.Annotation.Examples.Java;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-
-import com.groupdocs.annotation.domain.AnnotationInfo;
-import com.groupdocs.annotation.domain.AnnotationType;
-import com.groupdocs.annotation.domain.DocumentType;
-import com.groupdocs.annotation.domain.Rectangle;
-import com.groupdocs.annotation.domain.config.AnnotationConfig;
-import com.groupdocs.annotation.handler.AnnotationImageHandler;
-
-public class HtmlAnnotation {
- public static void createAnnotationForHtml(String fileName) throws Throwable, Throwable{
- //ExStart:createAnnotationForHtml
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- //there can be also documents of Emlx Msg formats
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName); //"../../ClearEmailDocument.eml"
-
- List annotations = new ArrayList();
-
- AnnotationInfo textAnnotation = new AnnotationInfo();
- textAnnotation.setPageNumber(0);
- textAnnotation.setSvgPath("[{\"x\":186.698,\"y\":706.196},{\"x\":318.41201,\"y\":706.196},{\"x\":186.698,\"y\":697.196},{\"x\":318.41201,\"y\":697.196}]");
- textAnnotation.setType(AnnotationType.Text);
-
- AnnotationInfo areaAnnnotation = new AnnotationInfo();
- areaAnnnotation.setBackgroundColor(11111111);
- areaAnnnotation.setBox(new Rectangle(87.9f, 276.5f, 435.7f, 87f));
- areaAnnnotation.setPageNumber(0);
- areaAnnnotation.setType(AnnotationType.Area);
-
- AnnotationInfo strikeoutAnnotation = new AnnotationInfo();
- strikeoutAnnotation.setBox(new Rectangle(87.9f, 276.5f, 435.7f, 87f));
- strikeoutAnnotation.setPageNumber(0);
- strikeoutAnnotation.setPenColor(1201033);
- strikeoutAnnotation.setSvgPath("[{\"x\":208.392,\"y\":313.088},{\"x\":519.659,\"y\":313.088},{\"x\":208.392,\"y\":304.088},{\"x\":519.659,\"y\":304.088}]");
- strikeoutAnnotation.setType(AnnotationType.TextStrikeout);
-
- AnnotationInfo textFieldAnnotation = new AnnotationInfo();
- textFieldAnnotation.setFieldText("text in the box");
- textFieldAnnotation.setFontFamily("Arial");
- textFieldAnnotation.setFontSize(10);
- textFieldAnnotation.setBox(new Rectangle(92f, 73f, 106f, 45f));
- textFieldAnnotation.setPageNumber(1);
- textFieldAnnotation.setType(AnnotationType.TextField);
-
- AnnotationInfo textReplacementAnnotation = new AnnotationInfo();
- textReplacementAnnotation.setFieldText(" \"REPLACED TEXT\" ");
- textReplacementAnnotation.setFontSize(10);
- textReplacementAnnotation.setSvgPath("[{\"x\":251.224,\"y\":637.20401},{\"x\":327.89,\"y\":637.20401},{\"x\":251.224,\"y\":628.20401},{\"x\":327.89,\"y\":628.20401}]");
- textReplacementAnnotation.setPageNumber(0);
- textReplacementAnnotation.setType(AnnotationType.TextReplacement);
-
- AnnotationInfo arrowAnnotation = new AnnotationInfo();
- arrowAnnotation.setBox(new Rectangle(479f, 218f, -261f, -89f));
- arrowAnnotation.setPageNumber(0);
- arrowAnnotation.setType(AnnotationType.Arrow);
-
- AnnotationInfo textRedactionAnnotation = new AnnotationInfo();
- textRedactionAnnotation.setPageNumber(1);
- textRedactionAnnotation.setSvgPath("[{\"x\":72,\"y\":676.07},{\"x\":196.427,\"y\":676.074},{\"x\":72,\"y\":662.674},{\"x\":196.427,\"y\":662.674}]");
- textRedactionAnnotation.setType(AnnotationType.TextRedaction);
-
- AnnotationInfo resourceRedactionAnnotation = new AnnotationInfo();
- resourceRedactionAnnotation.setBox(new Rectangle(69f, 337f, 449f, 118f));
- resourceRedactionAnnotation.setPageNumber(1);
- resourceRedactionAnnotation.setType(AnnotationType.ResourcesRedaction);
-
- AnnotationInfo underlineAnnotation = new AnnotationInfo();
- underlineAnnotation.setPageNumber(1);
- underlineAnnotation.setSvgPath("[{\"x\":415.17499,\"y\":628.874},{\"x\":511.85101,\"y\":628.874},{\"x\":415.17499,\"y\":619.874},{\"x\":511.85101,\"y\":619.874}]");
- underlineAnnotation.setType(AnnotationType.TextUnderline);
-
- annotations.add(textAnnotation);
- annotations.add(areaAnnnotation);
- annotations.add(strikeoutAnnotation);
- annotations.add(textFieldAnnotation);
- annotations.add(textReplacementAnnotation);
- annotations.add(arrowAnnotation);
- annotations.add(textRedactionAnnotation);
- annotations.add(resourceRedactionAnnotation);
- annotations.add(underlineAnnotation);
-
- // Add annotation to the document
- 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);
- }
- //ExEnd:createAnnotationForHtml
- }
-}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/ImagesAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/ImagesAnnotation.java
deleted file mode 100644
index 862ef87..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/ImagesAnnotation.java
+++ /dev/null
@@ -1,355 +0,0 @@
-package GroupDocs.Annotation.Examples.Java;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-
-import com.groupdocs.annotation.domain.AnnotationInfo;
-import com.groupdocs.annotation.domain.AnnotationType;
-import com.groupdocs.annotation.domain.DocumentType;
-import com.groupdocs.annotation.domain.PageData;
-import com.groupdocs.annotation.domain.Rectangle;
-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.image.PageImage;
-import com.groupdocs.annotation.domain.options.ImageOptions;
-import com.groupdocs.annotation.handler.AnnotationImageHandler;
-
-public class ImagesAnnotation {
- // ExStart:ImagesAnnotation
- /*
- * document name
- */
- // From version 17.1.0 you can work with images of EMF/WMF, CAD-files (DWG),
- // DICOM, DjVu, PNG, JPG, TIFF, BMP and GIF(static without animation) format
- // images
- public static void differentAnnotationsForImages(String fileName) throws Throwable {
- // ExStart:differentAnnotationsForImages
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
-
- FileInputStream cleanPresentation = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- ArrayList annotations;
- annotations = new ArrayList();
-
- AnnotationInfo textAnnotation = new AnnotationInfo();
- textAnnotation.setBox(new Rectangle(50, 510.9f, 454.73f, 29.08f));
- textAnnotation.setPageNumber(0);
- textAnnotation.setSvgPath(
- "[{\"x\":200,\"y\":520.92},{\"x\":454.73,\"y\":520.92},{\"x\":200,\"y\":539.98},{\"x\":454.73,\"y\":539.98}]");
- textAnnotation.setType(AnnotationType.Text);
- textAnnotation.setCreatorName("Anonym A.");
-
- AnnotationInfo textRedactionAnnotation = new AnnotationInfo();
- textRedactionAnnotation.setBox(new Rectangle(50, 510.9f, 454.73f, 29.08f));
- textRedactionAnnotation.setPageNumber(0);
- textRedactionAnnotation.setSvgPath(
- "[{\"x\":200,\"y\":545.92},{\"x\":454.73,\"y\":545.92},{\"x\":200,\"y\":564.98},{\"x\":454.73,\"y\":564.98}]");
- textRedactionAnnotation.setType(AnnotationType.TextRedaction);
- textRedactionAnnotation.setCreatorName("Anonym A.");
-
- AnnotationInfo strikeoutAnnotation = new AnnotationInfo();
- strikeoutAnnotation.setBox(new Rectangle(0, 510.92f, 454.73f, 29.08f));
- strikeoutAnnotation.setPageNumber(0);
- strikeoutAnnotation.setSvgPath(
- "[{\"x\":120,\"y\":520.92},{\"x\":454.73,\"y\":520.92},{\"x\":120,\"y\":539.98},{\"x\":454.73,\"y\":539.98}]");
- strikeoutAnnotation.setType(AnnotationType.TextStrikeout);
- strikeoutAnnotation.setCreatorName("Anonym A.");
-
- AnnotationInfo underlineAnnotation = new AnnotationInfo();
- underlineAnnotation.setBox(new Rectangle(0, 510.92f, 454.73f, 29.08f));
- underlineAnnotation.setPageNumber(0);
- underlineAnnotation.setSvgPath(
- "[{\"x\":120,\"y\":520.92},{\"x\":454.73,\"y\":520.92},{\"x\":120,\"y\":539.98},{\"x\":454.73,\"y\":539.98}]");
- underlineAnnotation.setType(AnnotationType.TextUnderline);
- underlineAnnotation.setCreatorName("Anonym A.");
-
- AnnotationInfo pointAnnotation = new AnnotationInfo();
- pointAnnotation.setPageNumber(0);
- pointAnnotation.setType(AnnotationType.Point);
- pointAnnotation.setBox(new Rectangle(100, 100, 0, 0));
- pointAnnotation.setFieldText("Hello!");
- pointAnnotation.setCreatorName("John");
-
- AnnotationInfo areaAnnotation = new AnnotationInfo();
- areaAnnotation.setCreatedOn(new Date());
- areaAnnotation.setType(AnnotationType.Area);
- areaAnnotation.setPageNumber(0);
- areaAnnotation.setBox(new Rectangle(200, 72.7f, 50, 50));
- areaAnnotation.setBackgroundColor(-15988609);
-
- AnnotationInfo polylineAnnotation = new AnnotationInfo();
- polylineAnnotation.setType(AnnotationType.Polyline);
- polylineAnnotation.setCreatedOn(new Date());
- polylineAnnotation.setBox(new Rectangle((float) 250.82807922363281, (float) 35.632957458496094,
- (float) 102.70676422119141, (float) 12.576337814331055));
- polylineAnnotation.setPageNumber(0);
- polylineAnnotation.setPenColor(65015);
- polylineAnnotation.setSvgPath(
- "M250.8280751173709,48.209295774647885l0.6986854460093896,0l0.6986854460093896, -1.3973708920187793l0.6986854460093896,"
- + "0l0.6986854460093896,-1.3973708920187793l1.3973708920187793, -0.6986854460093896l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0l2.096056338028169,"
- + "-1.3973708920187793l3.493427230046948,-1.3973708920187793l0.6986854460093896,-0.6986854460093896l1.3973708920187793,"
- + "-1.3973708920187793l0.6986854460093896,0l1.3973708920187793,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,"
- + "-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,0l0,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,"
- + "0l1.3973708920187793,0l0,-0.6986854460093896l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,"
- + "0l0.6986854460093896,0l2.096056338028169,-0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,"
- + "0l1.3973708920187793,0l1.3973708920187793,0l1.3973708920187793,0l2.096056338028169,0l5.589483568075117,0l1.3973708920187793,"
- + "0l2.096056338028169,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,0l1.3973708920187793,"
- + "0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0l2.096056338028169,1.3973708920187793l0.6986854460093896,0l0.6986854460093896,"
- + "0l0,0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0.6986854460093896l0,"
- + "0.6986854460093896l0.6986854460093896,0l1.3973708920187793,0.6986854460093896l1.3973708920187793,0.6986854460093896l3.493427230046948,"
- + "0.6986854460093896l1.3973708920187793,0.6986854460093896l2.096056338028169,0.6986854460093896l1.3973708920187793,"
- + "0.6986854460093896l1.3973708920187793,0l1.3973708920187793,0.6986854460093896l0.6986854460093896,0l0.6986854460093896,"
- + "0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l2.7947417840375586,0l1.3973708920187793,"
- + "0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,"
- + "0l0.6986854460093896,0l2.7947417840375586,0l0.6986854460093896,0l2.7947417840375586,0l1.3973708920187793,"
- + "0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,"
- + "0l0.6986854460093896,0l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0");
-
- AnnotationInfo resourceRedactionAnnotation = new AnnotationInfo();
- resourceRedactionAnnotation.setCreatedOn(new Date());
- resourceRedactionAnnotation.setType(AnnotationType.ResourcesRedaction);
- resourceRedactionAnnotation.setPageNumber(0);
- resourceRedactionAnnotation.setBox(new Rectangle(100, 72.7f, 50, 50));
-
- AnnotationInfo textFieldAnnotation = new AnnotationInfo();
- textFieldAnnotation.setCreatedOn(new Date());
- textFieldAnnotation.setType(AnnotationType.TextField);
- textFieldAnnotation.setPageNumber(0);
- textFieldAnnotation.setBox(new Rectangle(100, 72.7f, 50, 50));
- textFieldAnnotation.setFontColor(-15988609);
- textFieldAnnotation.setFieldText("some text");
- textFieldAnnotation.setFontFamily("times new roman");
-
- AnnotationInfo watermarkAnnotation = new AnnotationInfo();
- watermarkAnnotation.setCreatedOn(new Date());
- watermarkAnnotation.setType(AnnotationType.Watermark);
- watermarkAnnotation.setFieldText("This is watermark");
- watermarkAnnotation.setFontFamily("arial");
- watermarkAnnotation.setBox(new Rectangle(200, 250, 50, 0));
- watermarkAnnotation.setFontSize(25);
- watermarkAnnotation.setFontColor(15988609);
-
- AnnotationInfo distanceAnnotation = new AnnotationInfo();
- distanceAnnotation.setCreatedOn(new Date());
- distanceAnnotation.setType(AnnotationType.Distance);
- distanceAnnotation.setBox(new Rectangle(20, 20, 250, 250));
- distanceAnnotation.setBackgroundColor(-15988609);
- distanceAnnotation.setText("500px");
- distanceAnnotation.setFontFamily("Arial");
-
- AnnotationInfo arrowAnnotation = new AnnotationInfo();
- arrowAnnotation.setCreatedOn(new Date());
- arrowAnnotation.setType(AnnotationType.Arrow);
- arrowAnnotation.setBox(new Rectangle(250, 72.7f, 0, 20));
- arrowAnnotation.setBackgroundColor(-15988609);
-
- annotations.add(textAnnotation);
- annotations.add(pointAnnotation);
- annotations.add(areaAnnotation);
- annotations.add(textRedactionAnnotation);
- annotations.add(resourceRedactionAnnotation);
- annotations.add(polylineAnnotation);
- annotations.add(watermarkAnnotation);
- annotations.add(textFieldAnnotation);
- annotations.add(strikeoutAnnotation);
- annotations.add(underlineAnnotation);
- annotations.add(distanceAnnotation);
- annotations.add(arrowAnnotation);
-
- 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);
- }
- // ExEnd:differentAnnotationsForImages
- }
-
- public static void getDocInfoForDiagram(String fileName) {
- // ExStart:getDocInfoForDiagram
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- DocumentInfoContainer documentInfoContainer = annotator.getDocumentInfo(fileName);
-
- // Go through all pages
- for (PageData pageData : documentInfoContainer.getPages()) {
- System.out.println("Page number: " + pageData.getNumber());
- // Go through all page rows
- for (int i = 0; i < pageData.getRows().size(); i++) {
- RowData rowData = pageData.getRows().get(i);
- // Write data to console
- System.out.println("Row: " + (i + 1));
- System.out.println("Text: " + rowData.getText());
- System.out.println("Text width: " + rowData.getLineWidth());
- System.out.println("Text height: " + rowData.getLineHeight());
- System.out.println("Distance from left: " + rowData.getLineLeft());
- System.out.println("Distance from top: " + rowData.getLineTop());
- // Get words
- String[] words = rowData.getText().split(" ");
- // Go through all word coordinates
- for (int j = 0; j < words.length; j++) {
- int coordinateIndex = j == 0 ? 0 : j + 1;
- // Write data to console
- System.out.println("Word: '" + words[j] + "'");
- System.out.println("Word distance from left: " + rowData.getTextCoordinates().get(coordinateIndex));
- System.out.println("Word width: " + rowData.getTextCoordinates().get(coordinateIndex + 1));
- }
- }
- }
- // ExEnd:getDocInfoForDiagram
- }
-
- public static void getPageImagesForDiagramDocs(String fileName) throws Throwable {
- // ExStart:getPageImagesForDiagramDocs
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- List images = annotator.getPages(fileName, new ImageOptions());
- for (int i = 0; i < images.size(); i++) {
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "image_" + i + ".png");
-
- final PageImage pageImage = images.get(i);
- IOUtils.copy(pageImage.getStream(), fileStream);
- }
- // ExEnd:getPageImagesForDiagramDocs
- }
-
- public static void addAnnotationDiagrams(String fileName) throws Throwable {
- // ExStart:addAnnotationDiagrams
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDiagramFile = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
-
- // Area annotation
- AnnotationInfo areaAnnnotation = new AnnotationInfo();
- areaAnnnotation.setCreatedOn(new Date());
- areaAnnnotation.setType(AnnotationType.Area);
- areaAnnnotation.setBox(new Rectangle(200, 114.5f, 282.3f, 103.7f));
-
- // Polyline annotation
- AnnotationInfo polylineAnnotation = new AnnotationInfo();
- polylineAnnotation.setCreatedOn(new Date());
- polylineAnnotation.setType(AnnotationType.Polyline);
- polylineAnnotation.setBox(new Rectangle(206.3f, 106.61f, 456.04f, 307.97f));
- polylineAnnotation.setSvgPath(
- "M436.293427230047,148.06338028169014l0,-0.9870892018779343l-0.9870892018779343,-0.9870892018779343l-1.9741784037558685,-0.9870892018779343l-0.9870892018779343,0l-0.9870892018779343,-0.9870892018779343l-1.9741784037558685,-0.9870892018779343l-0.9870892018779343,0l-1.9741784037558685,-0.9870892018779343l-1.9741784037558685,0l-4.935446009389671,-1.9741784037558685l-1.9741784037558685,0l-1.9741784037558685,-0.9870892018779343l-1.9741784037558685,0l-1.9741784037558685,-0.9870892018779343l-2.961267605633803,0l-2.961267605633803,0l-2.961267605633803,0l-2.961267605633803,0l-2.961267605633803,0l-2.961267605633803,0l-1.9741784037558685,0l-3.948356807511737,0l-2.961267605633803,0l-3.948356807511737,0l-4.935446009389671,0l-3.948356807511737,0.9870892018779343l-4.935446009389671,0.9870892018779343l-6.90962441314554,0l-3.948356807511737,0.9870892018779343l-3.948356807511737,0l-2.961267605633803,1.9741784037558685l-3.948356807511737,0.9870892018779343l-6.90962441314554,1.9741784037558685l-6.90962441314554,0.9870892018779343l-12.832159624413146,2.961267605633803l-6.90962441314554,1.9741784037558685l-5.922535211267606,0.9870892018779343l-5.922535211267606,1.9741784037558685l-5.922535211267606,1.9741784037558685l-5.922535211267606,0.9870892018779343l-4.935446009389671,1.9741784037558685l-5.922535211267606,1.9741784037558685l-5.922535211267606,1.9741784037558685l-4.935446009389671,1.9741784037558685l-5.922535211267606,2.961267605633803l-5.922535211267606,3.948356807511737l-5.922535211267606,3.948356807511737l-4.935446009389671,3.948356807511737l-5.922535211267606,3.948356807511737l-5.922535211267606,3.948356807511737l-3.948356807511737,5.922535211267606l-3.948356807511737,4.935446009389671l-3.948356807511737,5.922535211267606l-3.948356807511737,6.90962441314554l-3.948356807511737,7.896713615023474l-0.9870892018779343,6.90962441314554l-1.9741784037558685,7.896713615023474l-1.9741784037558685,6.90962441314554l-0.9870892018779343,7.896713615023474l0,12.832159624413146l0,7.896713615023474l0,7.896713615023474l0.9870892018779343,7.896713615023474l1.9741784037558685,5.922535211267606l2.961267605633803,5.922535211267606l0.9870892018779343,5.922535211267606l2.961267605633803,6.90962441314554l3.948356807511737,5.922535211267606l4.935446009389671,4.935446009389671l3.948356807511737,5.922535211267606l3.948356807511737,5.922535211267606l3.948356807511737,5.922535211267606l5.922535211267606,5.922535211267606l5.922535211267606,5.922535211267606l5.922535211267606,5.922535211267606l6.90962441314554,5.922535211267606l7.896713615023474,5.922535211267606l7.896713615023474,5.922535211267606l17.767605633802816,8.883802816901408l11.845070422535212,3.948356807511737l11.845070422535212,4.935446009389671l23.690140845070424,8.883802816901408l41.45774647887324,6.90962441314554l31.586854460093896,3.948356807511737l16.780516431924884,0l16.780516431924884,1.9741784037558685l16.780516431924884,0l16.780516431924884,0l16.780516431924884,0l16.780516431924884,0l16.780516431924884,-1.9741784037558685l14.806338028169014,-1.9741784037558685l14.806338028169014,-1.9741784037558685l12.832159624413146,-1.9741784037558685l10.857981220657276,-2.961267605633803l10.857981220657276,-2.961267605633803l8.883802816901408,-4.935446009389671l8.883802816901408,-4.935446009389671l6.90962441314554,-6.90962441314554l6.90962441314554,-6.90962441314554l8.883802816901408,-16.780516431924884l4.935446009389671,-7.896713615023474l3.948356807511737,-8.883802816901408l4.935446009389671,-7.896713615023474l4.935446009389671,-7.896713615023474l3.948356807511737,-13.81924882629108l1.9741784037558685,-18.754694835680752l0,-7.896713615023474l0,-12.832159624413146l-1.9741784037558685,-15.793427230046948l-1.9741784037558685,-15.793427230046948l-4.935446009389671,-15.793427230046948l-8.883802816901408,-15.793427230046948l-12.832159624413146,-23.690140845070424l-10.857981220657276,-10.857981220657276l-5.922535211267606,-3.948356807511737l-12.832159624413146,-8.883802816901408l-9.870892018779342,-8.883802816901408l-5.922535211267606,-3.948356807511737l-12.832159624413146,-5.922535211267606l-15.793427230046948,-8.883802816901408l-13.81924882629108,-4.935446009389671l-11.845070422535212,-2.961267605633803l-11.845070422535212,-3.948356807511737l-11.845070422535212,-3.948356807511737l-5.922535211267606,-1.9741784037558685l-11.845070422535212,-2.961267605633803l-11.845070422535212,-1.9741784037558685l-5.922535211267606,-0.9870892018779343l-10.857981220657276,-1.9741784037558685l-10.857981220657276,-2.961267605633803l-9.870892018779342,0l-0.9870892018779343,0l-0.9870892018779343,0l-0.9870892018779343,0l-0.9870892018779343,0l0,-0.9870892018779343l1.9741784037558685,0");
-
- // Text field annotation
- AnnotationInfo textFieldAnnotation = new AnnotationInfo();
- textFieldAnnotation.setCreatedOn(new Date());
- textFieldAnnotation.setType(AnnotationType.TextField);
- textFieldAnnotation.setBox(new Rectangle(162.87f, 267.5f, 91.8f, 42.45f));
- textFieldAnnotation.setBackgroundColor(-15988609);
- textFieldAnnotation.setFieldText("Annotation Text");
-
- // Arrow annotation
- AnnotationInfo arrowAnnotation = new AnnotationInfo();
- arrowAnnotation.setType(AnnotationType.Arrow);
- arrowAnnotation.setBox(
- new Rectangle(435.77464788732397f, 148.05164319248826f, -66.34389671361504f, 53.07511737089203f));
-
- // Resource redaction annotation
- AnnotationInfo resourceRedactionAnnotation = new AnnotationInfo();
- resourceRedactionAnnotation.setType(AnnotationType.ResourcesRedaction);
- resourceRedactionAnnotation.setBox(new Rectangle(200, 114.5f, 282.3f, 103.7f));
-
- annotations.add(areaAnnnotation);
- annotations.add(polylineAnnotation);
- annotations.add(textFieldAnnotation);
- annotations.add(arrowAnnotation);
- annotations.add(resourceRedactionAnnotation);
-
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDiagramFile, annotations);
-
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "Annotated.vsdx");
- IOUtils.copy(result, fileStream);
- // ExEnd:addAnnotationDiagrams
- }
-
- public static void addDistanceAnnotationInDiagrams(String fileName) throws Throwable {
- // ExStart:addDistanceAnnotationInDiagrams
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDiagramFile = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Distance annotation
- AnnotationInfo distanceAnnotation = new AnnotationInfo();
- distanceAnnotation.setCreatedOn(new Date());
- distanceAnnotation.setType(AnnotationType.Distance);
- distanceAnnotation.setBox(new Rectangle((float)248.73202514648438, (float)287.85653686523438, (float)115.9178466796875, (float)25.143020629882812));
- distanceAnnotation.setSvgPath("M248.73201877934272,295.5439436619718 l115.28309859154929,-4.192112676056338");
-
- annotations.add(distanceAnnotation);
-
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDiagramFile, annotations);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "Annotated.vsdx");
- IOUtils.copy(result, fileStream);
- // ExEnd:addDistanceAnnotationInDiagrams
- }
-
- public static void addPointAnnotationInDiagrams(String fileName) throws Throwable {
- // ExStart:addPointAnnotationInDiagrams
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDiagramFile = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Point annotation
- AnnotationInfo pointAnnnotation = new AnnotationInfo();
- pointAnnnotation.setCreatedOn(new Date());
- pointAnnnotation.setType(AnnotationType.Point);
- pointAnnnotation.setBox(new Rectangle(150.32f, 99.22f, 0, 0));
- pointAnnnotation.setPageNumber(0);
-
- annotations.add(pointAnnnotation);
-
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDiagramFile, annotations);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "Annotated.vsdx");
- IOUtils.copy(result, fileStream);
- // ExEnd:addPointAnnotationInDiagrams
- }
-
- public static void addWatermarkAnnotationInDiagrams(String fileName) throws Throwable {
- // ExStart:addWatermarkAnnotationInDiagrams
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDiagramFile = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Watermark annotation
- AnnotationInfo watermarkAnnnotation = new AnnotationInfo();
- watermarkAnnnotation.setCreatedOn(new Date());
- watermarkAnnnotation.setFieldText("Watermark text");
- watermarkAnnnotation.setFontColor(16711680);
- watermarkAnnnotation.setFontFamily("Microsoft Sans Serif");
- watermarkAnnnotation.setFontSize(17);
- watermarkAnnnotation.setOpacity(0.3);
- watermarkAnnnotation.setType(AnnotationType.Watermark);
-
- annotations.add(watermarkAnnnotation);
-
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDiagramFile, annotations);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "Annotated.vsd");
- IOUtils.copy(result, fileStream);
- // ExEnd:addWatermarkAnnotationInDiagrams
- }
-}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/JsonFile.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/JsonFile.java
deleted file mode 100644
index 18f3fe8..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/JsonFile.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package GroupDocs.Annotation.Examples.Java;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-
-public abstract class JsonFile {
- protected Object _syncRoot = new Object();
- private String _filePath;
- private T _data;
-
- public JsonFile(String filePath) throws Exception {
- if (filePath == null || filePath.trim().isEmpty()) {
- throw new Exception("filePath");
- }
- _filePath = filePath;
- }
-
- protected void serialize() throws Exception {
- if (_data == null) {
- return;
- }
- synchronized (_syncRoot) {
- if (_data != null) {
- try {
- OutputStream stream = new FileOutputStream(_filePath);
- ObjectMapper xmlMapper = new XmlMapper();
- xmlMapper.writeValue(stream, _data);
- } catch (Exception e) {
- throw new Exception("Failed to serialize an object to file: '{0}'.", e);
- }
- }
- }
- }
-
- protected void deserialize() throws Exception {
- synchronized (_syncRoot) {
- try {
- if (!new File(_filePath).exists()) {
- InputStream fileStream = new FileInputStream(_filePath);
- fileStream.close();
- _data = newInstance();
- return;
- }
- InputStream stream = new FileInputStream(_filePath);
- ObjectMapper xmlMapper = new XmlMapper();
- if (xmlMapper.canDeserialize(xmlMapper.constructType(getClazz().getType()))) {
- _data = (T) xmlMapper.readValue(stream, getClazz());
- }
- } catch (Exception e) {
- throw new Exception("Failed to deserialize an object from file: '{0}'.", e);
- }
- if (_data == null) {
- _data = newInstance();
- }
- }
- }
-
- protected abstract T newInstance();
-
- protected abstract TypeReference getClazz();
-
- protected T getData() throws Exception {
- synchronized (_syncRoot) {
- if (_data == null) {
- deserialize();
- }
- return _data;
- }
- }
-}
\ No newline at end of file
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/JsonRepository.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/JsonRepository.java
deleted file mode 100644
index 245b7bb..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/JsonRepository.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package GroupDocs.Annotation.Examples.Java;
-
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.groupdocs.annotation.handler.input.IRepository;
-import com.groupdocs.annotation.handler.input.dataobjects.IEntity;
-
-public abstract class JsonRepository extends JsonFile>
- implements IRepository {
- private final String _entityName = getClazz().getClass().getName();
-
- public JsonRepository(String filePath) throws Exception {
- super(filePath);
- }
-
- public void commit() {
- try {
- serialize();
- } catch (Exception e) {
- Logger.getAnonymousLogger().log(Level.SEVERE, String.format("Unable to commit changes: %s", _entityName),
- e);
- }
- }
-
- public void refresh(TEntity entity) {
- try {
- deserialize();
- } catch (Exception e) {
- Logger.getAnonymousLogger().log(Level.SEVERE, String.format("Unable to refresh changes: %s", _entityName),
- e);
- }
- }
-
- public boolean add(TEntity entity) {
- synchronized (_syncRoot) {
- try {
- List data = this.getData();
- entity.setId(GetNextId(1));
- data.add(entity);
- commit();
- return true;
- } catch (Exception e) {
- Logger.getAnonymousLogger().log(Level.SEVERE, String.format("Unable to add entity: %s", _entityName),
- e);
- }
- }
- return true;
- }
-
- public boolean remove(TEntity entity) {
- synchronized (_syncRoot) {
- try {
- for (TEntity e : getData()) {
- if (e.getId() == entity.getId()) {
- getData().remove(e);
- }
- }
- commit();
- return true;
- } catch (Exception e) {
- Logger.getAnonymousLogger().log(Level.SEVERE, String.format("Unable to remove entity: %s", _entityName),
- e);
- }
- }
- return false;
- }
-
- public boolean update(TEntity entity) {
- synchronized (_syncRoot) {
- try {
- List data = this.getData();
- int index = -1;
- for (int n = 0; n < data.size(); n++) {
- TEntity x = data.get(n);
- if (x.getId() == entity.getId()) {
- index = n;
- break;
- }
- }
- if (index >= 0) {
- data.set(index, entity);
- commit();
- return true;
- }
- return false;
- } catch (Exception e) {
- Logger.getAnonymousLogger().log(Level.SEVERE, String.format("Unable to update entity: %s", _entityName),
- e);
- }
- }
- return true;
- }
-
- public boolean add(List entities) {
- synchronized (_syncRoot) {
- try {
- getData().addAll(entities);
- commit();
- return true;
- } catch (Exception e) {
- Logger.getAnonymousLogger().log(Level.SEVERE, String.format("Unable to add entities: %s", _entityName),
- e);
- }
- }
- return true;
- }
-
- public boolean remove(List entities) {
- synchronized (_syncRoot) {
- try {
- List data = this.getData();
- for (IEntity e : entities) {
- data.remove(e);
- }
- commit();
- return true;
- } catch (Exception e) {
- Logger.getAnonymousLogger().log(Level.SEVERE,
- String.format("Unable to remove entities: %s", _entityName), e);
- }
- }
- return true;
- }
-
- public boolean update(List entities) {
- synchronized (_syncRoot) {
- try {
- List data = this.getData();
- for (TEntity e : entities) {
- int index = -1;
- for (int n = 0; n < data.size(); n++) {
- TEntity x = data.get(n);
- if (x.getId() == e.getId()) {
- index = n;
- break;
- }
- }
- if (index >= 0) {
- data.set(index, e);
- }
- }
- commit();
- return true;
- } catch (Exception e) {
- Logger.getAnonymousLogger().log(Level.SEVERE,
- String.format("Unable to update entities: %s", _entityName), e);
- }
- }
- return true;
- }
-
- public TEntity get(double id) {
- synchronized (_syncRoot) {
- try {
- for (TEntity e : getData()) {
- if (e.getId() == e.getId()) {
- return e;
- }
- }
- } catch (Exception e) {
- Logger.getAnonymousLogger().log(Level.SEVERE, String.format("Unable to get entity: ID = %s", id), e);
- }
- }
- return null;
- }
-
- public TEntity get(long id) {
- return get((double) id);
- }
-
- protected long GetNextId(int increment) throws Exception {
- List data = getData();
- long lastId = 0L;
- if (!data.isEmpty()) {
- Collections.sort(data, new Comparator() {
- public int compare(TEntity o1, TEntity o2) {
- return (int) (o1.getId() - o2.getId());
- }
- });
- lastId = data.get(data.size() - 1).getId();
- }
- return (lastId + increment);
- }
-}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/MainClass.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/MainClass.java
deleted file mode 100644
index 8e9176e..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/MainClass.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package GroupDocs.Annotation.Examples.Java;
-
-public class MainClass {
-
- public static void main(String[] args) throws Throwable {
-
- // Apply license
-
- // Utilities.applyLicenseFromFile();
-
- // Annotations in PDF
-
- // PDFAnnotation.addTextAnnotationInPDF();
- // PDFAnnotation.addAreaAnnotationInPDF();
- // PDFAnnotation.addPointAnnotationInPDF();
- // PDFAnnotation.addStrikeOutAnnotationInPDF();
- // PDFAnnotation.addPolyLineAnnotationInPDF();
- // PDFAnnotation.addTextFieldAnnotationInPDF();
- // PDFAnnotation.addWatermarkAnnotationInPDF();
- // PDFAnnotation.addTextReplacementAnnotationInPDF();
- // PDFAnnotation.addArrowAnnotationInPDF();
- // PDFAnnotation.addTextRedactionAnnotationInPDF();
- // PDFAnnotation.addResourceRedactionAnnotationInPDF();
- // PDFAnnotation.addUnderlineAnnotationInPDF();
- // PDFAnnotation.addDistanceAnnotationInPDF();
- // PDFAnnotation.usersWithDifferentRights();
- // PDFAnnotation.gettingTextCoordinates("sample.pdf");
-
- // Annotation in Cells
-
- // CellsAnnotation.addAnnotationInCells();
-
- // Annotation in Slides
-
- // SlidesAnnotation.addAnnotationInSlides();
- // SlidesAnnotation.differentAnnotationsForSlides();
- // SlidesAnnotation.importingAnnotationsToSlide();
-
- // Annotation in Words
-
- // WordsAnnotation.addDifferentAnnotationInWords();
- // WordsAnnotation.addTextAnnotationInWords();
- // WordsAnnotation.addAreaAnnotationWithRepliesInWords();
- // WordsAnnotation.addStrikeoutAnnotationInWords();
- // WordsAnnotation.addTextFieldAnnotationInWords();
- // WordsAnnotation.addTextReplacementAnnotationInWords();
- // WordsAnnotation.addArrowAnnotationInWords();
- // WordsAnnotation.addTextRedactionAnnotationInWords();
- // WordsAnnotation.addResourceRedactionAnnotationInWords();
- // WordsAnnotation.addUnderlineAnnotationInWords();
- // WordsAnnotation.importingAnnotationsFromWordDoc();
-
- // WordsAnnotation.addDistanceAnnotationInWords();
- // WordsAnnotation.addPolylineAnnotationInWords();
- // WordsAnnotation.addWatermarkAnnotationInWords();
- // WordsAnnotation.addPointAnnotationInWords();
-
- // Data Storage Functions
-
- // DataStorage.createDocument();
- // DataStorage.setDocumentAccessRights();
- // DataStorage.createAndGetAnnotations();
- // DataStorage.getAllAnnotations();
- // DataStorage.resizeAnnotationResult();
- // DataStorage.moveAnnotationResult();
- // DataStorage.setBackgroundColor()
- // DataStorage.editTextFieldAnnotations();
- // DataStorage.removeAnnotation();
- // DataStorage.addAnnotationReply();
- // DataStorage.addCollaborator();
- // DataStorage.getCollaborator();
- // DataStorage.updateCollaborator();
- // DataStorage.deleteCollaborator();
- // DataStorage.managesCollaboratorRights();
- // DataStorage.exportAnnotations();
-
- // Annotation in Images/Diagrams
-
- // ImagesAnnotation.differentAnnotationsForImages("image.png");
- // ImagesAnnotation.getDocInfoForDiagram("sample.vsd");
- // ImagesAnnotation.getPageImagesForDiagramDocs("sample.vsd");
- // ImagesAnnotation.addAnnotationDiagrams("sample.vsd");
-
- // ImagesAnnotation.addDistanceAnnotationInDiagrams("sample.vsd");
- // ImagesAnnotation.addPointAnnotationInDiagrams("sample.vsd");
- // ImagesAnnotation.addWatermarkAnnotationInDiagrams("sample.vsd");
-
- // Annotation in Emails
-
- // EmailAnnotation.differentAnnotationsForEmail("DEPOSIT.eml");
-
- // Annotation in HTML
-
- // HtmlAnnotation.createAnnotationForHtml("source.html");
-
- // Other Operations
-
- // Get image representation of the document
- // Utilities.getImageRepresentation("sample.pdf");
-
- // Get text coordinates in image representation of the document
- // Utilities.getTextCoordinates("sample.pdf");
-
- }
-}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/PDFAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/PDFAnnotation.java
deleted file mode 100644
index f86e012..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/PDFAnnotation.java
+++ /dev/null
@@ -1,630 +0,0 @@
-package GroupDocs.Annotation.Examples.Java;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-
-import com.groupdocs.annotation.common.exception.AnnotatorException;
-import com.groupdocs.annotation.domain.AnnotationInfo;
-import com.groupdocs.annotation.domain.AnnotationReplyInfo;
-import com.groupdocs.annotation.domain.AnnotationReviewerRights;
-import com.groupdocs.annotation.domain.AnnotationType;
-import com.groupdocs.annotation.domain.DocumentType;
-import com.groupdocs.annotation.domain.PageData;
-import com.groupdocs.annotation.domain.Point;
-import com.groupdocs.annotation.domain.Rectangle;
-import com.groupdocs.annotation.domain.ReviewerInfo;
-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.results.CreateAnnotationResult;
-import com.groupdocs.annotation.domain.results.GetCollaboratorsResult;
-import com.groupdocs.annotation.domain.results.SetCollaboratorsResult;
-import com.groupdocs.annotation.handler.AnnotationImageHandler;
-import com.groupdocs.annotation.handler.input.IDocumentDataHandler;
-import com.groupdocs.annotation.handler.input.IUserDataHandler;
-import com.groupdocs.annotation.handler.input.dataobjects.Document;
-import com.groupdocs.annotation.handler.input.dataobjects.User;
-
-public class PDFAnnotation {
-
- // region initialize document name
-
- /*
- * document name
- */
- public static String fileName = "sample.pdf";
-
- // region Working with Annotations in PDF
-
- /*
- * add text annotations in PDF
- */
- public static void addTextAnnotationInPDF() {
- // ExStart:addTextAnnotationInPDF
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // 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);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // 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:addTextAnnotationInPDF
- }
-
- /*
- * add area annotation in PDF
- */
- public static void addAreaAnnotationInPDF() {
- // ExStart:addAreaAnnotationInPDF
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Area annotation with 2 replies
- AnnotationInfo areaAnnnotation = new AnnotationInfo();
- areaAnnnotation.setAnnotationPosition(new Point(852.0, 59.0));
- final AnnotationReplyInfo[] annotationReplyInfos = { new AnnotationReplyInfo() {
- {
- setMessage("Hello!");
- setRepliedOn(Calendar.getInstance().getTime());
- setUserName("John");
- }
- }, new AnnotationReplyInfo() {
- {
- setMessage("Hi!");
- setRepliedOn(Calendar.getInstance().getTime());
- setUserName("Judy");
- }
- } };
- areaAnnnotation.setReplies(annotationReplyInfos);
- areaAnnnotation.setBackgroundColor(11111111);
- areaAnnnotation.setBox(new Rectangle(300f, 200f, 88f, 37f));
- areaAnnnotation.setPageNumber(0);
- areaAnnnotation.setPenColor(2222222);
- areaAnnnotation.setPenStyle((byte) 1);
- areaAnnnotation.setPenWidth((byte) 1);
- areaAnnnotation.setOpacity(0.5);
- areaAnnnotation.setType(AnnotationType.Area);
- areaAnnnotation.setCreatorName("Anonym A.");
- annotations.add(areaAnnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "annotated-area.pdf");
- IOUtils.copy(result, fileStream);
-
- } catch (Exception e) {
- System.out.println("Exception :" + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addAreaAnnotationInPDF
- }
-
- /*
- * add point annotation in PDF
- */
- public static void addPointAnnotationInPDF() {
- //ExStart:addPointAnnotationInPDF
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Point annotation
- AnnotationInfo pointAnnotation = new AnnotationInfo();
- pointAnnotation.setAnnotationPosition(new Point(852.0, 81.0));
- pointAnnotation.setBox(new Rectangle(212f, 81f, 35f, 0.0f));
- pointAnnotation.setPageNumber(0);
- pointAnnotation.setType(AnnotationType.Point);
- pointAnnotation.setCreatorName("Anonym A.");
- annotations.add(pointAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "annotated-point.pdf");
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception:" + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addPointAnnotationInPDF
- }
-
- /*
- * add strike out annotation in PDF
- */
- public static void addStrikeOutAnnotationInPDF() {
- //ExStart:addStrikeOutAnnotationInPDF
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Text strikeout annotation
- AnnotationInfo strikeoutAnnotation = new AnnotationInfo();
- strikeoutAnnotation.setAnnotationPosition(new Point(852.0, 154.31));
- strikeoutAnnotation.setBox(new Rectangle(68, 154, 102, 9));
- strikeoutAnnotation.setPageNumber(0);
- strikeoutAnnotation.setPenColor(0);
- strikeoutAnnotation.setOpacity(0.5);
- strikeoutAnnotation.setType(AnnotationType.TextStrikeout);
- strikeoutAnnotation.setCreatorName("Anonym A.");
- annotations.add(strikeoutAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "annotated-strikeout.pdf");
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception:" + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addStrikeOutAnnotationInPDF
- }
-
- /*
- * add polyline annotation in PDF
- */
- public static void addPolyLineAnnotationInPDF() {
- //ExStart:addPolyLineAnnotationInPDF
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Polyline annotation
- AnnotationInfo polylineAnnotation = new AnnotationInfo();
- polylineAnnotation.setAnnotationPosition(new Point(852.0, 35.0));
- polylineAnnotation.setBox(new Rectangle(250f, 35f, 102f, 12f));
- polylineAnnotation.setPageNumber(0);
- polylineAnnotation.setPenColor(1201033);
- polylineAnnotation.setPenWidth((byte) 2);
- polylineAnnotation.setSvgPath(
- "M250.8280751173709,48.209295774647885l0.6986854460093896,0l0.6986854460093896,-1.3973708920187793l0.6986854460093896,0l0.6986854460093896,-1.3973708920187793l1.3973708920187793,-0.6986854460093896l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0l2.096056338028169,-1.3973708920187793l3.493427230046948,-1.3973708920187793l0.6986854460093896,-0.6986854460093896l1.3973708920187793,-1.3973708920187793l0.6986854460093896,0l1.3973708920187793,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,0l0,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,0l0,-0.6986854460093896l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l2.096056338028169,-0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,0l1.3973708920187793,0l1.3973708920187793,0l2.096056338028169,0l5.589483568075117,0l1.3973708920187793,0l2.096056338028169,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,0l1.3973708920187793,0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0l2.096056338028169,1.3973708920187793l0.6986854460093896,0l0.6986854460093896,0l0,0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0.6986854460093896l0,0.6986854460093896l0.6986854460093896,0l1.3973708920187793,0.6986854460093896l1.3973708920187793,0.6986854460093896l3.493427230046948,0.6986854460093896l1.3973708920187793,0.6986854460093896l2.096056338028169,0.6986854460093896l1.3973708920187793,0.6986854460093896l1.3973708920187793,0l1.3973708920187793,0.6986854460093896l0.6986854460093896,0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l2.7947417840375586,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l2.7947417840375586,0l0.6986854460093896,0l2.7947417840375586,0l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0");
- polylineAnnotation.setType(AnnotationType.Polyline);
- polylineAnnotation.setCreatorName("Anonym A.");
- annotations.add(polylineAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "annotated-polyline.pdf");
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception:" + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addPolyLineAnnotationInPDF
- }
-
- /*
- * add text field annotation in PDF
- */
- public static void addTextFieldAnnotationInPDF() {
- //ExStart:addTextFieldAnnotationInPDF
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Text field annotation
- AnnotationInfo textFieldAnnotation = new AnnotationInfo();
- textFieldAnnotation.setAnnotationPosition(new Point(852.0, 201.0));
- textFieldAnnotation.setFieldText("text in the box");
- textFieldAnnotation.setFontFamily("Arial");
- textFieldAnnotation.setFontSize(10);
- textFieldAnnotation.setBox(new Rectangle(66f, 201f, 64f, 37f));
- textFieldAnnotation.setPageNumber(0);
- textFieldAnnotation.setType(AnnotationType.TextField);
- textFieldAnnotation.setCreatorName("Anonym A.");
- annotations.add(textFieldAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "annotated-textfield.pdf");
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception :" + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addTextFieldAnnotationInPDF
- }
-
- /*
- * add watermark annotation in PDF
- */
- public static void addWatermarkAnnotationInPDF() {
- //ExStart:addWatermarkAnnotationInPDF
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Watermark annotation
- AnnotationInfo watermarkAnnotation = new AnnotationInfo();
- watermarkAnnotation.setAnnotationPosition(new Point(852.0, 300.0));
- watermarkAnnotation.setFieldText("TEXT STAMP");
- watermarkAnnotation.setFontFamily("Microsoft Sans Serif");
- watermarkAnnotation.setFontSize(10);
- watermarkAnnotation.setFontColor(2222222);
- watermarkAnnotation.setBox(new Rectangle(430f, 272f, 66f, 51f));
- watermarkAnnotation.setPageNumber(0);
- watermarkAnnotation.setType(AnnotationType.TextField);
- watermarkAnnotation.setCreatorName("Anonym A.");
- annotations.add(watermarkAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "annotated-watermark.pdf");
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addWatermarkAnnotationInPDF
- }
-
- /*
- * add text replacement annotation in PDF
- */
- public static void addTextReplacementAnnotationInPDF() {
- //ExStart:addTextReplacementAnnotationInPDF
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Text replacement annotation
- AnnotationInfo textReplacementAnnotation = new AnnotationInfo();
- textReplacementAnnotation.setAnnotationPosition(new Point(852.0, 172.0));
- textReplacementAnnotation.setFieldText("Replaced text");
- textReplacementAnnotation.setFontSize(10);
- textReplacementAnnotation.setBox(new Rectangle(68f, 154f, 102f, 9f));
- textReplacementAnnotation.setPageNumber(0);
- textReplacementAnnotation.setType(AnnotationType.TextReplacement);
- textReplacementAnnotation.setCreatorName("Anonym A.");
- annotations.add(textReplacementAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "annotated-textreplacement.pdf");
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addTextReplacementAnnotationInPDF
- }
-
- /*
- * add arrow annotation in PDF
- */
- public static void addArrowAnnotationInPDF() {
- //ExStart:addArrowAnnotationInPDF
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Arrow annotation
- AnnotationInfo arrowAnnotation = new AnnotationInfo();
- arrowAnnotation.setAnnotationPosition(new Point(852.0, 252.0));
- arrowAnnotation.setBox(new Rectangle(279.4742f, 252.9241f, 129.9555f, -9.781596f));
- arrowAnnotation.setPageNumber(0);
- arrowAnnotation.setPenColor(1201033);
- arrowAnnotation.setPenStyle((byte) 0);
- arrowAnnotation.setPenWidth((byte) 1);
- arrowAnnotation.setSvgPath("M279.47417840375584,252.92413145539905 L129.9554929577465,-9.781596244131455");
- arrowAnnotation.setType(AnnotationType.Arrow);
- arrowAnnotation.setCreatorName("Anonym A.");
- annotations.add(arrowAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "annotated-arrow.pdf");
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception:" + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addArrowAnnotationInPDF
- }
-
- /*
- * add text redaction annotation in PDF
- */
- public static void addTextRedactionAnnotationInPDF() {
- //ExStart:
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Text redaction annotation
- AnnotationInfo textRedactionAnnotation = new AnnotationInfo();
- textRedactionAnnotation.setAnnotationPosition(new Point(852.0, 154.0));
- textRedactionAnnotation.setBox(new Rectangle(68f, 154f, 102f, 9f));
- textRedactionAnnotation.setPageNumber(0);
- textRedactionAnnotation.setType(AnnotationType.TextRedaction);
- textRedactionAnnotation.setCreatorName("Anonym A.");
- annotations.add(textRedactionAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "annotated-textredaction.pdf");
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exceptino:" + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addTextRedactionAnnotationInPDF
- }
-
- /*
- * add resource redaction annotation in PDF
- */
- public static void addResourceRedactionAnnotationInPDF() {
- //ExStart:addResourceRedactionAnnotationInPDF
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Resource redaction annotation
- AnnotationInfo resourceRedactionAnnotation = new AnnotationInfo();
- resourceRedactionAnnotation.setAnnotationPosition(new Point(852.0, 271.78));
- resourceRedactionAnnotation.setBackgroundColor(3355443);
- resourceRedactionAnnotation.setBox(new Rectangle(466f, 271f, 69f, 62f));
- resourceRedactionAnnotation.setPageNumber(0);
- resourceRedactionAnnotation.setPenColor(3355443);
- resourceRedactionAnnotation.setType(AnnotationType.ResourcesRedaction);
- resourceRedactionAnnotation.setCreatorName("Anonym A.");
- annotations.add(resourceRedactionAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "annotated-resourceredaction.pdf");
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception:" + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addResourceRedactionAnnotationInPDF
- }
-
- /*
- * add underline annotation in PDF
- */
- public static void addUnderlineAnnotationInPDF() {
- //ExStart:addUnderlineAnnotationInPDF
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Underline annotation
- AnnotationInfo underlineAnnotation = new AnnotationInfo();
- underlineAnnotation.setAnnotationPosition(new Point(852.0, 154.3131));
- underlineAnnotation.setBox(new Rectangle(68f, 154f, 102f, 9f));
- underlineAnnotation.setPageNumber(0);
- underlineAnnotation.setPenColor(1201033);
- underlineAnnotation.setOpacity(0.5);
- underlineAnnotation.setType(AnnotationType.TextUnderline);
- underlineAnnotation.setCreatorName("Anonym A.");
- annotations.add(underlineAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "annotated-underline.pdf");
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.print("Exception:" + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addUnderlineAnnotationInPDF
- }
-
- /*
- * add distance annotation in PDF
- */
- public static void addDistanceAnnotationInPDF() {
- //ExStart:addDistanceAnnotationInPDF
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.getDocumentDataHandler();
- InputStream cleanPdf = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Distance annotation
- AnnotationInfo distanceAnnotation = new AnnotationInfo();
- distanceAnnotation.setAnnotationPosition(new Point(852.0, 287.0));
- distanceAnnotation.setBox(new Rectangle(248f, 287f, 115f, 25f));
- distanceAnnotation.setPageNumber(0);
- distanceAnnotation.setPenColor(1201033);
- distanceAnnotation.setPenStyle((byte) 0);
- distanceAnnotation.setPenWidth((byte) 1);
- distanceAnnotation
- .setSvgPath("M248.73201877934272,295.5439436619718 l115.28309859154929,-4.192112676056338");
- distanceAnnotation.setFieldText("\r\nAnonym A.: 115px");
- distanceAnnotation.setType(AnnotationType.Distance);
- distanceAnnotation.setCreatorName("Anonym A.");
- annotations.add(distanceAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanPdf, annotations, DocumentType.Pdf);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "annotated-distance.pdf");
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addDistanceAnnotationInPDF
- }
-
- public static void usersWithDifferentRights(){
- //ExStart:usersWithDifferentRights
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- IUserDataHandler userRepository = annotator.getUserDataHandler();
- IDocumentDataHandler documentRepository = annotator.getDocumentDataHandler();
-
- // Create storage folder
- if(!new File(cfg.getStoragePath()).exists() && !new File(cfg.getStoragePath()).mkdirs())
- {
- System.out.println("Can't create directory!");
- }
-
- // Create owner.
- User johnOwner = userRepository.getUserByEmail("john@doe.com");
-
- if(johnOwner == null)
- {
- final User user = new User();
- user.setFirstName("John");
- user.setLastName("Doe");
- user.setEmail("john@doe.com");
- userRepository.add(user);
- johnOwner = userRepository.getUserByEmail("john@doe.com");
- }
-
- // Create document data object in storage
- Document document = documentRepository.getDocument(fileName);
- long documentId = document == null ? annotator.createDocument(fileName, DocumentType.Pdf, johnOwner.getId()) : document.getId();
-
- // Create reviewer.
- ReviewerInfo reviewerInfo = new ReviewerInfo();
- reviewerInfo.setPrimaryEmail("judy@doe.com");
- reviewerInfo.setFirstName("Judy");
- reviewerInfo.setLastName("Doe");
- reviewerInfo.setAccessRights(AnnotationReviewerRights.CanView);
-
- // Add collaboorator to the document. If user with UserName equals to reviewers PrimaryEmail is absent it will be created.
- SetCollaboratorsResult addCollaboratorResult = annotator.addCollaborator(documentId, reviewerInfo);
- System.out.println(addCollaboratorResult);
-
- // Get document collaborators
- GetCollaboratorsResult getCollaboratorsResult = annotator.getCollaborators(documentId);
- System.out.println(getCollaboratorsResult);
- User judy = userRepository.getUserByEmail("judy@doe.com");
-
- // Create annotation object
- AnnotationInfo pointAnnotation = new AnnotationInfo();
- pointAnnotation.setAnnotationPosition(new Point(852.0, 81.0));
- pointAnnotation.setBox(new Rectangle(212f, 81f, 142f, 0.0f));
- pointAnnotation.setType(AnnotationType.Point);
- pointAnnotation.setPageNumber(0);
- pointAnnotation.setCreatorName("Anonym A.");
-
- // John try to add annotations
- CreateAnnotationResult johnResult = annotator.createAnnotation(pointAnnotation, documentId, johnOwner.getId());
- System.out.println(johnResult);
-
- // Judy try to add annotations
- try {
- CreateAnnotationResult judyResult = annotator.createAnnotation(pointAnnotation, documentId, judy.getId());
- System.out.println(judyResult);
- } catch (AnnotatorException e) {
- System.out.println(e.getMessage());
- }
-
- // Allow Judy create annotations.
- reviewerInfo.setAccessRights(AnnotationReviewerRights.CanAnnotate);
- SetCollaboratorsResult updateCollaboratorResult = annotator.updateCollaborator(documentId, reviewerInfo);
- System.out.println(updateCollaboratorResult);
-
- // Judy try to add annotations
- CreateAnnotationResult judyResultCanAnnotate = annotator.createAnnotation(pointAnnotation, documentId, judy.getId());
- System.out.println(judyResultCanAnnotate);
- //ExEnd:usersWithDifferentRights
- }
- public static void gettingTextCoordinates(String fileName){
- //ExStart:gettingTextCoordinates
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- annotator.createDocument(fileName);
- DocumentInfoContainer documentInfoContainer = annotator.getDocumentInfo(fileName);
-
- // Go through all pages
- for (PageData pageData : documentInfoContainer.getPages())
- {
- System.out.println("Page number: " + pageData.getNumber());
-
- //Go through all page rows
- for(int i = 0; i < pageData.getRows().size(); i++)
- {
- RowData rowData = pageData.getRows().get(i);
-
- // Write data to console
- System.out.println("Row: " + (i + 1));
- System.out.println("Text: " + rowData.getText());
- System.out.println("Text width: " + rowData.getLineWidth());
- System.out.println("Text height: " + rowData.getLineHeight());
- System.out.println("Distance from left: " + rowData.getLineLeft());
- System.out.println("Distance from top: " + rowData.getLineTop());
-
- // Get words
- String[] words = rowData.getText().split(" ");
-
- // Go through all word coordinates
- for(int j = 0; j < words.length; j++)
- {
- int coordinateIndex = j == 0 ? 0 : j + 1;
- // Write data to console
- System.out.println();
- System.out.println("Word:'" + words[j] + "'");
- System.out.println("Word distance from left: " + rowData.getTextCoordinates().get(coordinateIndex));
- System.out.println("Word width: " + rowData.getTextCoordinates().get(coordinateIndex + 1));
- System.out.println();
- }
- }
- }
- //ExEnd:gettingTextCoordinates
- }
-}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/SlidesAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/SlidesAnnotation.java
deleted file mode 100644
index 17de2de..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/SlidesAnnotation.java
+++ /dev/null
@@ -1,206 +0,0 @@
-package GroupDocs.Annotation.Examples.Java;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-
-import com.groupdocs.annotation.domain.AnnotationInfo;
-import com.groupdocs.annotation.domain.AnnotationType;
-import com.groupdocs.annotation.domain.DocumentType;
-import com.groupdocs.annotation.domain.Point;
-import com.groupdocs.annotation.domain.Rectangle;
-import com.groupdocs.annotation.domain.config.AnnotationConfig;
-import com.groupdocs.annotation.handler.AnnotationImageHandler;
-
-public class SlidesAnnotation {
-
- // region initialize document name
-
- /*
- * document name
- */
- public static String fileName = "slide.pptx";
-
- // region Working with Annotations in Slides
-
- /*
- * add annotation in Slides
- */
- public static void addAnnotationInSlides() {
- //ExStart:addAnnotationInSlides
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream inputStream = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- final AnnotationInfo annotationInfo = new AnnotationInfo();
- annotationInfo.setPageNumber(0);
- annotationInfo.setAnnotationPosition(new Point(1, 2));
- annotationInfo.setFieldText("Hello!");
- annotationInfo.setCreatorName("John");
- annotations.add(annotationInfo);
- // Export annotations to Slides document
- InputStream resultStream = annotator.exportAnnotationsToDocument(inputStream, annotations);
- System.out.println(resultStream.available());
- IOUtils.copy(resultStream,
- new FileOutputStream(Utilities.outputPath + File.separator + "slides-annotated.pptx"));
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addAnnotationInSlides
- }
-
- /*
- * Creating annotations of different types
- */
- public static void differentAnnotationsForSlides() throws Throwable{
- //ExStart:differentAnnotationsForSlides
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- List annotations;
-
-
- FileInputStream cleanPresentation = new FileInputStream(Utilities.storagePath + File.separator + fileName);
-
- annotations = new ArrayList();
-
- AnnotationInfo pointAnnotation = new AnnotationInfo();
- pointAnnotation.setPageNumber(0);
- pointAnnotation.setType(AnnotationType.Point);
- pointAnnotation.setBox(new Rectangle(100, 100, 0, 0));
- pointAnnotation.setFieldText("Hello!");
- pointAnnotation.setCreatorName("John");
-
- AnnotationInfo areaAnnotation = new AnnotationInfo();
- areaAnnotation.setCreatedOn(new Date());
- areaAnnotation.setType(AnnotationType.Area);
- areaAnnotation.setPageNumber(0);
- areaAnnotation.setBox(new Rectangle(100, 72.7f, 50, 50));
- areaAnnotation.setBackgroundColor(-15988609);
-
- AnnotationInfo arrowAnnotation = new AnnotationInfo();
- arrowAnnotation.setType(AnnotationType.Arrow);
- arrowAnnotation.setCreatedOn(new Date());
- arrowAnnotation.setPageNumber(0);
- arrowAnnotation.setBox(new Rectangle(0, 0, 100, 100));
- arrowAnnotation.setBackgroundColor(15988609);
-
- AnnotationInfo polylineAnnotation = new AnnotationInfo();
- polylineAnnotation.setType(AnnotationType.Polyline);
- polylineAnnotation.setCreatedOn(new Date());
- polylineAnnotation.setBox(new Rectangle((float)250.82807922363281, (float)35.632957458496094, (float)102.70676422119141, (float)12.576337814331055));
- polylineAnnotation.setPageNumber(0);
- polylineAnnotation.setPenColor(65015);
- polylineAnnotation.setSvgPath(
- "M250.8280751173709,48.209295774647885l0.6986854460093896,0l0.6986854460093896,-1.3973708920187793l0.6986854460093896,0l0.6986854460093896,-1.3973708920187793l1.3973708920187793,"
- + "-0.6986854460093896l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0l2.096056338028169,-1.3973708920187793l3.493427230046948,-1.3973708920187793l0.6986854460093896,"
- + "-0.6986854460093896l1.3973708920187793,-1.3973708920187793l0.6986854460093896,0l1.3973708920187793,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,"
- + "-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,0l0,-0.6986854460093896l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,0l0,"
- + "-0.6986854460093896l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l2.096056338028169,"
- + "-0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,0l1.3973708920187793,0l1.3973708920187793,"
- + "0l2.096056338028169,0l5.589483568075117,0l1.3973708920187793,0l2.096056338028169,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,"
- + "0l1.3973708920187793,0l1.3973708920187793,0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0l2.096056338028169,1.3973708920187793l0.6986854460093896,"
- + "0l0.6986854460093896,0l0,0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0.6986854460093896l0,"
- + "0.6986854460093896l0.6986854460093896,0l1.3973708920187793,0.6986854460093896l1.3973708920187793,0.6986854460093896l3.493427230046948,0.6986854460093896l1.3973708920187793,"
- + "0.6986854460093896l2.096056338028169,0.6986854460093896l1.3973708920187793,0.6986854460093896l1.3973708920187793,0l1.3973708920187793,0.6986854460093896l0.6986854460093896,"
- + "0l0.6986854460093896,0.6986854460093896l1.3973708920187793,0l0.6986854460093896,0l0.6986854460093896,0l2.7947417840375586,0l1.3973708920187793,0l0.6986854460093896,0l1.3973708920187793,"
- + "0l0.6986854460093896,0l0.6986854460093896,0l1.3973708920187793,0l0.6986854460093896,0l2.7947417840375586,0l0.6986854460093896,0l2.7947417840375586,0l1.3973708920187793,0l0.6986854460093896,"
- + "0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,0l0.6986854460093896,-0.6986854460093896l0.6986854460093896,0"
- );
-
- AnnotationInfo resourceRedactionAnnotation = new AnnotationInfo();
- resourceRedactionAnnotation.setCreatedOn(new Date());
- resourceRedactionAnnotation.setType(AnnotationType.ResourcesRedaction);
- resourceRedactionAnnotation.setPageNumber(0);
- resourceRedactionAnnotation.setBox(new Rectangle(100, 72.7f, 50, 50));
-
- AnnotationInfo textFieldAnnotation = new AnnotationInfo();
- textFieldAnnotation.setCreatedOn(new Date());
- textFieldAnnotation.setType(AnnotationType.TextField);
- textFieldAnnotation.setPageNumber(0);
- textFieldAnnotation.setBox(new Rectangle(100, 72.7f, 50, 50));
- textFieldAnnotation.setFontColor(-15988609);
- textFieldAnnotation.setFieldText("some text");
- textFieldAnnotation.setFontFamily("times new roman");
-
- AnnotationInfo watermarkAnnotation = new AnnotationInfo();
- watermarkAnnotation.setCreatedOn(new Date());
- watermarkAnnotation.setType(AnnotationType.Watermark);
- watermarkAnnotation.setFieldText("This is watermark");
- watermarkAnnotation.setFontFamily("arial");
- watermarkAnnotation.setBox(new Rectangle(100,50,50,0));
- watermarkAnnotation.setFontSize(25);
- watermarkAnnotation.setFontColor(-15988609);
- //Text annotations
-
- AnnotationInfo textAnnotation = new AnnotationInfo();
- textAnnotation.setBox(new Rectangle(50, 510.9f, 454.73f, 29.08f));
- textAnnotation.setPageNumber(0);
- textAnnotation.setSvgPath("[{\"x\":200,\"y\":510.92},{\"x\":454.73,\"y\":510.92},{\"x\":200,\"y\":539.98},{\"x\":454.73,\"y\":539.98}]");
- textAnnotation.setType(AnnotationType.Text);
- textAnnotation.setCreatorName("Anonym A.");
-
- AnnotationInfo strikeoutAnnotation = new AnnotationInfo();
- strikeoutAnnotation.setBox(new Rectangle(0, 510.92f, 454.73f, 29.08f));
- strikeoutAnnotation.setPageNumber(0);
- strikeoutAnnotation.setSvgPath("[{\"x\":0,\"y\":510.92},{\"x\":454.73,\"y\":510.92},{\"x\":0,\"y\":539.98},{\"x\":454.73,\"y\":539.98}]");
- strikeoutAnnotation.setType(AnnotationType.TextStrikeout);
- strikeoutAnnotation.setCreatorName("Anonym A.");
-
- AnnotationInfo underlineAnnotation = new AnnotationInfo();
- underlineAnnotation.setBox(new Rectangle(0, 510.92f, 454.73f, 29.08f));
- underlineAnnotation.setPageNumber(0);
- underlineAnnotation.setSvgPath("[{\"x\":0,\"y\":510.92},{\"x\":454.73,\"y\":510.92},{\"x\":0,\"y\":539.98},{\"x\":454.73,\"y\":539.98}]");
- underlineAnnotation.setType(AnnotationType.TextUnderline);
- underlineAnnotation.setCreatorName("Anonym A.");
-
- annotations.add(pointAnnotation);
- annotations.add(areaAnnotation);
- annotations.add(arrowAnnotation);
- annotations.add(resourceRedactionAnnotation);
- annotations.add(polylineAnnotation);
- annotations.add(watermarkAnnotation);
- annotations.add(textFieldAnnotation);
- annotations.add(textAnnotation);
- annotations.add(strikeoutAnnotation);
- 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);
- }
- //ExEnd:differentAnnotationsForSlides
- }
-
- /*
- * Importing annotations to slide docuemnts
- */
- public static void importingAnnotationsToSlide() throws Throwable{
- //ExStart:importingAnnotationsToSlide
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- FileInputStream input = new FileInputStream(Utilities.storagePath + File.separator + fileName);
-
- AnnotationInfo[] annotations = annotator.importAnnotations(input, DocumentType.Slides);
- // Export imported annotation to another document
- InputStream clearDocument = new FileInputStream(Utilities.storagePath + File.separator + "Clear.pptx");
- InputStream output = annotator.exportAnnotationsToDocument(clearDocument, Arrays.asList(annotations), DocumentType.Slides);
-
- OutputStream fileStream = new FileOutputStream(Utilities.outputPath + File.separator + "slides-annotated.pptx");
- System.out.println(output.available());
- IOUtils.copy(output, fileStream);
- //ExEnd:importingAnnotationsToSlide
- }
-}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/Utilities.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/Utilities.java
deleted file mode 100644
index dcad874..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/Utilities.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package GroupDocs.Annotation.Examples.Java;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-
-import com.groupdocs.annotation.common.license.License;
-import com.groupdocs.annotation.common.license.Metered;
-import com.groupdocs.annotation.domain.AnnotationInfo;
-import com.groupdocs.annotation.domain.DocumentType;
-import com.groupdocs.annotation.domain.PageData;
-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.image.PageImage;
-import com.groupdocs.annotation.domain.options.ImageOptions;
-import com.groupdocs.annotation.handler.AnnotationImageHandler;
-import com.groupdocs.annotation.handler.input.IDocumentDataHandler;
-
-
-public class Utilities {
- // ExStart:commonutilities
- public final static String storagePath = "./Data/SourceFiles/";
- public final static String outputPath = "./Data/OutputFiles/";
- public static final String licensePath = "E://GroupDocs.Total.Java.lic";
- // ExEnd::commonutilities
-
- // Applies License
- public static void applyLicenseFromFile() {
- //ExStart:applyLicenseFromFile
- try {
- // Setup license
- License lic = new License();
- lic.setLicense(licensePath);
- } catch (Exception exp) {
- System.out.println("Exception: " + exp.getMessage());
- exp.printStackTrace();
- }
- //ExEnd:applyLicenseFromFile
- }
-
- public static void setMeteredLicense() throws Exception{
- //ExStart:setMeteredLicense
- String PublicKey = ""; // Your public license key
- String PrivateKey = ""; // Your private license key
- Metered metered = new Metered();
- metered.setMeteredKey(PublicKey, PrivateKey);
- //ExEnd:setMeteredLicense
- }
- // Returns AnnotationConfig configurations
- public static AnnotationConfig getConfiguration() {
- //ExStart:getConfiguration
- try {
- // Setup annotation configuration
- AnnotationConfig conversionConfig = new AnnotationConfig();
- conversionConfig.setStoragePath(storagePath);
- return conversionConfig;
- } catch (Exception exp) {
- System.out.println("Exception: " + exp.getMessage());
- exp.printStackTrace();
- return null;
- }
- //ExEnd:getConfiguration
- }
-
- // Gets Image Representation
- public static void getImageRepresentation(String fileName) {
- //ExStart:getImageRepresentation
- try {
- InputStream document = new FileInputStream(storagePath + File.separator + fileName);
- AnnotationConfig cfg = getConfiguration();
- AnnotationImageHandler annotationHandler = new AnnotationImageHandler(cfg);
- List images = annotationHandler.getPages(document, new ImageOptions());
- // Save result stream to file.
- OutputStream outputStream = new FileOutputStream(Utilities.outputPath + File.separator + "image.png");
- final PageImage pageImage = images.get(0);
- IOUtils.copy(pageImage.getStream(), outputStream);
- System.out.println("Document exported!");
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:getImageRepresentation
- }
-
- // Get text coordinates
- public static void getTextCoordinates(String fileName) {
- //ExStart:getTextCoordinates
- try {
- AnnotationConfig cfg = getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- DocumentInfoContainer documentInfoContainer = annotator.getDocumentInfo(fileName);
- // Go through all pages
- for (PageData pageData : documentInfoContainer.getPages()) {
- System.out.println("Page number: " + pageData.getNumber());
- // Go through all page rows
- for (int i = 0; i < pageData.getRows().size(); i++) {
- RowData rowData = pageData.getRows().get(i);
- // Write data to console
- System.out.println("Row: " + (i + 1));
- System.out.println("Text: " + rowData.getText());
- System.out.println("Text width: " + rowData.getLineWidth());
- System.out.println("Text height: " + rowData.getLineHeight());
- System.out.println("Distance from left: " + rowData.getLineLeft());
- System.out.println("Distance from top: " + rowData.getLineTop());
- // Get words
- String[] words = rowData.getText().split(" ");
- // Go through all word coordinates
- for (int j = 0; j < words.length; j++) {
- int coordinateIndex = j == 0 ? 0 : j + 1;
- // Write data to console
- System.out.println();
- System.out.println("Word:'" + words[j] + "'");
- System.out.println(
- "Word distance from left: " + rowData.getTextCoordinates().get(coordinateIndex));
- System.out.println("Word width: " + rowData.getTextCoordinates().get(coordinateIndex + 1));
- System.out.println();
- }
- }
- }
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:getTextCoordinates
- }
-}
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/WordsAnnotation.java b/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/WordsAnnotation.java
deleted file mode 100644
index 1776822..0000000
--- a/Examples/GroupDocs.Annotation.Examples.Java/src/main/java/GroupDocs/Annotation/Examples/Java/WordsAnnotation.java
+++ /dev/null
@@ -1,543 +0,0 @@
-package GroupDocs.Annotation.Examples.Java;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-
-import com.groupdocs.annotation.domain.AnnotationInfo;
-import com.groupdocs.annotation.domain.AnnotationType;
-import com.groupdocs.annotation.domain.DocumentType;
-import com.groupdocs.annotation.domain.Rectangle;
-import com.groupdocs.annotation.domain.config.AnnotationConfig;
-import com.groupdocs.annotation.handler.AnnotationImageHandler;
-
-public class WordsAnnotation {
-
- // region initialize document name
-
- /*
- * document name
- */
- public static String fileName = "sample.docx";
-
- // region Working with annotation in Words
-
- /*
- * add different annotations in words
- */
- public static void addDifferentAnnotationInWords() {
- //ExStart:addDifferentAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // initialize possible types of annotations
- AnnotationInfo textAnnotation = new AnnotationInfo();
- textAnnotation.setPageNumber(1);
- textAnnotation.setSvgPath(
- "[{\"x\":186.698,\"y\":706.196},{\"x\":318.41201,\"y\":706.196},{\"x\":186.698,\"y\":697.196},{\"x\":318.41201,\"y\":697.196}]");
- textAnnotation.setType(AnnotationType.Text);
- textAnnotation.setText("Comment");
- AnnotationInfo areaAnnnotation = new AnnotationInfo();
- areaAnnnotation.setBackgroundColor(11111111);
- areaAnnnotation.setBox(new Rectangle(87.9f, 276.5f, 435.7f, 87f));
- areaAnnnotation.setPageNumber(1);
- areaAnnnotation.setType(AnnotationType.Area);
- AnnotationInfo strikeoutAnnotation = new AnnotationInfo();
- strikeoutAnnotation.setBox(new Rectangle(87.9f, 276.5f, 435.7f, 87f));
- strikeoutAnnotation.setPageNumber(1);
- strikeoutAnnotation.setPenColor(1201033);
- strikeoutAnnotation.setSvgPath(
- "[{\"x\":208.392,\"y\":313.088},{\"x\":519.659,\"y\":313.088},{\"x\":208.392,\"y\":304.088},{\"x\":519.659,\"y\":304.088}]");
- strikeoutAnnotation.setType(AnnotationType.TextStrikeout);
- AnnotationInfo textFieldAnnotation = new AnnotationInfo();
- textFieldAnnotation.setFieldText("text in the box");
- textFieldAnnotation.setFontFamily("Arial");
- textFieldAnnotation.setFontSize(10);
- textFieldAnnotation.setBox(new Rectangle(92f, 73f, 106f, 45f));
- textFieldAnnotation.setPageNumber(1);
- textFieldAnnotation.setType(AnnotationType.TextField);
- AnnotationInfo textReplacementAnnotation = new AnnotationInfo();
- textReplacementAnnotation.setFieldText(" \"REPLACED TEXT\" ");
- textReplacementAnnotation.setFontSize(10);
- textReplacementAnnotation.setSvgPath(
- "[{\"x\":251.224,\"y\":637.20401},{\"x\":327.89,\"y\":637.20401},{\"x\":251.224,\"y\":628.20401},{\"x\":327.89,\"y\":628.20401}]");
- textReplacementAnnotation.setPageNumber(1);
- textReplacementAnnotation.setType(AnnotationType.TextReplacement);
- AnnotationInfo arrowAnnotation = new AnnotationInfo();
- arrowAnnotation.setBox(new Rectangle(479f, 218f, -261f, -89f));
- arrowAnnotation.setPageNumber(1);
- arrowAnnotation.setType(AnnotationType.Arrow);
- AnnotationInfo textRedactionAnnotation = new AnnotationInfo();
- textRedactionAnnotation.setPageNumber(2);
- textRedactionAnnotation.setSvgPath(
- "[{\"x\":72,\"y\":676.07},{\"x\":196.427,\"y\":676.074},{\"x\":72,\"y\":662.674},{\"x\":196.427,\"y\":662.674}]");
- textRedactionAnnotation.setType(AnnotationType.TextRedaction);
- AnnotationInfo resourceRedactionAnnotation = new AnnotationInfo();
- resourceRedactionAnnotation.setBox(new Rectangle(69f, 337f, 449f, 118f));
- resourceRedactionAnnotation.setPageNumber(1);
- resourceRedactionAnnotation.setType(AnnotationType.ResourcesRedaction);
- AnnotationInfo underlineAnnotation = new AnnotationInfo();
- underlineAnnotation.setPageNumber(2);
- underlineAnnotation.setSvgPath(
- "[{\"x\":415.17499,\"y\":628.874},{\"x\":511.85101,\"y\":628.874},{\"x\":415.17499,\"y\":619.874},{\"x\":511.85101,\"y\":619.874}]");
- underlineAnnotation.setType(AnnotationType.TextUnderline);
- // * annotations.add(textAnnotation);
- annotations.add(areaAnnnotation);
- // * annotations.add(strikeoutAnnotation);
- annotations.add(textFieldAnnotation);
- // ** annotations.add(textReplacementAnnotation);
- annotations.add(arrowAnnotation);
- // * annotations.add(textRedactionAnnotation);
- annotations.add(resourceRedactionAnnotation);
- // * annotations.add(underlineAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addDifferentAnnotationInWords
- }
-
- /*
- * add text annotation in words
- */
- public static void addTextAnnotationInWords() {
- //ExStart:addTextAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // init possible types of annotations
- AnnotationInfo textAnnotation = new AnnotationInfo();
- textAnnotation.setPageNumber(1);
- textAnnotation.setSvgPath(
- "[{\"x\":186.698,\"y\":706.196},{\"x\":318.41201,\"y\":706.196},{\"x\":186.698,\"y\":697.196},{\"x\":318.41201,\"y\":697.196}]");
- textAnnotation.setType(AnnotationType.Text);
- textAnnotation.setText("Comment");
- annotations.add(textAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addTextAnnotationInWords
- }
-
- /*
- * add area annotation with replies in words
- */
- public static void addAreaAnnotationWithRepliesInWords() {
- //ExStart:addAreaAnnotationWithRepliesInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // initialize possible types of annotations
- AnnotationInfo areaAnnnotation = new AnnotationInfo();
- areaAnnnotation.setBackgroundColor(11111111);
- areaAnnnotation.setBox(new Rectangle(87.9f, 276.5f, 435.7f, 87f));
- areaAnnnotation.setPageNumber(1);
- areaAnnnotation.setType(AnnotationType.Area);
- annotations.add(areaAnnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addAreaAnnotationWithRepliesInWords
- }
-
- /*
- * add strikeout annotation in words
- */
- public static void addStrikeoutAnnotationInWords() {
- //ExStart:addStrikeoutAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // init strikeout annotations
- AnnotationInfo strikeoutAnnotation = new AnnotationInfo();
- strikeoutAnnotation.setBox(new Rectangle(87.9f, 276.5f, 435.7f, 87f));
- strikeoutAnnotation.setPageNumber(1);
- strikeoutAnnotation.setPenColor(1201033);
- strikeoutAnnotation.setSvgPath(
- "[{\"x\":208.392,\"y\":313.088},{\"x\":519.659,\"y\":313.088},{\"x\":208.392,\"y\":304.088},{\"x\":519.659,\"y\":304.088}]");
- strikeoutAnnotation.setType(AnnotationType.TextStrikeout);
- annotations.add(strikeoutAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addStrikeoutAnnotationInWords
- }
-
- /*
- * add text field annotation in words
- */
- public static void addTextFieldAnnotationInWords() {
- //ExStart:addTextFieldAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // init text Field annotations
- AnnotationInfo textFieldAnnotation = new AnnotationInfo();
- textFieldAnnotation.setFieldText("text in the box");
- textFieldAnnotation.setFontFamily("Arial");
- textFieldAnnotation.setFontSize(10);
- textFieldAnnotation.setBox(new Rectangle(92f, 73f, 106f, 45f));
- textFieldAnnotation.setPageNumber(1);
- textFieldAnnotation.setType(AnnotationType.TextField);
- annotations.add(textFieldAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addTextFieldAnnotationInWords
- }
-
- /*
- * add text replacement annotation in words
- */
- public static void addTextReplacementAnnotationInWords() {
- //ExStart:addTextReplacementAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // init text replacement annotations
- AnnotationInfo textReplacementAnnotation = new AnnotationInfo();
- textReplacementAnnotation.setFieldText(" \"REPLACED TEXT\" ");
- textReplacementAnnotation.setFontSize(10);
- textReplacementAnnotation.setSvgPath(
- "[{\"x\":251.224,\"y\":637.20401},{\"x\":327.89,\"y\":637.20401},{\"x\":251.224,\"y\":628.20401},{\"x\":327.89,\"y\":628.20401}]");
- textReplacementAnnotation.setPageNumber(1);
- textReplacementAnnotation.setType(AnnotationType.TextReplacement);
- annotations.add(textReplacementAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addTextReplacementAnnotationInWords
- }
-
- /*
- * add arrow annotation in words
- */
- public static void addArrowAnnotationInWords() {
- //ExStart:addArrowAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // init arrow annotations
- AnnotationInfo arrowAnnotation = new AnnotationInfo();
- arrowAnnotation.setBox(new Rectangle(479f, 218f, -261f, -89f));
- arrowAnnotation.setPageNumber(1);
- arrowAnnotation.setType(AnnotationType.Arrow);
- annotations.add(arrowAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addArrowAnnotationInWords
- }
-
- /*
- * add text redaction annotation in words
- */
- public static void addTextRedactionAnnotationInWords() {
- //ExStart:addTextRedactionAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // init text redaction annotations
- AnnotationInfo textRedactionAnnotation = new AnnotationInfo();
- textRedactionAnnotation.setPageNumber(2);
- textRedactionAnnotation.setSvgPath(
- "[{\"x\":72,\"y\":676.07},{\"x\":196.427,\"y\":676.074},{\"x\":72,\"y\":662.674},{\"x\":196.427,\"y\":662.674}]");
- textRedactionAnnotation.setType(AnnotationType.TextRedaction);
- annotations.add(textRedactionAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addTextRedactionAnnotationInWords
- }
-
- /*
- * add resource redaction annotation in words
- */
- public static void addResourceRedactionAnnotationInWords() {
- //ExStart:addResourceRedactionAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // init possible types of annotations
- AnnotationInfo resourceRedactionAnnotation = new AnnotationInfo();
- resourceRedactionAnnotation.setBox(new Rectangle(69f, 337f, 449f, 118f));
- resourceRedactionAnnotation.setPageNumber(1);
- resourceRedactionAnnotation.setType(AnnotationType.ResourcesRedaction);
- annotations.add(resourceRedactionAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addResourceRedactionAnnotationInWords
- }
-
- /*
- * add underline annotation in words
- */
- public static void addUnderlineAnnotationInWords() {
- //ExStart:addUnderlineAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // init underline annotations
- AnnotationInfo underlineAnnotation = new AnnotationInfo();
- underlineAnnotation.setPageNumber(2);
- underlineAnnotation.setSvgPath(
- "[{\"x\":415.17499,\"y\":628.874},{\"x\":511.85101,\"y\":628.874},{\"x\":415.17499,\"y\":619.874},{\"x\":511.85101,\"y\":619.874}]");
- underlineAnnotation.setType(AnnotationType.TextUnderline);
- annotations.add(underlineAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addUnderlineAnnotationInWords
- }
- /*
- * import annotations from word docs
- */
- public static void importingAnnotationsFromWordDoc() throws Throwable{
- //ExStart:importingAnnotationsFromWordDoc
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- // Importing annotations from Words document
- FileInputStream stream = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- AnnotationInfo[] annotations = annotator.importAnnotations(stream, DocumentType.Words);
-
- // Export imported annotation to another document
- InputStream clearDocument = new FileInputStream(Utilities.storagePath + File.separator + "Clear.docx");
- InputStream output = annotator.exportAnnotationsToDocument(clearDocument, Arrays.asList(annotations), DocumentType.Words);
-
- // Save results after export
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(output.available());
- IOUtils.copy(output, fileStream);
- //ExEnd:importingAnnotationsFromWordDoc
- }
-
- public static void addDistanceAnnotationInWords() {
- //ExStart:addDistanceAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Distance annotation
- AnnotationInfo distanceAnnotation = new AnnotationInfo();
- distanceAnnotation.setCreatedOn(new Date());
- distanceAnnotation.setType(AnnotationType.Distance);
- distanceAnnotation.setBox(new Rectangle((float)248.73202514648438, (float)287.85653686523438, (float)115.9178466796875, (float)25.143020629882812));
- distanceAnnotation.setSvgPath("M248.73201877934272,295.5439436619718 l115.28309859154929,-4.192112676056338");
-
- annotations.add(distanceAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addDistanceAnnotationInWords
- }
-
- public static void addPolylineAnnotationInWords() {
- //ExStart:addPolylineAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Polyline annotation
- AnnotationInfo polylineAnnotation = new AnnotationInfo();
- polylineAnnotation.setCreatedOn(new Date());
- polylineAnnotation.setType(AnnotationType.Polyline);
- polylineAnnotation.setBox(new Rectangle(206.3f, 106.61f, 456.04f, 307.97f));
- polylineAnnotation.setSvgPath("M436.293427230047,148.06338028169014l0,-0.9870892018779343l-0.9870892018779343,-0.9870892018779343l-1.9741784037558685,-0.9870892018779343l-0.9870892018779343,0l-0.9870892018779343,-0.9870892018779343l-1.9741784037558685,-0.9870892018779343l-0.9870892018779343,0l-1.9741784037558685,-0.9870892018779343l-1.9741784037558685,0l-4.935446009389671,-1.9741784037558685l-1.9741784037558685,0l-1.9741784037558685,-0.9870892018779343l-1.9741784037558685,0l-1.9741784037558685,-0.9870892018779343l-2.961267605633803,0l-2.961267605633803,0l-2.961267605633803,0l-2.961267605633803,0l-2.961267605633803,0l-2.961267605633803,0l-1.9741784037558685,0l-3.948356807511737,0l-2.961267605633803,0l-3.948356807511737,0l-4.935446009389671,0l-3.948356807511737,0.9870892018779343l-4.935446009389671,0.9870892018779343l-6.90962441314554,0l-3.948356807511737,0.9870892018779343l-3.948356807511737,0l-2.961267605633803,1.9741784037558685l-3.948356807511737,0.9870892018779343l-6.90962441314554,1.9741784037558685l-6.90962441314554,0.9870892018779343l-12.832159624413146,2.961267605633803l-6.90962441314554,1.9741784037558685l-5.922535211267606,0.9870892018779343l-5.922535211267606,1.9741784037558685l-5.922535211267606,1.9741784037558685l-5.922535211267606,0.9870892018779343l-4.935446009389671,1.9741784037558685l-5.922535211267606,1.9741784037558685l-5.922535211267606,1.9741784037558685l-4.935446009389671,1.9741784037558685l-5.922535211267606,2.961267605633803l-5.922535211267606,3.948356807511737l-5.922535211267606,3.948356807511737l-4.935446009389671,3.948356807511737l-5.922535211267606,3.948356807511737l-5.922535211267606,3.948356807511737l-3.948356807511737,5.922535211267606l-3.948356807511737,4.935446009389671l-3.948356807511737,5.922535211267606l-3.948356807511737,6.90962441314554l-3.948356807511737,7.896713615023474l-0.9870892018779343,6.90962441314554l-1.9741784037558685,7.896713615023474l-1.9741784037558685,6.90962441314554l-0.9870892018779343,7.896713615023474l0,12.832159624413146l0,7.896713615023474l0,7.896713615023474l0.9870892018779343,7.896713615023474l1.9741784037558685,5.922535211267606l2.961267605633803,5.922535211267606l0.9870892018779343,5.922535211267606l2.961267605633803,6.90962441314554l3.948356807511737,5.922535211267606l4.935446009389671,4.935446009389671l3.948356807511737,5.922535211267606l3.948356807511737,5.922535211267606l3.948356807511737,5.922535211267606l5.922535211267606,5.922535211267606l5.922535211267606,5.922535211267606l5.922535211267606,5.922535211267606l6.90962441314554,5.922535211267606l7.896713615023474,5.922535211267606l7.896713615023474,5.922535211267606l17.767605633802816,8.883802816901408l11.845070422535212,3.948356807511737l11.845070422535212,4.935446009389671l23.690140845070424,8.883802816901408l41.45774647887324,6.90962441314554l31.586854460093896,3.948356807511737l16.780516431924884,0l16.780516431924884,1.9741784037558685l16.780516431924884,0l16.780516431924884,0l16.780516431924884,0l16.780516431924884,0l16.780516431924884,-1.9741784037558685l14.806338028169014,-1.9741784037558685l14.806338028169014,-1.9741784037558685l12.832159624413146,-1.9741784037558685l10.857981220657276,-2.961267605633803l10.857981220657276,-2.961267605633803l8.883802816901408,-4.935446009389671l8.883802816901408,-4.935446009389671l6.90962441314554,-6.90962441314554l6.90962441314554,-6.90962441314554l8.883802816901408,-16.780516431924884l4.935446009389671,-7.896713615023474l3.948356807511737,-8.883802816901408l4.935446009389671,-7.896713615023474l4.935446009389671,-7.896713615023474l3.948356807511737,-13.81924882629108l1.9741784037558685,-18.754694835680752l0,-7.896713615023474l0,-12.832159624413146l-1.9741784037558685,-15.793427230046948l-1.9741784037558685,-15.793427230046948l-4.935446009389671,-15.793427230046948l-8.883802816901408,-15.793427230046948l-12.832159624413146,-23.690140845070424l-10.857981220657276,-10.857981220657276l-5.922535211267606,-3.948356807511737l-12.832159624413146,-8.883802816901408l-9.870892018779342,-8.883802816901408l-5.922535211267606,-3.948356807511737l-12.832159624413146,-5.922535211267606l-15.793427230046948,-8.883802816901408l-13.81924882629108,-4.935446009389671l-11.845070422535212,-2.961267605633803l-11.845070422535212,-3.948356807511737l-11.845070422535212,-3.948356807511737l-5.922535211267606,-1.9741784037558685l-11.845070422535212,-2.961267605633803l-11.845070422535212,-1.9741784037558685l-5.922535211267606,-0.9870892018779343l-10.857981220657276,-1.9741784037558685l-10.857981220657276,-2.961267605633803l-9.870892018779342,0l-0.9870892018779343,0l-0.9870892018779343,0l-0.9870892018779343,0l-0.9870892018779343,0l0,-0.9870892018779343l1.9741784037558685,0");
-
- annotations.add(polylineAnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addPolylineAnnotationInWords
- }
-
- public static void addWatermarkAnnotationInWords() {
- //ExStart:addWatermarkAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Watermark annotations
- AnnotationInfo watermarkAnnnotation = new AnnotationInfo();
- watermarkAnnnotation.setCreatedOn(new Date());
- watermarkAnnnotation.setFieldText("Watermark text");
- watermarkAnnnotation.setFontColor(16711680);
- watermarkAnnnotation.setFontFamily("Microsoft Sans Serif");
- watermarkAnnnotation.setFontSize(17);
- watermarkAnnnotation.setOpacity(0.3);
- watermarkAnnnotation.setType(AnnotationType.Watermark);
-
- annotations.add(watermarkAnnnotation);
-
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addWatermarkAnnotationInWords
- }
-
- public static void addPointAnnotationInWords() {
- //ExStart:addPointAnnotationInWords
- try {
- AnnotationConfig cfg = Utilities.getConfiguration();
- AnnotationImageHandler annotator = new AnnotationImageHandler(cfg);
- InputStream cleanDoc = new FileInputStream(Utilities.storagePath + File.separator + fileName);
- List annotations = new ArrayList();
- // Point annotation
- AnnotationInfo pointAnnnotation = new AnnotationInfo();
- pointAnnnotation.setCreatedOn(new Date());
- pointAnnnotation.setType(AnnotationType.Point);
- pointAnnnotation.setBox(new Rectangle(150.32f, 99.22f, 0, 0));
- pointAnnnotation.setPageNumber(0);
-
- annotations.add(pointAnnnotation);
- // Add annotation to the document
- InputStream result = annotator.exportAnnotationsToDocument(cleanDoc, annotations, DocumentType.Words);
- // Save result stream to file.
- OutputStream fileStream = new FileOutputStream(
- Utilities.outputPath + File.separator + "words-annotated.docx");
- System.out.println(result.available());
- IOUtils.copy(result, fileStream);
- } catch (Exception e) {
- System.out.println("Exception: " + e.getMessage());
- e.printStackTrace();
- }
- //ExEnd:addPointAnnotationInWords
- }
-}
diff --git a/Examples/README.md b/Examples/README.md
index 96adf0b..e026112 100644
--- a/Examples/README.md
+++ b/Examples/README.md
@@ -1,28 +1,26 @@
-# GroupDocs.Annotation for Java Examples
+# GroupDocs_Annotation_Java
-This package contains Java Example Projects for [GroupDocs.Annotation for Java](#) and sample input templates used in the examples.
+This package contains [Examples](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java/tree/master/Examples) that will help you in understanding the API's working and writing your own applications.
+
+GroupDocs.Annotation is essentially devised to add annotations in documents within a Java applications. API comes with an extensive number of markup tools. These tools permit users to highlight, strikeout, and comment on text and images. This doesn't end up here user can avail numerous properties to control annotation's appearance in the document.
-
+
+
-# How to Run the Examples?
-
-It is assumed that maven is installed and configured in your system path. You can edit the project by opening in your favorite IDE like NetBeans, Eclipse, and IntelliJ IDEA.
-
-You may find following resources helpful:
-
-1. Learn how to install and configure Maven - Environment Setup
-2. Maven support for NetBeans
-3. Maven support for IntelliJ IDEA
-4. Maven support for Eclipse IDE
-
-# Apply License
+Directory | Description
+--------- | -----------
+[Examples](https://github.com/groupdocs-annotation/GroupDocs.Annotation-for-Java/tree/master/Examples) | Contains the package of all Java examples and sample files that will help you learn how to use product features.
+## Resources
-Follow below steps if you have product license
++ **Website:** [www.groupdocs.com](http://www.groupdocs.com)
++ **Product Home:** [GroupDocs.Annotation for Java](#)
++ **Product API:** [API of GroupDocs.Annotation for Java](#)
++ **Download:** [Download GroupDocs.Annotation for Java](#)
++ **Documentation:** [GroupDocs.Annotation for Java Documentation](#)
++ **Forum:** [GroupDocs.Annotation for Java Forum](#)
++ **Blog:** [GroupDocs.Annotation for Java Blog](#)
-1. Open Utilities.java.
-2. Set "licensePath" variable to your license path.
-3. Call applyLicenseFromFile method from MainClass
\ No newline at end of file
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/DEPOSIT.eml b/Examples/Resources/SampleFiles/DEPOSIT.eml
similarity index 100%
rename from Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/DEPOSIT.eml
rename to Examples/Resources/SampleFiles/DEPOSIT.eml
diff --git a/Examples/Resources/SampleFiles/annotated.pdf b/Examples/Resources/SampleFiles/annotated.pdf
new file mode 100644
index 0000000..31934c8
Binary files /dev/null and b/Examples/Resources/SampleFiles/annotated.pdf differ
diff --git a/Examples/Resources/SampleFiles/annotated_area_replies_5.pdf b/Examples/Resources/SampleFiles/annotated_area_replies_5.pdf
new file mode 100644
index 0000000..6d8799f
Binary files /dev/null and b/Examples/Resources/SampleFiles/annotated_area_replies_5.pdf differ
diff --git a/Examples/Resources/SampleFiles/annotated_big.pdf b/Examples/Resources/SampleFiles/annotated_big.pdf
new file mode 100644
index 0000000..5426aeb
Binary files /dev/null and b/Examples/Resources/SampleFiles/annotated_big.pdf differ
diff --git a/Examples/Resources/SampleFiles/annotated_import.pdf b/Examples/Resources/SampleFiles/annotated_import.pdf
new file mode 100644
index 0000000..392350e
Binary files /dev/null and b/Examples/Resources/SampleFiles/annotated_import.pdf differ
diff --git a/Examples/Resources/SampleFiles/annotated_with_replies.pdf b/Examples/Resources/SampleFiles/annotated_with_replies.pdf
new file mode 100644
index 0000000..087746c
Binary files /dev/null and b/Examples/Resources/SampleFiles/annotated_with_replies.pdf differ
diff --git a/Examples/Resources/SampleFiles/annotated_with_replies_new.pdf b/Examples/Resources/SampleFiles/annotated_with_replies_new.pdf
new file mode 100644
index 0000000..b5c2d71
Binary files /dev/null and b/Examples/Resources/SampleFiles/annotated_with_replies_new.pdf differ
diff --git a/Examples/Resources/SampleFiles/annotated_with_replies_new_old.pdf b/Examples/Resources/SampleFiles/annotated_with_replies_new_old.pdf
new file mode 100644
index 0000000..a6cf83b
Binary files /dev/null and b/Examples/Resources/SampleFiles/annotated_with_replies_new_old.pdf differ
diff --git a/Examples/Resources/SampleFiles/annotation.xml b/Examples/Resources/SampleFiles/annotation.xml
new file mode 100644
index 0000000..28f21d6
--- /dev/null
+++ b/Examples/Resources/SampleFiles/annotation.xml
@@ -0,0 +1,22 @@
+
+
+
+ 0
+ 0001-01-01T00:00:00
+ This is rectangle annotation
+
+
+ Area
+ 65535
+
+ 100
+ 100
+ 100
+ 100
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Examples/Resources/SampleFiles/clear.pdf b/Examples/Resources/SampleFiles/clear.pdf
new file mode 100644
index 0000000..725a073
Binary files /dev/null and b/Examples/Resources/SampleFiles/clear.pdf differ
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/excel.xlsx b/Examples/Resources/SampleFiles/excel.xlsx
similarity index 100%
rename from Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/excel.xlsx
rename to Examples/Resources/SampleFiles/excel.xlsx
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/image.PNG b/Examples/Resources/SampleFiles/image.PNG
similarity index 100%
rename from Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/image.PNG
rename to Examples/Resources/SampleFiles/image.PNG
diff --git a/Examples/Resources/SampleFiles/input.pdf b/Examples/Resources/SampleFiles/input.pdf
new file mode 100644
index 0000000..4468713
Binary files /dev/null and b/Examples/Resources/SampleFiles/input.pdf differ
diff --git a/Examples/Resources/SampleFiles/input.xlsx b/Examples/Resources/SampleFiles/input.xlsx
new file mode 100644
index 0000000..171d948
Binary files /dev/null and b/Examples/Resources/SampleFiles/input.xlsx differ
diff --git a/Examples/Resources/SampleFiles/input_protected.pdf b/Examples/Resources/SampleFiles/input_protected.pdf
new file mode 100644
index 0000000..aec9278
Binary files /dev/null and b/Examples/Resources/SampleFiles/input_protected.pdf differ
diff --git a/Examples/Resources/SampleFiles/remove_anno_1139.pdf b/Examples/Resources/SampleFiles/remove_anno_1139.pdf
new file mode 100644
index 0000000..72f6897
Binary files /dev/null and b/Examples/Resources/SampleFiles/remove_anno_1139.pdf differ
diff --git a/Examples/Resources/SampleFiles/remove_anno_1139_1.pdf b/Examples/Resources/SampleFiles/remove_anno_1139_1.pdf
new file mode 100644
index 0000000..44f9728
Binary files /dev/null and b/Examples/Resources/SampleFiles/remove_anno_1139_1.pdf differ
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/sample.docx b/Examples/Resources/SampleFiles/sample.docx
similarity index 100%
rename from Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/sample.docx
rename to Examples/Resources/SampleFiles/sample.docx
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/sample.pdf b/Examples/Resources/SampleFiles/sample.pdf
similarity index 100%
rename from Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/sample.pdf
rename to Examples/Resources/SampleFiles/sample.pdf
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/sample.vsd b/Examples/Resources/SampleFiles/sample.vsd
similarity index 100%
rename from Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/sample.vsd
rename to Examples/Resources/SampleFiles/sample.vsd
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/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/slide.pptx b/Examples/Resources/SampleFiles/slide.pptx
similarity index 100%
rename from Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/slide.pptx
rename to Examples/Resources/SampleFiles/slide.pptx
diff --git a/Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/source.html b/Examples/Resources/SampleFiles/source.html
similarity index 100%
rename from Examples/GroupDocs.Annotation.Examples.Java/Data/SourceFiles/source.html
rename to Examples/Resources/SampleFiles/source.html
diff --git a/Examples/Resources/SampleFiles/source.pdf b/Examples/Resources/SampleFiles/source.pdf
new file mode 100644
index 0000000..7172262
Binary files /dev/null and b/Examples/Resources/SampleFiles/source.pdf differ
diff --git a/Examples/pom.xml b/Examples/pom.xml
new file mode 100644
index 0000000..9cb67a7
--- /dev/null
+++ b/Examples/pom.xml
@@ -0,0 +1,53 @@
+
+ 4.0.0
+ GroupDocs.Annotation-for-Java
+ GroupDocs.Annotation-for-Java
+ 0.0.1-SNAPSHOT
+
+ 8
+ 8
+
+
+
+
+ commons-net
+ commons-net
+ 3.6
+
+
+ commons-io
+ commons-io
+ 2.7
+
+
+ com.groupdocs
+ groupdocs-annotation
+ 24.6
+
+
+
+
+ GroupDocsArtifactRepository
+ GroupDocs Artifact Repository
+ https://repository.groupdocs.com/repo/
+
+
+ GroupDocsJavaAPI
+ GroupDocs Java API
+ https://artifact.groupdocs.com/repo/
+
+
+ maven-central
+ https://repo1.maven.org/maven2
+
+
+
+
+
+ src/main/resources
+ true
+
+
+
+
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/Constants.java b/Examples/src/main/java/com/groupdocs/annotation/examples/Constants.java
new file mode 100644
index 0000000..b7aa5bf
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/Constants.java
@@ -0,0 +1,38 @@
+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_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");
+ public static String ANNOTATED_WITH_REPLIES_NEW = getSampleFilePath("annotated_with_replies_new.pdf");
+ public static String ANNOTATED_AREA_REPLIES_5 = getSampleFilePath("annotated_area_replies_5.pdf");
+
+ public static String INPUT_PROTECTED = getSampleFilePath("input_protected.pdf");
+ public static String RESULT = getSampleFilePath("result.pdf");
+ public static String ANNOTATED = getSampleFilePath("annotated.pdf");
+ 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");
+
+ public static String INPUT_CELL = getSampleFilePath("input.xlsx");
+
+ private static String getSampleFilePath(String fileName) {
+ return PROJECT_PATH + SamplesPath + fileName;
+ }
+
+ public static String getOutputFilePath(String fileName, String fileExtension) {
+ return PROJECT_PATH + OutputPath + fileName + "." + fileExtension;
+ }
+
+ public static String getPagePreviewPathFormat(String fileNameFormat) {
+ return PROJECT_PATH + OutputPath + fileNameFormat;
+ }
+}
\ No newline at end of file
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/RunExamples.java b/Examples/src/main/java/com/groupdocs/annotation/examples/RunExamples.java
new file mode 100644
index 0000000..995a86f
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/RunExamples.java
@@ -0,0 +1,144 @@
+package com.groupdocs.annotation.examples;
+
+import com.groupdocs.annotation.examples.advanced_usage.*;
+import com.groupdocs.annotation.examples.advanced_usage.loading.*;
+import com.groupdocs.annotation.examples.advanced_usage.loading.loading_documents_from_different_sources.*;
+import com.groupdocs.annotation.examples.advanced_usage.saving.*;
+import com.groupdocs.annotation.examples.basic_usage.*;
+import com.groupdocs.annotation.examples.basic_usage.add_annotation_to_the_document.*;
+import com.groupdocs.annotation.examples.quick_start.*;
+import java.io.IOException;
+
+
+public class RunExamples {
+
+ public static void main(String[] args) throws IOException {
+ 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
+
+ // Quick Start
+ SetLicenseFromFile.run();
+// SetLicenseFromStream.run();
+// SetMeteredLicense.run();
+
+ // Get supported file formats
+// GetSupportedFileFormats.run();
+
+ // Get file info
+// GetFileInfo.run(Constants.INPUT_PDF);
+// GetFileInfo.run(Constants.INPUT_DOC);
+// GetFileInfo.run(Constants.INPUT_CELL);
+
+ // Extract annotations from document
+// 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(Constants.INPUT_PDF);
+// GenerateDocumentPagesPreview.run(Constants.INPUT_DOC);
+// GenerateDocumentPagesPreview.run(Constants.INPUT_CELL);
+
+ // Saving specific page range
+// SavingSpecificPageRange.run(Constants.INPUT_PDF);
+
+ // Saving only pages with annotations
+// SavingOnlyPagesWithAnnotations.run(Constants.INPUT_PDF);
+
+ // Filtering annotation types
+// FilteringAnnotationTypes.run(Constants.INPUT_PDF);
+
+ // Add area annotation
+// AddAreaAnnotation.run();
+
+ // Add arrow annotation
+// AddArrowAnnotation.run();
+
+ // Add distance annotation
+// AddDistanceAnnotation.run();
+
+ // Add ellipse annotation
+// AddEllipseAnnotation.run();
+
+ // Add link annotation
+// AddLinkAnnotation.run();
+
+ // Add point annotation
+// AddPointAnnotation.run();
+
+ // Add resources redaction annotation
+// AddResourcesRedactionAnnotation.run();
+
+ // Add text highlight annotation
+// AddTextHighlightAnnotation.run();
+
+ // Add text field annotation
+// AddTextFieldAnnotation.run();
+
+ // Add text redaction annotation
+// AddTextRedactionAnnotation.run();
+
+ // Add text replacement annotation
+// AddTextReplacementAnnotation.run();
+
+ // Add text strikeout annotation
+ AddTextStrikeoutAnnotation.run();
+
+ // Add polyline annotation
+// AddPolylineAnnotation.run();
+
+ // Add underline annotation
+ AddTextUnderlineAnnotation.run();
+
+ // Add watermark annotation
+// AddWatermarkAnnotation.run();
+
+ // Add replies annotation
+// AddReplies.run();
+
+ // Remove replies
+// RemoveReplies.run();
+
+ // Remove replies by Id
+// RemoveRepliesById.run();
+
+ // Remove replies by user name
+// RemoveRepliesByUserName.run();
+
+ // Update annotation
+// UpdateAnnotation.run();
+
+ // Load document from local disk
+// LoadDocumentFromLocalDisk.run();
+
+ // Load document from stream
+// LoadDocumentFromStream.run();
+
+ // Load password-protected documents
+// LoadPasswordProtectedDocuments.run();
+
+ // Load document from url
+// LoadDocumentFromUrl.run();
+
+ // Load document from FTP
+// LoadDocumentFromFtp.run();
+
+ // Load document from AmazonS3
+// LoadDocumentFromAmazonS3.run();
+
+ // Load document from Azure
+// LoadDocumentFromAzure.run();
+
+// MinimalAnnotation.run();
+
+// AddUserRole.run();
+
+ System.out.println();
+ System.out.println("All done.");
+ }
+}
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
new file mode 100644
index 0000000..0c0ec10
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/GenerateDocumentPagesPreview.java
@@ -0,0 +1,43 @@
+package com.groupdocs.annotation.examples.advanced_usage;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.exception.GroupDocsException;
+import com.groupdocs.annotation.options.pagepreview.CreatePageStream;
+import com.groupdocs.annotation.options.pagepreview.PreviewFormats;
+import com.groupdocs.annotation.options.pagepreview.PreviewOptions;
+
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+
+/**
+ *
+ * This example demonstrates annotating generating previews from document
+ *
+ */
+public class GenerateDocumentPagesPreview {
+
+ 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(85);
+ previewOptions.setPreviewFormat(PreviewFormats.PNG);
+ previewOptions.setPageNumbers(new int[]{1, 2});
+ annotator.getDocument().generatePreview(previewOptions);
+
+ System.out.println("\nDocument previews generated successfully.\nCheck output in " + Constants.OutputPath);
+ }
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/LoadPasswordProtectedDocuments.java b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/LoadPasswordProtectedDocuments.java
new file mode 100644
index 0000000..15ef198
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/LoadPasswordProtectedDocuments.java
@@ -0,0 +1,35 @@
+package com.groupdocs.annotation.examples.advanced_usage.loading;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import com.groupdocs.annotation.options.LoadOptions;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates annotating documents that are protected with a
+ * password.
+ *
+ */
+public class LoadPasswordProtectedDocuments {
+
+ public static void run() {
+ String outputPath = Constants.getOutputFilePath("LoadPasswordProtectedDocuments", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ LoadOptions loadOptions = new LoadOptions();
+ loadOptions.setPassword("1234");
+ final Annotator annotator = new Annotator(Constants.INPUT_PROTECTED, loadOptions);
+
+ AreaAnnotation area = new AreaAnnotation();
+ area.setBox(new Rectangle(100, 100, 100, 100));
+ area.setBackgroundColor(65535);
+ annotator.add(area);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromAmazonS3.java b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromAmazonS3.java
new file mode 100644
index 0000000..f6e943e
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromAmazonS3.java
@@ -0,0 +1,52 @@
+package com.groupdocs.annotation.examples.advanced_usage.loading.loading_documents_from_different_sources;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+
+/**
+ *
+ * This example demonstrates loading document from Amazon S3 storage.
+ *
+ */
+public class LoadDocumentFromAmazonS3 {
+
+// public static void run() {
+// String outputPath = Path.Combine(Constants.getOutputDirectoryPath(), "result" + Path.GetExtension(Constants.INPUT));
+//
+// String key = "sample.pdf";
+// final Annotator annotator = new Annotator(downloadFile(key));
+// try {
+// AreaAnnotation area = new AreaAnnotation();
+// area.setBox(new Rectangle(100, 100, 100, 100);
+// area.setBackgroundColor(65535;
+// annotator.add(area);
+// annotator.save(outputPath);
+// } finally {
+// if (annotator != null) {
+// annotator.dispose();
+// }
+// }
+// System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+// }
+
+// private static Stream downloadFile(String key) {
+// AmazonS3Client client = new AmazonS3Client();
+// String bucketName = "my-bucket";
+// GetObjectRequest request = new GetObjectRequest();
+// request.Key = key;
+// request.BucketName = bucketName;
+// final GetObjectResponse response = client.GetObject(request);
+// try {
+// MemoryStream stream = new MemoryStream();
+// response.ResponseStream.CopyTo(stream);
+// stream.setPosition(0);
+// return stream;
+// } finally {
+// if (response != null) {
+// ((IDisposable) response).dispose();
+// }
+// }
+// }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromAzure.java b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromAzure.java
new file mode 100644
index 0000000..df4433c
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromAzure.java
@@ -0,0 +1,51 @@
+package com.groupdocs.annotation.examples.advanced_usage.loading.loading_documents_from_different_sources;
+
+/**
+ *
+ * This example demonstrates loading document from Azure.
+ *
+ */
+public class LoadDocumentFromAzure {
+
+// public static void run() {
+// String outputPath = Path.Combine(Constants.getOutputDirectoryPath(), "result" + Path.GetExtension(Constants.INPUT));
+//
+// String blobName = "sample.pdf";
+// final Annotator annotator = new Annotator(downloadFile(blobName));
+// try {
+// AreaAnnotation area = new AreaAnnotation();
+// area.setBox(new Rectangle(100, 100, 100, 100);
+// area.setBackgroundColor(65535;
+// annotator.add(area);
+// annotator.save(outputPath);
+// } finally {
+// if (annotator != null) {
+// annotator.dispose();
+// }
+// }
+// System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+// }
+
+// public static Stream downloadFile(String blobName) {
+// CloudBlobContainer container = getContainer();
+// CloudBlob blob = container.GetBlobReference(blobName);
+// MemoryStream memoryStream = new MemoryStream();
+// blob.DownloadToStream(memoryStream);
+// memoryStream.setPosition(0);
+// return memoryStream;
+// }
+
+// private static CloudBlobContainer getContainer() {
+// String accountName = "***";
+// String accountKey = "***";
+// String endpoint = "https://{accountName}.blob.core.windows.net/";
+// String containerName = "***";
+// StorageCredentials storageCredentials = new StorageCredentials(accountName, accountKey);
+// CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(
+// storageCredentials, new Uri(endpoint), null, null, null);
+// CloudBlobClient cloudBlobClient = cloudStorageAccount.CreateCloudBlobClient();
+// CloudBlobContainer container = cloudBlobClient.GetContainerReference(containerName);
+// container.CreateIfNotExists();
+// return container;
+// }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromFtp.java b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromFtp.java
new file mode 100644
index 0000000..fe5a388
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromFtp.java
@@ -0,0 +1,51 @@
+package com.groupdocs.annotation.examples.advanced_usage.loading.loading_documents_from_different_sources;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import org.apache.commons.io.FilenameUtils;
+
+import org.apache.commons.net.ftp.FTPClient;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ *
+ * This example demonstrates loading document from FTP.
+ *
+ */
+public class LoadDocumentFromFtp {
+
+ public static void run() {
+ try {
+ String outputPath = Constants.getOutputFilePath("LoadDocumentFromFtp", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ String filePath = "sample.pdf";
+ String server = "localhost";
+
+ final Annotator annotator = new Annotator(getFileFromFtp(server, filePath));
+
+ AreaAnnotation area = new AreaAnnotation();
+ area.setBox(new Rectangle(100, 100, 100, 100));
+ area.setBackgroundColor(65535);
+ annotator.add(area);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ } catch (Throwable e) {
+ e.getMessage();
+ }
+ }
+
+ private static InputStream getFileFromFtp(String server, String filePath) throws IOException {
+ FTPClient client = new FTPClient();
+ client.connect(server);
+ InputStream inputStream = client.retrieveFileStream(filePath);
+ client.disconnect();
+
+ return inputStream;
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromLocalDisk.java b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromLocalDisk.java
new file mode 100644
index 0000000..ac38a18
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromLocalDisk.java
@@ -0,0 +1,31 @@
+package com.groupdocs.annotation.examples.advanced_usage.loading.loading_documents_from_different_sources;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates loading document from file path.
+ *
+ */
+public class LoadDocumentFromLocalDisk {
+
+ public static void run() {
+ String outputPath = Constants.getOutputFilePath("LoadDocumentFromLocalDisk", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ final Annotator annotator = new Annotator(Constants.INPUT_PDF);
+
+ AreaAnnotation area = new AreaAnnotation();
+ area.setBox(new Rectangle(100, 100, 100, 100));
+ area.setBackgroundColor(65535);
+ annotator.add(area);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
\ No newline at end of file
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromStream.java b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromStream.java
new file mode 100644
index 0000000..917f2fe
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromStream.java
@@ -0,0 +1,38 @@
+package com.groupdocs.annotation.examples.advanced_usage.loading.loading_documents_from_different_sources;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates loading document from stream.
+ *
+ */
+public class LoadDocumentFromStream {
+
+ public static void run() {
+ try {
+ String outputPath = Constants.getOutputFilePath("LoadDocumentFromStream", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ InputStream stream = new FileInputStream(Constants.INPUT_PDF);
+ final Annotator annotator = new Annotator(stream);
+
+ AreaAnnotation area = new AreaAnnotation();
+ area.setBox(new Rectangle(100, 100, 100, 100));
+ area.setBackgroundColor(65535);
+ annotator.add(area);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ } catch (Throwable e) {
+ e.getMessage();
+ }
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromUrl.java b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromUrl.java
new file mode 100644
index 0000000..4f76e68
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/loading/loading_documents_from_different_sources/LoadDocumentFromUrl.java
@@ -0,0 +1,37 @@
+package com.groupdocs.annotation.examples.advanced_usage.loading.loading_documents_from_different_sources;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import org.apache.commons.io.FilenameUtils;
+import java.net.URL;
+
+/**
+ *
+ * This example demonstrates loading document from URL.
+ *
+ */
+public class LoadDocumentFromUrl {
+
+ public static void run() {
+ try {
+ 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());
+
+ AreaAnnotation area = new AreaAnnotation();
+ area.setBox(new Rectangle(100, 100, 100, 100));
+ area.setBackgroundColor(65535);
+ annotator.add(area);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ } catch (Throwable e) {
+ e.getMessage();
+ }
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/saving/FilteringAnnotationTypes.java b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/saving/FilteringAnnotationTypes.java
new file mode 100644
index 0000000..c21fd85
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/saving/FilteringAnnotationTypes.java
@@ -0,0 +1,46 @@
+package com.groupdocs.annotation.examples.advanced_usage.saving;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import com.groupdocs.annotation.models.annotationmodels.EllipseAnnotation;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.annotation.options.export.SaveOptions;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates saving result document with specified annotations
+ *
+ */
+public class FilteringAnnotationTypes {
+ public static void run(String fileName) {
+ String outputPath = Constants.getOutputFilePath("FilteringAnnotationTypes", FilenameUtils.getExtension(fileName));
+
+ 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 annotations = new ArrayList<>();
+ annotations.add(area);
+ annotations.add(ellipse);
+ annotator.add(annotations);
+ SaveOptions saveOptions = new SaveOptions();
+ saveOptions.setAnnotationTypes(AnnotationType.ELLIPSE);
+ annotator.save(outputPath, saveOptions);
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/saving/SavingOnlyPagesWithAnnotations.java b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/saving/SavingOnlyPagesWithAnnotations.java
new file mode 100644
index 0000000..e5bcd21
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/saving/SavingOnlyPagesWithAnnotations.java
@@ -0,0 +1,43 @@
+package com.groupdocs.annotation.examples.advanced_usage.saving;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import com.groupdocs.annotation.models.annotationmodels.EllipseAnnotation;
+import com.groupdocs.annotation.options.export.SaveOptions;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates saving result document with specified pages
+ *
+ */
+public class SavingOnlyPagesWithAnnotations {
+ public static void run(String fileName) {
+ String outputPath = Constants.getOutputFilePath("SavingOnlyPagesWithAnnotations", FilenameUtils.getExtension(fileName));
+
+ 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 annotations = new ArrayList();
+ annotations.add(area);
+ annotations.add(ellipse);
+ annotator.add(annotations);
+ SaveOptions saveOptions = new SaveOptions();
+ saveOptions.setOnlyAnnotatedPages(true);
+ annotator.save(outputPath, saveOptions);
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/saving/SavingSpecificPageRange.java b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/saving/SavingSpecificPageRange.java
new file mode 100644
index 0000000..d549b35
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/advanced_usage/saving/SavingSpecificPageRange.java
@@ -0,0 +1,27 @@
+package com.groupdocs.annotation.examples.advanced_usage.saving;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.options.export.SaveOptions;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates saving result document with specified pages
+ *
+ */
+public class SavingSpecificPageRange {
+
+ public static void run(String inputFile) {
+ String outputPath = Constants.getOutputFilePath("SavingSpecificPageRange", FilenameUtils.getExtension(inputFile));
+
+ try(final Annotator annotator = new Annotator(inputFile)) {
+ SaveOptions saveOptions = new SaveOptions();
+ saveOptions.setFirstPage(2);
+ saveOptions.setLastPage(4);
+ annotator.save(outputPath, saveOptions);
+
+ System.out.println("\nDocument saved successfully.\nCheck output in {outputPath}.");
+ }
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/AddReplies.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/AddReplies.java
new file mode 100644
index 0000000..c8a1159
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/AddReplies.java
@@ -0,0 +1,95 @@
+package com.groupdocs.annotation.examples.basic_usage;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.PenStyle;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.User;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import java.util.ArrayList;
+import java.util.Calendar;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates adding replies to annotation.
+ *
+ */
+public class AddReplies {
+
+ public static void run() {
+ String outputPath = Constants.getOutputFilePath("AddReplies", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ final Annotator annotator = new Annotator(Constants.INPUT_PDF);
+
+ User user1 = new User();
+ user1.setId(1);
+ user1.setName("Tom");
+ user1.setEmail("somemail@mail.com");
+ User user2 = new User();
+ user2.setId(2);
+ user2.setName("Jack");
+ user2.setEmail("somebody@mail.com");
+ User user3 = new User();
+ user3.setId(3);
+ user3.setName("Mike");
+ user3.setEmail("somemike@mail.com");
+
+ AreaAnnotation area = new AreaAnnotation();
+ area.setBackgroundColor(65535);
+ area.setBox(new Rectangle(100, 100, 100, 100));
+ area.setCreatedOn(Calendar.getInstance().getTime());
+ area.setMessage("This is area annotation");
+ area.setOpacity(0.7);
+ area.setPageNumber(0);
+ area.setPenColor(65535);
+ area.setPenStyle(PenStyle.DOT);
+ area.setPenWidth((byte) 3);
+
+ Reply reply1 = new Reply();
+ reply1.setId(1);
+ reply1.setComment("First comment");
+ reply1.setRepliedOn(Calendar.getInstance().getTime());
+ reply1.setUser(user1);
+
+ Reply reply2 = new Reply();
+ reply2.setId(2);
+ reply2.setComment("Second comment");
+ reply2.setRepliedOn(Calendar.getInstance().getTime());
+ reply2.setUser(user2);
+
+ Reply reply3 = new Reply();
+ reply3.setId(3);
+ reply3.setComment("Third comment");
+ reply3.setRepliedOn(Calendar.getInstance().getTime());
+ reply3.setUser(user1);
+
+ Reply reply4 = new Reply();
+ reply4.setId(4);
+ reply4.setComment("Fourth comment");
+ reply4.setRepliedOn(Calendar.getInstance().getTime());
+ reply4.setUser(user2);
+
+ Reply reply5 = new Reply();
+ reply5.setId(5);
+ reply5.setComment("Five comment");
+ reply5.setRepliedOn(Calendar.getInstance().getTime());
+ reply5.setUser(user3);
+
+ java.util.List replies = new ArrayList();
+ replies.add(reply1);
+ replies.add(reply2);
+ replies.add(reply3);
+ replies.add(reply4);
+ replies.add(reply5);
+
+ area.setReplies(replies);
+ annotator.add(area);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/AddUserRole.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/AddUserRole.java
new file mode 100644
index 0000000..5a916ef
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/AddUserRole.java
@@ -0,0 +1,58 @@
+package com.groupdocs.annotation.examples.basic_usage;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+
+import com.groupdocs.annotation.models.*;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import org.apache.commons.io.FilenameUtils;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+
+/**
+ *
+ * This example demonstrates adding user role to reply.
+ *
+ */
+public class AddUserRole {
+ public static void run() {
+ String outputPath = Constants.getOutputFilePath("AddUserRole", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ final Annotator annotator = new Annotator(Constants.INPUT_PDF);
+
+ Reply reply1 = new Reply();
+ reply1.setComment("This comment will be applied");
+ reply1.setRepliedOn(Calendar.getInstance().getTime());
+ User user1 = new User(1, "Reviewer", Role.EDITOR);
+ reply1.setUser(user1);
+
+ Reply reply2 = new Reply();
+ reply2.setComment("This comment will NOT be applied");
+ reply2.setRepliedOn(Calendar.getInstance().getTime());
+ User user2 = new User(1, "Member", Role.VIEWER);
+ reply2.setUser(user2);
+
+ java.util.List replies = new ArrayList<>();
+ replies.add(reply1);
+ replies.add(reply2);
+
+ AreaAnnotation area = new AreaAnnotation();
+ area.setBackgroundColor(65535);
+ area.setBox(new Rectangle(100, 100, 100, 100));
+ area.setCreatedOn(Calendar.getInstance().getTime());
+ area.setMessage("This is area annotation");
+ area.setOpacity(0.7);
+ area.setPageNumber(0);
+ area.setPenColor(65535);
+ area.setPenStyle(PenStyle.DOT);
+ area.setPenWidth((byte) 3);
+ area.setReplies(replies);
+ annotator.add(area);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/DevTest.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/DevTest.java
new file mode 100644
index 0000000..299e9f5
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/DevTest.java
@@ -0,0 +1,63 @@
+package com.groupdocs.annotation.examples.basic_usage;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.models.Point;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.annotationmodels.StrikeoutAnnotation;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+public class DevTest {
+ public static void run() {
+ // This example demonstrates adding text strikeout annotation.
+
+ // Create an instance of Annotator class
+ Annotator annotator = new Annotator(System.getProperty("user.dir") + "\\Resources\\SampleFiles\\dev_sample.pdf");
+ try {
+ // Create an instance of Reply class and add comments
+ 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);
+
+ Point point1 = new Point(80, 730);
+ Point point2 = new Point(240, 730);
+ Point point3 = new Point(80, 650);
+ Point point4 = new Point(240, 650);
+
+ List points = new ArrayList<>();
+ points.add(point1);
+ points.add(point2);
+ points.add(point3);
+ points.add(point4);
+
+ // Create an instance of StrikeoutAnnotation class and set options
+ StrikeoutAnnotation strikeout;
+ strikeout = new StrikeoutAnnotation();
+ strikeout.setCreatedOn(Calendar.getInstance().getTime());
+ strikeout.setFontColor(65535);
+ strikeout.setMessage("This is strikeout annotation");
+ strikeout.setOpacity(0.7);
+ strikeout.setPageNumber(0);
+ strikeout.setPoints(points);
+ strikeout.setReplies(replies);
+
+ // Add annotation and save to file
+ annotator.add(strikeout);
+ annotator.save(System.getProperty("user.dir") + "\\Resources\\Output\\dev.pdf");
+ } finally {
+ if (annotator != null) {
+ annotator.dispose();
+ }
+ }
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/ExtractAnnotationsFromDocument.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/ExtractAnnotationsFromDocument.java
new file mode 100644
index 0000000..134b549
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/ExtractAnnotationsFromDocument.java
@@ -0,0 +1,33 @@
+package com.groupdocs.annotation.examples.basic_usage;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ *
+ * This example demonstrates how to extract annotations
+ *
+ */
+public class ExtractAnnotationsFromDocument {
+ public static void run(String inputFile) {
+ try (final InputStream inputStream = new FileInputStream(inputFile);
+ final Annotator annotator = new Annotator(inputStream)){
+ List annotations = annotator.get();
+
+ Iterator items = (annotations).iterator();
+ while (items.hasNext()) {
+ AnnotationBase annotation = items.next();
+ System.out.println(annotation.getMessage());
+ }
+ System.out.println("Annotations extracted successfully.");
+ }catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/GetFileInfo.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/GetFileInfo.java
new file mode 100644
index 0000000..13c86a3
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/GetFileInfo.java
@@ -0,0 +1,28 @@
+package com.groupdocs.annotation.examples.basic_usage;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.IDocumentInfo;
+
+import java.io.IOException;
+
+/**
+ *
+ * This example demonstrates document info extraction
+ *
+ */
+public class GetFileInfo {
+ public static void run(String inputFile) {
+ try(final Annotator annotator = new Annotator(inputFile)) {
+ IDocumentInfo info = null;
+ try {
+ info = annotator.getDocument().getDocumentInfo();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ System.out.println(
+ "\nFile type: " + info.getFileType() + "\nNumber of pages: " + info.getPageCount() + "\nDocument size: " + info.getSize() + " bytes");
+
+ System.out.println("\nDocument info extracted successfully.");
+ }
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/GetSupportedFileFormats.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/GetSupportedFileFormats.java
new file mode 100644
index 0000000..275716c
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/GetSupportedFileFormats.java
@@ -0,0 +1,26 @@
+package com.groupdocs.annotation.examples.basic_usage;
+
+import com.groupdocs.annotation.options.FileType;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ *
+ * This example demonstrates file types support
+ *
+ */
+public class GetSupportedFileFormats {
+
+ public static void run() {
+
+ List fileTypes = FileType.getSupportedFileTypes();
+ //foreach to while statements conversion
+ Iterator items = (fileTypes).iterator();
+ while (items.hasNext()) {
+ FileType fileType = (FileType) items.next();
+ System.out.println(fileType.getExtension());
+ }
+
+ System.out.println("\nSupported file types retrieved successfully.");
+ }
+}
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
new file mode 100644
index 0000000..0b79f76
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/MinimalAnnotation.java
@@ -0,0 +1,19 @@
+package com.groupdocs.annotation.examples.basic_usage;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.annotationmodels.ArrowAnnotation;
+import org.apache.commons.io.FilenameUtils;
+
+public class MinimalAnnotation {
+ public static void run() {
+ 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/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/RemoveAnnotationFromDocument.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/RemoveAnnotationFromDocument.java
new file mode 100644
index 0000000..89dc99f
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/RemoveAnnotationFromDocument.java
@@ -0,0 +1,29 @@
+package com.groupdocs.annotation.examples.basic_usage;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.options.export.AnnotationType;
+import com.groupdocs.annotation.options.export.SaveOptions;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates how to remove annotations from document
+ *
+ */
+public class RemoveAnnotationFromDocument {
+
+ public static void run() {
+ String outputPath = Constants.getOutputFilePath("RemoveAnnotationFromDocument", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ final Annotator annotator = new Annotator(Constants.ANNOTATED_AREA_REPLIES_5);
+
+ SaveOptions saveOptions = new SaveOptions();
+ saveOptions.setAnnotationTypes(AnnotationType.NONE);
+ annotator.save(outputPath, saveOptions);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/RemoveReplies.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/RemoveReplies.java
new file mode 100644
index 0000000..cf9cce0
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/RemoveReplies.java
@@ -0,0 +1,37 @@
+package com.groupdocs.annotation.examples.basic_usage;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.options.LoadOptions;
+import java.util.List;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates how to remove replies from annotated document
+ *
+ */
+public class RemoveReplies {
+
+ public static void run() {
+ String outputPath = Constants.getOutputFilePath("RemoveRepliesById", FilenameUtils.getExtension(Constants.INPUT_PDF));
+ LoadOptions loadOptions = new LoadOptions();
+
+ // NOTE: Input document already contain annotations with replies
+ final Annotator annotator = new Annotator(Constants.ANNOTATED_WITH_REPLIES_NEW, loadOptions);
+
+ // Obtain annotations collection from document
+ List annotations = annotator.get();
+ // Remove first reply by index
+ if(!annotations.isEmpty())annotations.get(0).getReplies().remove(0);
+
+ // Save changes
+ annotator.update(annotations);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/RemoveRepliesById.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/RemoveRepliesById.java
new file mode 100644
index 0000000..e379832
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/RemoveRepliesById.java
@@ -0,0 +1,39 @@
+package com.groupdocs.annotation.examples.basic_usage;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.options.LoadOptions;
+import java.util.List;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates how to remove replies from annotated document by
+ * reply Id
+ *
+ */
+public class RemoveRepliesById {
+
+ public static void run() {
+ String outputPath = Constants.getOutputFilePath("RemoveRepliesById", FilenameUtils.getExtension(Constants.INPUT_PDF));
+ LoadOptions loadOptions = new LoadOptions();
+
+ // NOTE: Input document already contain annotations with replies
+ final Annotator annotator = new Annotator(Constants.ANNOTATED_AREA_REPLIES_5, loadOptions);
+
+ // Obtain annotations collection from document
+ List annotations = annotator.get();
+
+ // Remove reply with Id = 4
+ if(!annotations.isEmpty())annotations.get(0).getReplies().remove(4);
+
+ // Save changes
+ annotator.update(annotations);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/RemoveRepliesByUserName.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/RemoveRepliesByUserName.java
new file mode 100644
index 0000000..1b3f504
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/RemoveRepliesByUserName.java
@@ -0,0 +1,43 @@
+package com.groupdocs.annotation.examples.basic_usage;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.annotationmodels.AnnotationBase;
+import com.groupdocs.annotation.options.LoadOptions;
+import java.util.List;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates how to remove replies from annotated document by
+ * user name
+ *
+ */
+public class RemoveRepliesByUserName {
+
+ public static void run() {
+ String outputPath = Constants.getOutputFilePath("RemoveRepliesByUserName", FilenameUtils.getExtension(Constants.INPUT_PDF));
+ LoadOptions loadOptions = new LoadOptions();
+
+ // NOTE: Input document already contain annotations with replies
+ final Annotator annotator = new Annotator(Constants.ANNOTATED_AREA_REPLIES_5, loadOptions);
+
+ // Obtain annotations collection from document
+ List annotations = annotator.get();
+
+ // Remove all replies where author name is "Tom"
+ for (int i = 0; i < annotations.get(0).getReplies().size(); i++) {
+ if (annotations.get(0).getReplies().get(i).getUser().getName().toString().equals("Tom")) {
+ annotations.get(0).getReplies().remove(i);
+ }
+ }
+
+ // Save changes
+ annotator.update(annotations);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/UpdateAnnotation.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/UpdateAnnotation.java
new file mode 100644
index 0000000..fbd02f2
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/UpdateAnnotation.java
@@ -0,0 +1,84 @@
+package com.groupdocs.annotation.examples.basic_usage;
+
+import com.groupdocs.annotation.Annotator;
+import com.groupdocs.annotation.examples.Constants;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import com.groupdocs.annotation.options.LoadOptions;
+import java.util.ArrayList;
+import java.util.Calendar;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates how to update annotation
+ *
+ */
+public class UpdateAnnotation {
+
+ public static void run() {
+
+ String outputPath = Constants.getOutputFilePath("UpdateAnnotation", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ final Annotator annotator = new Annotator(Constants.INPUT_PDF);
+
+ Reply reply1 = new Reply();
+ reply1.setComment("Original first comment");
+ reply1.setRepliedOn(Calendar.getInstance().getTime());
+
+ Reply reply2 = new Reply();
+ reply2.setComment("Original second comment");
+ reply2.setRepliedOn(Calendar.getInstance().getTime());
+
+ java.util.List replies = new ArrayList();
+ replies.add(reply1);
+ replies.add(reply2);
+
+ AreaAnnotation original = new AreaAnnotation();
+ original.setId(1);
+ original.setBackgroundColor(65535);
+ original.setBox(new Rectangle(100, 100, 100, 100));
+ original.setCreatedOn(Calendar.getInstance().getTime());
+ original.setMessage("This is original annotation");
+ original.setReplies(replies);
+ // add original annotation
+ annotator.add(original);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ LoadOptions loadOptions = new LoadOptions();
+
+ // open annotated document
+ final Annotator annotator1 = new Annotator(outputPath, loadOptions);
+
+ Reply reply3 = new Reply();
+ reply3.setComment("Updated first comment");
+ reply3.setRepliedOn(Calendar.getInstance().getTime());
+
+ Reply reply4 = new Reply();
+ reply4.setComment("Updated second comment");
+ reply4.setRepliedOn(Calendar.getInstance().getTime());
+
+ java.util.List replies1 = new ArrayList();
+ replies1.add(reply3);
+ replies1.add(reply4);
+
+ // suggest we want change some properties of existed annotation
+ AreaAnnotation updated = new AreaAnnotation();
+ updated.setId(1);
+ updated.setBackgroundColor(255);
+ updated.setBox(new Rectangle(0, 0, 50, 200));
+ updated.setCreatedOn(Calendar.getInstance().getTime());
+ updated.setMessage("This is updated annotation");
+ updated.setReplies(replies1);
+ // update annotation
+ annotator1.update(updated);
+ annotator1.save(outputPath);
+
+ annotator1.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
\ No newline at end of file
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddAreaAnnotation.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddAreaAnnotation.java
new file mode 100644
index 0000000..71ebf2a
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddAreaAnnotation.java
@@ -0,0 +1,52 @@
+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.PenStyle;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.annotationmodels.AreaAnnotation;
+import java.util.ArrayList;
+import java.util.Calendar;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates adding area annotation.
+ *
+ */
+public class AddAreaAnnotation {
+ public static void run() {
+ 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);
+
+ String outputPath = Constants.getOutputFilePath("AddAreaAnnotation", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ try(final Annotator annotator = new Annotator(Constants.INPUT_PDF)) {
+ AreaAnnotation area = new AreaAnnotation();
+ area.setBackgroundColor(65535);
+ area.setBox(new Rectangle(100, 100, 100, 100));
+ area.setCreatedOn(Calendar.getInstance().getTime());
+ area.setMessage("This is area annotation");
+ area.setOpacity(0.7);
+ area.setPageNumber(0);
+ area.setPenColor(65535);
+ area.setPenStyle(PenStyle.DOT);
+ area.setPenWidth((byte) 3);
+ area.setReplies(replies);
+ annotator.add(area);
+ annotator.save(outputPath);
+ }
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddArrowAnnotation.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddArrowAnnotation.java
new file mode 100644
index 0000000..764727a
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddArrowAnnotation.java
@@ -0,0 +1,54 @@
+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.PenStyle;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.annotationmodels.ArrowAnnotation;
+import java.util.ArrayList;
+import java.util.Calendar;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates adding arrow annotation.
+ *
+ */
+public class AddArrowAnnotation {
+
+ public static void run() {
+ String outputPath = Constants.getOutputFilePath("AddArrowAnnotation", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ final Annotator annotator = new Annotator(Constants.INPUT_PDF);
+
+ 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);
+
+ ArrowAnnotation arrow = new ArrowAnnotation();
+ arrow.setBox(new Rectangle(100, 100, 100, 100));
+ arrow.setCreatedOn(Calendar.getInstance().getTime());
+ arrow.setMessage("This is arrow annotation");
+ arrow.setOpacity(0.7);
+ arrow.setPageNumber(0);
+ arrow.setPenColor(65535);
+ arrow.setPenStyle(PenStyle.DOT);
+ arrow.setPenWidth((byte) 3);
+ arrow.setReplies(replies);
+ annotator.add(arrow);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddDistanceAnnotation.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddDistanceAnnotation.java
new file mode 100644
index 0000000..49a9ed2
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddDistanceAnnotation.java
@@ -0,0 +1,54 @@
+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.PenStyle;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.annotationmodels.DistanceAnnotation;
+import java.util.ArrayList;
+import java.util.Calendar;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates adding distance annotation.
+ *
+ */
+public class AddDistanceAnnotation {
+
+ public static void run() {
+ String outputPath = Constants.getOutputFilePath("AddDistanceAnnotation", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ final Annotator annotator = new Annotator(Constants.INPUT_PDF);
+
+ 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);
+
+ DistanceAnnotation distance = new DistanceAnnotation();
+ distance.setBox(new Rectangle(200, 150, 200, 30));
+ distance.setCreatedOn(Calendar.getInstance().getTime());
+ distance.setMessage("This is distance annotation");
+ distance.setOpacity(0.7);
+ distance.setPageNumber(0);
+ distance.setPenColor(65535);
+ distance.setPenStyle(PenStyle.DOT);
+ distance.setPenWidth((byte) 3);
+ distance.setReplies(replies);
+ annotator.add(distance);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddEllipseAnnotation.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddEllipseAnnotation.java
new file mode 100644
index 0000000..6ae2682
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddEllipseAnnotation.java
@@ -0,0 +1,55 @@
+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.PenStyle;
+import com.groupdocs.annotation.models.Rectangle;
+import com.groupdocs.annotation.models.Reply;
+import com.groupdocs.annotation.models.annotationmodels.EllipseAnnotation;
+import java.util.ArrayList;
+import java.util.Calendar;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates adding ellipse annotation.
+ *
+ */
+public class AddEllipseAnnotation {
+
+ public static void run() {
+ String outputPath = Constants.getOutputFilePath("AddLinkAnnotation", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ final Annotator annotator = new Annotator(Constants.INPUT_PDF);
+
+ 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);
+
+ EllipseAnnotation ellipse = new EllipseAnnotation();
+ ellipse.setBackgroundColor(65535);
+ ellipse.setBox(new Rectangle(100, 100, 100, 100));
+ ellipse.setCreatedOn(Calendar.getInstance().getTime());
+ ellipse.setMessage("This is ellipse annotation");
+ ellipse.setOpacity(0.7);
+ ellipse.setPageNumber(0);
+ ellipse.setPenColor(65535);
+ ellipse.setPenStyle(PenStyle.DOT);
+ ellipse.setPenWidth((byte) 3);
+ ellipse.setReplies(replies);
+ annotator.add(ellipse);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddImageAnnotation.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddImageAnnotation.java
new file mode 100644
index 0000000..fc90f0e
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddImageAnnotation.java
@@ -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");
+ }
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddLinkAnnotation.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddLinkAnnotation.java
new file mode 100644
index 0000000..2d63be4
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddLinkAnnotation.java
@@ -0,0 +1,63 @@
+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.LinkAnnotation;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *
+ * This example demonstrates adding link annotation.
+ *
+ */
+public class AddLinkAnnotation {
+
+ public static void run() {
+ String outputPath = Constants.getOutputFilePath("AddLinkAnnotation", FilenameUtils.getExtension(Constants.INPUT_PDF));
+
+ final Annotator annotator = new Annotator(Constants.INPUT_PDF);
+
+ 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);
+
+ Point point1 = new Point(80, 730);
+ Point point2 = new Point(240, 730);
+ Point point3 = new Point(80, 650);
+ Point point4 = new Point(240, 650);
+
+ List points = new ArrayList();
+ points.add(point1);
+ points.add(point2);
+ points.add(point3);
+ points.add(point4);
+
+ LinkAnnotation link = new LinkAnnotation();
+ link.setCreatedOn(Calendar.getInstance().getTime());
+ link.setMessage("This is link annotation");
+ link.setOpacity(0.7);
+ link.setPageNumber(0);
+ link.setPoints(points);
+ link.setReplies(replies);
+ link.setUrl("https://www.google.com");
+ annotator.add(link);
+ annotator.save(outputPath);
+
+ annotator.dispose();
+
+ System.out.println("\nDocument saved successfully.\nCheck output in " + outputPath);
+ }
+}
diff --git a/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddPointAnnotation.java b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddPointAnnotation.java
new file mode 100644
index 0000000..11f4778
--- /dev/null
+++ b/Examples/src/main/java/com/groupdocs/annotation/examples/basic_usage/add_annotation_to_the_document/AddPointAnnotation.java
@@ -0,0 +1,49 @@
+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.Reply;
+import com.groupdocs.annotation.models.annotationmodels.PointAnnotation;
+import java.util.ArrayList;
+import java.util.Calendar;
+import org.apache.commons.io.FilenameUtils;
+
+/**
+ *