Skip to main content

Annotations

TFTPDF allows you to create annotations on your documents.

API

startCreate

Create an annotation. You can select between Measure, Perimeter, Area and Calibration.

ParamTypeDescription
toolstringSelect the desired tool
[single]boolSelect true to make a single measure, false to make a multi-point measure
[color]stringChange the color of the annotation tool
[showLength]boolToogle visibility of the length drawing of the measure - area and perimeter tool
[single]boolSelect true to make a single measure, false to make a multi-point measure
[guid]stringSet 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.

ParamTypeDescription
drawingArray.JSONArray of json annotations

Example

TFTPDFGadget.callCommand({
name: 'stopCreate',
callback: myfunc,
});
CAUTION
  • Call this command with an JSON object to load 1 annotation.
  • Call this command with an array of x JSON object to load all of them.
TFTPDFGadget.callCommand({
name: 'setPageAnnotation',
args: { drawing: { annotation_1 } },
callback: myfunc,
});

stopCreate

Stop the current tool.

Example

TFTPDFGadget.callCommand({
name: 'stopCreate',
callback: myfunc,
});

deleteAnnotation

Delete annotation with his GUID.

ParamTypeDescription
guidstringGUID of the annotations group.
[annotation_guid]stringGUID of the unique annotation.
ParamTypeDescription
guidstringGUID of the annotations group.
[unique_guid]stringGUID 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 or 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,
});

setSelection

Select a pin or a group of Annotations with their GUID.

ParamTypeDescription
guidstringGUID of the annotations group.
[annotation_guid]stringGUID 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.

Select a group or a unique annotation

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,
});

resetSelection

Reset the current selection.

ParamTypeDescription
guidstringGUID of the annotations group.
[annotation_guid]stringGUID 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.

Unselect a group or a unique annotation

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,
});

setComment

Set a comment to an Annotation.

ParamTypeDescription
guidstringThe GUID of the pin(s) you want to add a comment
commentstringThe 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.

ParamTypeDescription
guidstringGUID of the annotations group.
colorstringGUID 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.

ParamTypeDescription
guidstringGUID of the annotations group.
numbernumberNumber 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

ParamTypeDescription
guidstringGUID of the annotations group.
colorstringThe 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,
});