THPDFViewer Highlights and Marquee Selection
Marks page regions without changing the PDF and converts interactive selections back to PDF page coordinates
Declarations
function THPDFViewerModel.AddHighlightRegion(PageIndex: Integer;
const PageRect: THPDFRectangle; Color: TColor= clYellow): Integer;
function THPDFViewerModel.RemoveHighlightRegion(Index: Integer): boolean;
procedure THPDFViewerModel.ClearHighlightRegions;
function THPDFViewerModel.TryGetHighlightRegion(Index: Integer;
out Highlight: THPDFViewerHighlight): boolean;
property THPDFViewer.InteractionMode: THPDFViewerInteractionMode;
property THPDFViewer.HighlightColor: TColor;
property THPDFViewer.OnMarqueeSelect: THPDFViewerMarqueeSelectEvent;
Programmatic highlights
Region.Left:= 72;
Region.Bottom:= 540;
Region.Right:= 240;
Region.Top:= 600;
HighlightIndex:= Viewer.HighlightRegion(0, Region, clLime);
Interactive selection
Viewer.InteractionMode:= vimHighlight;
Viewer.HighlightColor:= clYellow;
Viewer.OnMarqueeSelect:= ViewerMarqueeSelect;
Usage notes
- Page indexes are zero based and rectangles use PDF page coordinates
- Input rectangles are normalized and clipped to the visible page box, the CropBox clipped to the MediaBox
- Highlights are Viewer state only and do not modify or save into the PDF
- Each successful addition returns its current list index; invalid or empty regions return -1
vimHighlightcaptures a left-button drag, draws a temporary outline, stores the completed region, and raisesOnMarqueeSelect- Marquee coordinates account for page rotation, Viewer rotation, zoom, and fit modes
- Assigning another document clears all existing highlights