<< Click to Display Table of Contents >> Navigation: Tasks > Draw Shapes / Text objects on PDF > Modify attributes of draw objects / annotations |
It is also possible to change the attributes of the currently selected annotation and/or draw objects using the command COMPDF_Ann_ModifyAddProps. It will expect a comma separated list with name-property pair. The names should be the same as the names used with the internal actions.
procedure TForm1.btnSelectColorClick(Sender: TObject);
begin
if (pdf<>nil) and ColorDialog1.Execute(Handle) then
begin
pdf.command(COMPDF_Ann_ModifyAddProps,
'Brush-Color=' + ColorToString(ColorDialog1.Color) , 4 + 8);
end;
end;
For draw objects this names can be used
Font
Font-Size
Alpha
Line-Width
Line-Color
Brush-Color
Text
With "'HighlightType=..." it is also possible to set the annotation which will be created for selected text. The default is "Highlight", a possible alternative would be "Square".
pdf.CommandStrEx( COMPDF_Ann_ModifyAddProps, 'HighlightType=Square' , 1+8 );
Note: The name "Color" and "Background-Color" is used for annotations, not draw objects.
Please make sure the " signs are paired.
The integer parameter is a bit field (if 0 nothing will be changed!)
1 : modify the "current" attributes. This attributes are used by the currently active action or "Draw mode".
2 : modify the attributes of the currently selected annotations - mode 2.
4 : Auto Mode: If annotations are selected, they will be modified.
If nothing is selected, the "current" attributes are modified.
8 : If the current attributes are changed,
also change the defaults for the highlight, frame and freetext actions
16: Do not update the screen
32: Limit use of undo buffer (only stores first element)
You can also use command(COMPDF_Ann_Undo, 4) to disable the undo buffer.
Dont' forget to call command(COMPDF_Ann_Undo, 5) to enable it again.