Annotations
TFTPDF allows you to create annotations on your documents.
API
startCreate
Create an annotation. You can select between Measure, Perimeter, Area and Calibration.
| Param | Type | Description |
|---|---|---|
| tool | string | Select the desired tool |
| [single] | bool | Select true to make a single measure, false to make a multi-point measure |
| [color] | string | Change the color of the annotation tool |
| [showLength] | bool | Toogle visibility of the length drawing of the measure - area and perimeter tool |
| [single] | bool | Select true to make a single measure, false to make a multi-point measure |
| [guid] | string | Set a group_guid if you want to add a pin to an existing group |
Available tool options:
- annotation: Select the annotation tool.
- measure: Select measure tool.
- area: Select area tool.
- perimeter: Select perimeter tool.
- calibration: Set a calibration to match the scale of the plan on the pdf.
Example
TFTPDFGadget.callCommand({
name: 'startCreate',
args: {
tool: 'annotation',
single: 'false',
color: 'yellow',
showLength: 'false',
},
callback: myfunc,
});
setPageAnnotation
Add a JSON annotation on the PDF. The command parse the Json with the className and draw the annotation on the correct page.
| Param | Type | Description |
|---|---|---|
| drawing | Array.JSON | Array of json annotations |
Example
TFTPDFGadget.callCommand({
name: 'stopCreate',
callback: myfunc,
});
- Call this command with an
JSON objectto load 1 annotation. - Call this command with an
arrayof xJSON objectto load all of them.
- Load 1 annotation
- Load multiples annotations
TFTPDFGadget.callCommand({
name: 'setPageAnnotation',
args: { drawing: { annotation_1 } },
callback: myfunc,
});
TFTPDFGadget.callCommand({
name: 'setPageAnnotation',
args: { drawing: [{ annotation_1 }, { annotation_2 }, { annotation_3 }] },
callback: myfunc,
});
stopCreate
Stop the current tool.
Example
TFTPDFGadget.callCommand({
name: 'stopCreate',
callback: myfunc,
});
deleteAnnotation
Delete annotation with his GUID.
| Param | Type | Description |
|---|---|---|
| guid | string | GUID of the annotations group. |
| [annotation_guid] | string | GUID of the unique annotation. |
| Param | Type | Description |
|---|---|---|
| guid | string | GUID of the annotations group. |
| [unique_guid] | string | GUID of the unique annotation. |
Example
TFTPDFGadget.callCommand({
name: 'deleteAnnotation',
args: {
guid: '4a4f720b64b7-4170-aa1b-80c8fdb595d3',
unique_guid: 'xxxxxxxxx-xxxxx-xxxxx',
},
callback: myfunc,
});
Please see this Hint below to know how to delete a group or an unique annotation.
- Delete a group
- Delete a unique annotation
Use the guid of the group to delete all annotations inside it.
TFTPDFGadget.callCommand({
name: 'deleteAnnotation',
args: {
guid: '4a4f720b-64b7-4170-aa1b-80c8fdb595d3',
},
callback: myfunc,
});
Use the guid of the group and the annotation_guid of the unique annotation to delete it.
TFTPDFGadget.callCommand({
name: 'deleteAnnotation',
args: {
guid: '4a4f720b-64b7-4170-aa1b-80c8fdb595d3',
unique_guid: '5a8f774z-67a9-ez55-2184-1973eptda4x9',
},
callback: myfunc,
});
setSelection
Select a pin or a group of Annotations with their GUID.
| Param | Type | Description |
|---|---|---|
| guid | string | GUID of the annotations group. |
| [annotation_guid] | string | GUID of the unique annotation. |
Example
TFTPDFGadget.callCommand({
name: 'setSelection',
args: { guid: '4a4f720b-64b7-4170-aa1b-80c8fdb595d3' },
callback: myfunc,
});
Please see this Hint below to know how to select a group or an unique annotation.
- Group
- Unique
Use the guid of the group to select all annotations inside it.
TFTPDFGadget.callCommand({
name: 'setSelection',
args: {
guid: '4a4f720b-64b7-4170-aa1b-80c8fdb595d3',
},
callback: myfunc,
});
Use the guid of the group and the annotation_guid of the unique annotation to select it.
TFTPDFGadget.callCommand({
name: 'setSelection',
args: {
guid: '4a4f720b-64b7-4170-aa1b-80c8fdb595d3',
unique_guid: '5a8f774z-67a9-ez55-2184-1973eptda4x9',
},
callback: myfunc,
});
resetSelection
Reset the current selection.
| Param | Type | Description |
|---|---|---|
| guid | string | GUID of the annotations group. |
| [annotation_guid] | string | GUID of the unique annotation. |
Example
TFTPDFGadget.callCommand({
name: 'resetSelection',
args: { guid: '4a4f720b-64b7-4170-aa1b-80c8fdb595d3' },
callback: myfunc,
});
Please see this Hint below to know how to unselect a group or an unique annotation.
- Group
- Unique
Use the guid of the group to select all annotations inside it.
TFTPDFGadget.callCommand({
name: 'resetSelection',
args: {
guid: '4a4f720b-64b7-4170-aa1b-80c8fdb595d3',
},
callback: myfunc,
});
Use the guid of the group and the annotation_guid of the unique annotation to select it.
TFTPDFGadget.callCommand({
name: 'resetSelection',
args: {
guid: '4a4f720b-64b7-4170-aa1b-80c8fdb595d3',
unique_guid: '5a8f774z-67a9-ez55-2184-1973eptda4x9',
},
callback: myfunc,
});
setComment
Set a comment to an Annotation.
| Param | Type | Description |
|---|---|---|
| guid | string | The GUID of the pin(s) you want to add a comment |
| comment | string | The comment you want to set to the corresponding pin |
Example
TFTPDFGadget.callCommand({
name: 'setComment',
args: {
guid: '4a4f720b-64b7-4170-aa1b-80c8fdb595d3',
comment: 'This is a new comment',
},
callback: myfunc,
});
moveAnnotation
Move the desired annotation - Start the state to edit position, stop with stopMoveAnnotation.
Example
TFTPDFGadget.callCommand({ name: 'moveAnnotation', callback: myfunc });
stopMoveAnnotation
Disable the moveAnnotation mode.
Example
TFTPDFGadget.callCommand({
name: 'stopMoveAnnotation',
callback: myfunc,
});
getTotalPinCount ⇒ number
Get the total count of annotations in the current Page.
Example
TFTPDFGadget.callCommand({ name: 'getTotalPinCount', callback: myfunc });
setColor
Update the color of a group of Annotations with their GUID.
| Param | Type | Description |
|---|---|---|
| guid | string | GUID of the annotations group. |
| color | string | GUID of the annotations group. |
Example
TFTPDFGadget.callCommand({
name: 'setColor',
args: { guid: '4a4f720b-64b7-4170-aa1b-80c8fdb595d3', color: 'green' },
callback: myfunc,
});
setNumber
Set a number to a group of pin.
| Param | Type | Description |
|---|---|---|
| guid | string | GUID of the annotations group. |
| number | number | Number to add to the annotations group. |
Example
TFTPDFGadget.callCommand({
name: 'setNumber',
args: { guid: '4a4f720b-64b7-4170-aa1b-80c8fdb595d3', number: '4' },
callback: myfunc,
});
updateNumberColor
Update the color number of a group of Annotations with their GUI
| Param | Type | Description |
|---|---|---|
| guid | string | GUID of the annotations group. |
| color | string | The desired color for the numbers (pin_index) inside the annotations (Use string or hexadecimal color code ex: #FFFFF) |
Example
TFTPDFGadget.callCommand({
name: 'updateNumberColor',
args: { guid: '4a4f720b-64b7-4170-aa1b-80c8fdb595d3', color: 'red' },
callback: myfunc,
});