ImageEn, unit iexPdfiumCore

TPdfAnnotationList.NewAnnotation

TPdfAnnotationList.NewAnnotation


Declaration

function NewAnnotation(const R: TDRect; AnnotType: TPdfAnnotationSubType): Boolean; overload;
function NewAnnotation(const R: TDRect; AnnotType: TPdfAnnotationSubType; BorderColor, FillColor: TRGBA): Boolean; overload;


Description

Adds an annotation to the page at the specified position.
At this time, only patSquare or patCircle should be adding using this method.
The second overload initialize the annotation with a border and fill of the specified color and transparency

Note:
For patText, use NewTextAnnotation
For patLink, use NewLinkAnnotation


Demo

Demo  Demos\PDF\PDFAnnotations\PdfAnnotations.dpr


Examples

// Add an ellipse to the page (blue border and half-transparent red fill)
ImageEnView1.PdfViewer.Annotations.NewAnnotation( R, patCircle, TColor2TRGBA( clBlue, 255 ), TColor2TRGBA( clRed, 125 ));


// Add an rectangle to the page (green border and yellow fill)
ImageEnView1.PdfViewer.Annotations.NewAnnotation( R, patSquare, TColor2TRGBA( clGreen, 255 ), TColor2TRGBA( clYellow, 255 ));


// Convert the selection to a rectangular annotation
procedure TfrmMain.btnAddAnnotationClick(Sender: TObject);
var
  selR: TRect;
  R: TDRect;
begin
  if ImageEnView1.Selected = False then
    exit;

  // Get selection as screen values
  selR := Rect( ImageEnView1.XBmp2Scr( ImageEnView1.SelX1 ),
                ImageEnView1.YBmp2Scr( ImageEnView1.SelY1 ),
                ImageEnView1.XBmp2Scr( ImageEnView1.SelX2 ),
                ImageEnView1.YBmp2Scr( ImageEnView1.SelY2 ));

  if ( selR.width < 10 ) or ( selR.height < 10 ) then
    exit;

  R := ImageEnView1.PdfViewer.ScrToPage( selR, true );
  ImageEnView1.PdfViewer.Annotations.NewAnnotation( R, patSquare, TColor2TRGBA( clGreen, 255 ), TColor2TRGBA( clYellow, 125 ));
end;


See Also

NewTextAnnotation
NewLinkAnnotation
TColor2TRGBA