ImageEn, unit iexPdfiumCore

TPdfAnnotationList


Declaration

TPdfAnnotationList = class;


Description

Provides access to the annotations of a PDF page.



Methods and Properties

Public Property  Count: Integer;
Public Property  HighlightedIndex
Public Method  FindAnnotationAt
Public Property  Items[Index: Integer]: TPdfAnnotation;
Public Method  NewAnnotation
Public Method  NewLinkAnnotation
Public Method  NewTextAnnotation
Public Method  Remove


Demo

Demo  Demos\PDF\PDFAnnotations\PdfAnnotations.dpr


Examples

// Add a text annotation to the page
ImageEnView1.PdfViewer.Annotations.NewLinkAnnotation( R, 'ImageEn Rules!' );


// Output all annotations on the page
for i := 0 to ImageEnView1.PdfViewer.Annotations.Count -1 do
begin
  ann := ImageEnView1.PdfViewer.Annotations[i];
  lbxAnnotations.Items.Add( Format( 'Annot %d: (%s) at (%d,%d,%d,%d)',
                                    [ i+1, PdfAnnotTypeToStr( ann.AnnotType ),
                                      Round(ann.Bounds.Left), Round(ann.Bounds.Top), Round(ann.Bounds.Right), Round(ann.Bounds.Bottom) ]));
end;


// Delete the first annotation from the page
ImageEnView1.PdfViewer.Annotations.Remove( 0 );
ImageEnView1.PdfViewer.ReloadPage();


// Remove the selected annotation from the PDF page
ImageEnView1.PdfViewer.Annotations.Remove( ImageEnView1.PdfViewer.SelectedAnnotation );
ImageEnView1.PdfViewer.ReloadPage();


// 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;