I have no time to do more research for you but this may be a starting point for you. This should wotk with all 5.2* Versions.
Best regards, Marian
procedure TPDFViewerForm.imgPdfPageMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); type TRectangleF = record Left, Top, Width, Height: Double; end; TPointF = record X, Y : Double; end;
function RectangleF(Left, Top, Width, Height: Double) : TRectangleF; begin Result.Left := Left; Result.Top := Top; Result.Width := Width; Result.Height := Height; end;
function PointF(X, Y : Double) : TPointF; begin Result.X := X; Result.Y := Y; end;
function Contains(Rect: TRectangleF; Point : TPointF) : Boolean; begin Result := (Point.X >= Rect.Left) and (Point.X <= (Rect.Left + Rect.Width)) and (Point.Y >= Rect.Top) and (Point.Y <= (Rect.Top + Rect.Height)); end;
procedure MultDiv(var Rect : TRectangleF; nMult, nDiv : Double); overload; begin Rect.Left := Rect.Left * nMult / nDiv; Rect.Top := Rect.Top * nMult / nDiv; Rect.Width := Rect.Width * nMult / nDiv; Rect.Height := Rect.Height * nMult / nDiv; end;
procedure MultDiv(var Point : TPointF; nMult, nDiv : Double); overload; begin Point.X := Point.X * nMult / nDiv; Point.Y := Point.Y * nMult / nDiv; end;
procedure DeviceToSpaceCoordinates(Pdf : IQuickPDF2; var Rect : TRectangleF); overload; begin MultDiv(Rect, PageResolution, STD_DPI); Rect.Top := Pdf.PageHeight - Rect.Top - Rect.Height; end;
procedure DeviceToSpaceCoordinates(Pdf : IQuickPDF2; var Point : TPointF); overload; begin Point.Y := Pdf.PageHeight - Point.Y; MultDiv(Point, PageResolution, STD_DPI); end; var nCount : Integer; nIndex : Integer; strPrp : string; intDst : Integer; strDst : string; rect : TRectangleF; point : TPointF; begin if IsEmpty then Exit; point := PointF(x, y); DeviceToSpaceCoordinates(Pdf, point);
//Log_Message('<AnnotationCheck>'); nCount := Pdf.AnnotationCount; for nIndex := 1 to nCount do begin try strPrp := string(Pdf.GetAnnotStrProperty(nIndex, 101)); if CompareText(strPrp, 'Link') <> 0 then Continue; rect := RectangleF( Pdf.GetAnnotDblProperty(nIndex, 105), Pdf.GetAnnotDblProperty(nIndex, 106), Pdf.GetAnnotDblProperty(nIndex, 107), Pdf.GetAnnotDblProperty(nIndex, 108));
if not Contains(rect, point) then Continue;
//Log_MessageFmt('%n:%n:%n:%n - %n:%n', [rect.Left, rect.Top, rect.Left + rect.Width, rect.Top + rect.Height, point.X, point.Y]); MessageBeep(MB_ICONEXCLAMATION); case Pdf.GetAnnotIntProperty(nIndex, 111) of 0, 1: begin intDst := Pdf.GetAnnotIntProperty(nIndex, 112); if intDst > 0 then begin {$IFDEF _DEBUG} intDst := Pdf.GetDestPage(intDst); LogMessageFmt('Link[%d]->GotoPage: %d', [nIndex, intDst]); {$ENDIF} end; end; 4, 6: begin strDst := Pdf.GetAnnotStrProperty(nIndex, 112); {$IFDEF _DEBUG} LogMessageFmt('Link[%d]->Launch: %s', [nIndex, strDst]); {$ENDIF} end; end; except end; end; //Log_Message('</AnnotationCheck>'); end;
|