Link annotations
Link annotations define clickable regions that open a URI or jump within the document. Links are not Markup annotations (no opacity, replies, etc.).
Action types
| Action | Class | Description |
|---|---|---|
| URI | FSURIAction | External URL |
| GoTo | FSGotoAction | In-document page and view |
Example: URI link
objc
#import <FoxitRDK/FSPDFObjC.h>
FSPDFDoc *doc = [[FSPDFDoc alloc] initWithPath:@"path/to/Sample.pdf"];
[doc load:nil];
FSPDFPage *page = [doc getPage:0];
FSRectF *rect = [[FSRectF alloc] initWithLeft1:100 bottom1:700 right1:300 top1:720];
FSAnnot *annot = [page addAnnot:FSAnnotLink rect:rect];
FSLink *link = [[FSLink alloc] initWithAnnot:annot];
if (!link || [link isEmpty]) return;
FSAction *action = [FSAction create:doc action_type:FSActionTypeURI];
FSURIAction *uriAction = [[FSURIAction alloc] initWithAction:action];
[uriAction setURI:@"https://www.foxitsoftware.com"];
[link setAction:uriAction];
[link resetAppearanceStream];
[doc saveAs:@"path/to/output.pdf" saveFlags:FSPDFDocSaveFlagNormal];Example: in-document link
objc
#import <FoxitRDK/FSPDFObjC.h>
FSPDFDoc *doc = [[FSPDFDoc alloc] initWithPath:@"path/to/Sample.pdf"];
[doc load:nil];
FSPDFPage *page = [doc getPage:0];
FSRectF *rect = [[FSRectF alloc] initWithLeft1:100 bottom1:650 right1:250 top1:670];
FSAnnot *annot = [page addAnnot:FSAnnotLink rect:rect];
FSLink *link = [[FSLink alloc] initWithAnnot:annot];
FSDestination *dest = [FSDestination createFitPage:doc page_index:4];
FSAction *action = [FSAction create:doc action_type:FSActionTypeGoto];
FSGotoAction *gotoAction = [[FSGotoAction alloc] initWithAction:action];
[gotoAction setDestination:dest];
[link setAction:gotoAction];
[link resetAppearanceStream];Note
page_index in [FSDestination createFitPage:page_index:] is zero-based. See also createXYZ:page_index:left:top:zoom: and createFitWidth:page_index:top:.
Highlighting mode
| Constant | Description |
|---|---|
FSAnnotHighlightingNone | None |
FSAnnotHighlightingInvert | Invert region (default) |
FSAnnotHighlightingOutline | Invert border |
FSAnnotHighlightingPush | Push effect |
objc
[link setHighlightingMode:FSAnnotHighlightingInvert];Methods summary
| Method | Description |
|---|---|
getAction / setAction: | Associated action |
removeAction | Remove action |
getHighlightingMode / setHighlightingMode: | Highlight mode |