Text Highlight Annotation

Text Highlight annotation highlights and comments selected text

API Usage

There are steps that usage of GroupDocs.Annotation Cloud consists of:

  1. Upload input document into cloud storage and other files, like image annotation
  2. Add annotation
  3. Export document with annotations
HTTP POST ~/annotation

Swagger UI lets you call this REST API directly from the browser.

cURL REST Example

// First get JSON Web Token
// Please get your Client Id and Client Secret from https://dashboard.groupdocs.cloud/applications. Kindly place Client Id in the "client_id" and Client Secret in the "client_secret" arguments.
curl -v "https://api.groupdocs.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=xxxx&client_secret=xxxx" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

// cURL example to get document information
curl -v "https://api.groupdocs.cloud/v2.0/annotation/?filePath=annotationdocs%2Fone-page.docx" \
-X POST \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer <jwt token>" \
-d "
[
  {
    'Type': 'TextHighlight',
    'Text': 'This is text highlight annotation',
    'CreatorName': 'Anonym A.',
    'Points': [ {
      'X': 80,
      'Y': 730
     },
     {
      'X': 240,
      'Y': 730
     },
     {
      'X': 80,
      'Y': 760
     },
     {
      'X': 240,
      'Y': 650
     }
    ],
    'PageNumber': 0,
    'Replies': [
      {
        'Comment': 'First comment',
        'RepliedOn': '2020-10-02T06:52:01.376Z'
      },
      {
        'Comment': 'Second comment',
        'RepliedOn': '2020-10-02T06:52:01.376Z'
      }
    ],
    'CreatedOn': '2020-10-02T06:52:01.376Z'
  }
]
"
code 200 OK

SDKs

The API is completely independent of your operating system, database system or development language. We provide and support API SDKs in many development languages in order to make it even easier to integrate. You can see our available SDKs list here.

SDK Examples


// For complete examples and data files, please go to https://github.com/groupdocs-annotation-cloud/groupdocs-annotation-cloud-dotnet-samples
string MyClientSecret = ""; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
string MyClientId = ""; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud

var configuration = new Configuration(MyClientId, MyClientSecret);

var apiInstance = new AnnotateApi(configuration);

var request = new PostAnnotationsRequest();
request.filePath = "one-page.docx";
AnnotationInfo[] annotations =
{
    new AnnotationInfo
    {
        Points = new List<Point>
        {
            new Point {X = 80, Y = 730}, new Point {X=240, Y=730}, new Point {X=80, Y=650}, new Point {X=240, Y=650}
        },
        BackgroundColor = 65535,
        PageNumber = 0,
        Type = AnnotationInfo.TypeEnum.TextHighlight,
        Text = "This is text highlight annotation",
        CreatorName = "Anonym A.",
        CreatedOn = DateTime.Now,
        Replies = new List<AnnotationReplyInfo>
        {
            new AnnotationReplyInfo
            {
                Comment = "First comment",
                RepliedOn = DateTime.Now
            },
            new AnnotationReplyInfo
            {
                Comment = "Second comment",
                RepliedOn = DateTime.Now
            }
        }
    },
};
request.annotations = annotations.ToList();
apiInstance.PostAnnotations(request);
Console.WriteLine("AddTextHighlightAnnotation: Text highlight Annotation added.");


// For complete examples and data files, please go to https://github.com/groupdocs-annotation-cloud/groupdocs-annotation-cloud-java-samples
String MyClientSecret = ""; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
String MyClientId = ""; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud

Configuration configuration = new Configuration(MyClientId, MyClientSecret);

AnnotateApi apiInstance = new AnnotateApi(configuration);

// Create annotation/s.
AnnotationInfo[] annotations = new AnnotationInfo[1];
annotations[0] = new AnnotationInfo();

Point[] pt = new Point[4];
pt[0] = new Point();
pt[0].setX(80.0);
pt[0].setY(730.0);
pt[1] = new Point();
pt[1].setX(240.0);
pt[1].setY(730.0);
pt[2] = new Point();
pt[2].setX(80.0);
pt[2].setY(650.0);
pt[3] = new Point();
pt[3].setX(240.0);
pt[3].setY(650.0);
annotations[0].setPoints(Arrays.asList(pt));

annotations[0].setPageNumber(0);
annotations[0].setBackgroundColor(65535);
annotations[0].setType(TypeEnum.TEXTHIGHLIGHT);
annotations[0].setText("This is text highlight annotation");
annotations[0].setCreatorName("Anonym A.");

// Create request object.
PostAnnotationsRequest request = new PostAnnotationsRequest("Annotationdocs\\one-page.docx", Arrays.asList(annotations));

// Executing api method.
apiInstance.postAnnotations(request);

System.out.println("AddTextHighlightAnnotation: Text highlight Annotation added.");


// For complete examples and data files, please go to https://github.com/groupdocs-annotation-cloud/groupdocs-annotation-cloud-php-samples
use GroupDocs\Annotation\Model;
use GroupDocs\Annotation\Model\Requests;

$ClientId = ""; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
$ClientSecret = ""; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud

$configuration = new GroupDocs\Annotation\Configuration();
$configuration->setAppSid($ClientId);
$configuration->setAppKey($ClientSecret);

$apiInstance = new GroupDocs\Annotation\AnnotateApi($configuration);

$a = new GroupDocs\Annotation\Model\AnnotationInfo();
$pt1 = new GroupDocs\Annotation\Model\Point();
$pt1->setX(80);
$pt1->setY(730);
$pt2 = new GroupDocs\Annotation\Model\Point();
$pt2->setX(80);
$pt2->setY(730);
$pt3 = new GroupDocs\Annotation\Model\Point();
$pt3->setX(80);
$pt3->setY(730);
$pt4 = new GroupDocs\Annotation\Model\Point();
$pt4->setX(80);
$pt4->setY(730);
$a->setPoints([$pt1, $pt2, $pt3, $pt4]);

$a->setPageNumber(0);
$a->setBackgroundColor(65535);
$a->setType(GroupDocs\Annotation\Model\AnnotationInfo::TYPE_TEXT_HIGHLIGHT);
$a->setText("This is text highlight annotation");
$a->setCreatorName("Anonym A.");

$request = new GroupDocs\Annotation\Model\Requests\postAnnotationsRequest("annotationdocs\\one-page.docx", [$a]);
$apiInstance->postAnnotations($request);

echo "AddTextHighlightAnnotation: Text highlight Annotation added.";

// For complete examples and data files, please go to https://github.com/groupdocs-annotation-cloud/groupdocs-annotation-cloud-node-samples
global.annotation_cloud = require("groupdocs-annotation-cloud");

global.clientId = "XXXX-XXXX-XXXX-XXXX"; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
global.clientSecret = "XXXXXXXXXXXXXXXX"; // Get Client Id and Client Secret from https://dashboard.groupdocs.cloud

global.annotateApi = annotation_cloud.AnnotateApi.fromKeys(clientId, clientSecret);

let a1 = new annotation_cloud.AnnotationInfo();
let p1 = new annotation_cloud.Point();
p1.x = 80;
p1.y = 730;
let p2 = new annotation_cloud.Point();
p2.x = 240;
p2.y = 730;
let p3 = new annotation_cloud.Point();
p3.x = 80;
p3.y = 650;
let p4 = new annotation_cloud.Point();
p4.x = 240;
p4.y = 650;
a1.points = [p1, p2, p3, p4];
a1.pageNumber = 0;
a1.backgroundColor = 65535;
a1.type = annotation_cloud.AnnotationInfo.TypeEnum.TextHighlight;
a1.text = "This is text highlight annotation";
a1.creatorName = "Anonym A.";

var request = new annotation_cloud.PostAnnotationsRequest("Annotationdocs\\one-page.docx", [a1]);
await annotateApi.postAnnotations(request);
console.log("AddTextHighlightAnnotation: text highlight Annotation added.");


# For complete examples and data files, please go to https://github.com/groupdocs-annotation-cloud/groupdocs-annotation-cloud-python-samples
import groupdocs_annotation_cloud

client_id = "XXXX-XXXX-XXXX-XXXX" # Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
client_secret = "XXXXXXXXXXXXXXXX" # Get Client Id and Client Secret from https://dashboard.groupdocs.cloud

api = groupdocs_annotation_cloud.AnnotateApi.from_keys(client_id, client_secret)

a1 = groupdocs_annotation_cloud.AnnotationInfo()
p1 = groupdocs_annotation_cloud.Point()
p1.x = 80
p1.y = 730
p2 = groupdocs_annotation_cloud.Point()
p2.x = 240
p2.y = 730
p3 = groupdocs_annotation_cloud.Point()
p3.x = 80
p3.y = 650
p4 = groupdocs_annotation_cloud.Point()
p4.x = 240
p4.y = 650
a1.points = [p1, p2, p3, p4]
a1.page_number = 0
a1.background_color = 65535
a1.type = "TextHighlight"
a1.text = "This is text highlight annotation"
a1.creator_name = "Anonym A."

request = PostAnnotationsRequest("annotationdocs\\one-page.docx", [a1])
api.post_annotations(request)

print("AddTextHighlightAnnotation: Text highlight Annotation added.")

# For complete examples and data files, please go to https://github.com/groupdocs-annotation-cloud/groupdocs-annotation-cloud-ruby-samples
require 'groupdocs_annotation_cloud'

$client_id = "XXXX-XXXX-XXXX-XXXX" # Get Client Id and Client Secret from https://dashboard.groupdocs.cloud
$client_secret = "XXXXXXXXXXXXXXXX" # Get Client Id and Client Secret from https://dashboard.groupdocs.cloud

$api = GroupDocsAnnotationCloud::AnnotateApi.from_keys($client_id, $client_secret)

$a1 = GroupDocsAnnotationCloud::AnnotationInfo.new
$p1 = GroupDocsAnnotationCloud::Point.new
$p1.x = 1
$p1.y = 1
$p2 = GroupDocsAnnotationCloud::Point.new
$p2.x = 1
$p2.y = 1
$p3 = GroupDocsAnnotationCloud::Point.new
$p3.x = 1
$p3.y = 1
$p4 = GroupDocsAnnotationCloud::Point.new
$p4.x = 1
$p4.y = 1
$a1.points = [$p1, $p2, $p3, $p4]
$a1.page_number = 0
$a1.background_color = 65535
$a1.type = "TextHighlight"
$a1.text = "This is text highlight annotation"
$a1.creator_name = "Anonym A."

$request = GroupDocsAnnotationCloud::PostAnnotationsRequest.new("Annotationdocs\\one-page.docx", [$a1])

# Executing an API.
$api.post_annotations($request)

puts("AddTextHighlightAnnotation: Text highlight Annotation added.")