Function DrawAnnotation

Top  Previous  Next

The methods DrawAnnotation are very variable to create PDF annotations. However insights of the PDF syntax are required. Both methods return 0 or the number of the newly created annotation object.

 

function TWPCustomPDFExport.DrawAnnotation(

  pt : array of TPoint;

  AnnotType : AnsiString;

  AnnotPopupID : Integer;

  AnnotParams : array of String;

  AnnotAppearances : array of String;

  AnnotMode : Integer; 

  AnnotData : Pbyte=nil; AnnotDataLen : Integer=0 ) : Integer;overload;

 

function DrawAnnotation( pt : array of TPoint; 

        AnnotType : AnsiString;

        AnnotPopupID : Integer;

        AnnotParams : TStrings; 

        AnnotMode : Integer;

        AnnotData : Pbyte=nil; AnnotDataLen : Integer=0 ) : Integer; overload;

 

 

Parameters:

 

pt        This is an array of 4 or 8 points. In case of 4 points the PDF parameter /Rect will be created, otherwise also /QuadPoints will be created.

 

AnnotType        This is the most important parameter. It can contain any PDF parameters as clear text, i.e. "/Subtype/FreeText/F 4" or "/Subtype/Text/Name/Comment/F 28/C [1 0 1]".

 

AnnotPopupID        Unless it is 0, this is expected to be the number of a different annotation which was created before. This annotation will be then linked to the new annotation through the PDF parameter /Popup ref.

 

AnnotParams        This array or stringlist contains a string parameters for the annotation in the form "name=value". Since string parameter have to be specially encoded into PDF it is not possible to pass them through the parameter AnnotType.

 

AnnotAppearances        This are the names of the XForms (which can be created with StartWatermark) which should be used as appearance stream. In case AnnotParams is of type TStrings there is no AnnotAppearances parameter. In this case add the appearance names to the AnnotParams with a leading "#", i.e. "#N=FREETEXT1"

 

Example:

     pdf.StartWatermark('FREETEXT1', 100,20,0,0);

     pdf.Canvas.TextOut(0,0,'Watermarktext');

     pdf.EndWatermark; 

 

     pdf.DrawAnnotation([Point(100,100), Point(200,120)],

           '/Subtype/FreeText/F 4',

           i,

            ['Subj=Watermarktext',

             'Contents=Watermarktext',

             'DA=1 0 0 rg /Helv 12 Tf'

             ],

             ['N=FREETEXT1'],

             0, nil, 0);

 

AnnotMode        Bitfield.

 8192 - the annotation will not be listed in the Fields[] array of the AcroForm object

 

 

 

AnnotData and AnnotDataLen is currently not being used. It can be useful for multimedia.