3.1 Annotation
Annotations refer to interactive objects with location information on a PDF page, such as lines, notes, highlight markups, links, and attachments. Most of the annotation types listed in Table3.1 are defined as markup annotations and some of them contain text that appears as part of the annotation. See Table 3.1 for more information about whether a certain annotation is supported by SDK.
Table 3.1
|
Annotation type |
Description |
Markup |
Supported by
SDK |
1 |
Text |
Text annotation |
Yes |
Yes |
2 |
Link |
Link annotation |
No |
Yes |
3 |
FreeText (TypeWritter) |
Free text annotation |
Yes |
Yes |
4 |
Line |
Line annotation |
Yes |
Yes |
5 |
Square |
Square annotation |
Yes |
Yes |
6 |
Circle |
Circle annotation |
Yes |
Yes |
7 |
Polygon |
Polygon annotation |
Yes |
Yes |
8 |
Polyline |
Polyline annotation |
Yes |
Yes |
9 |
Highlight |
Highlight annotation |
Yes |
Yes |
10 |
Underline |
Underline annotation |
Yes |
Yes |
11 |
Squiggly |
Squiggly-underline annotation |
Yes |
Yes |
12 |
Strikeout |
Strikeout annotation |
Yes |
Yes |
13 |
Stamp |
Rubber stamp annotation |
Yes |
Yes |
14 |
Caret |
Caret annotation |
Yes |
Yes |
15 |
Ink (pencil) |
Ink annotation |
Yes |
Yes |
16 |
Popup |
Pop-up annotation |
No |
Yes |
17 |
File Attachment |
File attachment |
Yes |
Yes |
18 |
Sound |
Sound annotation |
Yes |
No |
19 |
Movie |
Movie annotation |
No |
No |
20 |
Widget |
Widget annotation |
No |
Yes |
21 |
Screen |
Screen annotation |
No |
No |
22 |
PrinterMark |
Printer’s mark annotation |
No |
No |
23 |
Trapnet |
Trap network annotation |
No |
No |
24 |
Watermark |
Watermark annotation |
No |
No |
25 |
3D |
3D annotation |
No |
No |
26 |
Richmedia |
Rich media annotation |
No |
No |
*Please note that the annotation type of Widget is supported only in the “Form” module.
Right PDF SDK provides APIs for annotation creation, deletion, and property settings. Here are some common APIs for annotations listed in Table 3.2. For a complete list of APIs please refer to ZSAnnot.h.
Table 3.2
|
API Name |
Description |
1 |
ZSAnnot_GetLineEndingStyles |
Get line ending styles of an annotation. |
2 |
ZSAnnot_HasCaptionContents |
Check if there is a caption to a line annotation. |
3 |
ZSAnnot_GetAttachment |
Get attachment of a file attachment annotation. |
4 |
ZSAnnot_Add |
Add an annotation with a specific index, by the specific filter. |
5 |
ZSAnnot_Remove |
Remove an annotation from a page. |
6 |
ZSAnnot_SetFlags |
Set flags of an annotation. |
7 |
ZSAnnot_SetName |
Set name of an annotation. |
8 |
ZSAnnot_SetBorder |
Set border of an annotation. |
9 |
ZSAnnot_SetHighlighting Mode |
Set highlighting mode of a link or widget annotation. |
10 |
ZSAnnot_SetStampWithBitmap |
Set bitmap to a stamp annotation. |
11 |
ZSAnnot_SetAction |
Set action data of a specified index associated with an annotation. |
12 |
ZSAnnot_InsertAction |
Insert an action of specified index associated with an annotation. |
13 |
ZSAnnot_NumActions |
Get number of actions associated with an annotation. |
Example: Add a highlight annotation to a page and set properties.
ZSFRect rext = {0, 100, 100, 0};
ZSBStr annotType;
ZSBStr_Init(&annotType);
ZSBStr_Set(&annotType, “Highlight”, 9);
ZSAnnot annot = {0};
ZSResult ret = ZSAnnot_Add(page, &rect, &annotType, &annotType, 0, &annot);
if (ZS_OK != ret)
{
}
ZSFQuad quadPoints = {0, 0, 100, 0, 0, 50, 100, 50};
ZSAnnot_SetQuadPoints(annot, &quadPoints, 1);
ZSAnnot_SetColor(annot, ZS_FALSE, 0x0000FF00);
ZSAnnot_SetOpacity(annot, (ZSFloat)0.55);
|