Ticket T644461
Visible to All Users

TdxPDFViewer: Getting PDF user space coodinates

created 7 years ago

Dear DevExpress team,

I need to obtain the coordinates of a clicked point in a pdf file. As far as I understand, the TdxPDFViewerCustomHitTest.HitPoint contains the current coordinates within the control expressed in points. Is there a way to find out the corresponding coordinates where in the pdf file expressed in pdf user space coordinates?

Thanks,

Matthias.

Comments (2)
DevExpress Support Team 7 years ago

    Hello Matthias,

    Would you please provide us with a screenshot of the PDFViewer and mark there what coordinates you wish to obtain?

      Hello Mikhail,

      I need to paint markers on a PDFViewer canvas that sticks to a certain position in the PDF file. Therefore, the coordinates used for drawing depends on the current zoom level, rotation and displayed section of the PDF file. Is there a way to obtain information on what part of the PDF file is displayed currently?

      Thanks.

      Answers approved by DevExpress Support

      created 7 years ago

      Hello Matthias,

      You can try working with the Position protected property of a HitTest object. This property contains information about the Page index and required coordinates.

        Show previous comments (2)

          I have the same problem as MatthiasN…

          When I click on a certain page of the PDF, I want to obtain the coordinates (on the PDF page) and the page number.
          So, coordinates on the PDF page and not the coordinates on the dxPDFViewer component. Those I can get with onMouseDown event…

          I've tried it all, but didn't get any results.
          Also the approach you mentioned, but it doesn't work, or maybe I did something wrong…

          My code:

          Delphi
          ..... TADXPDFViewerDocumentHitTest = class(TdxPDFViewerDocumentHitTest) strict private FPosition: TdxPDFPosition; public property Position: TdxPDFPosition read FPosition; end; ...... procedure TfrmMain.dxPDFViewer1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); var iPage : Integer; sX,sY : Single; begin iPage := TADXPDFViewerDocumentHitTest(dxPDFViewer1.HitTest).Position.PageIndex; sX := TADXPDFViewerDocumentHitTest(dxPDFViewer1.HitTest).Position.Point.X; sY := TADXPDFViewerDocumentHitTest(dxPDFViewer1.HitTest).Position.Point.Y; end;

          Can you please make a small sample, that shows the right approach?

          DevExpress Support Team 3 years ago

            Hello Mlojk,

            Would you please elaborate on what you mean by saying "on the PDF page". The TADXPDFViewerDocumentHitTest(dxPDFViewer1.HitTest).Position property contains coordinates of a point in a document model, but not on the PDF viewer's page.
            In addition please describe your task in greater detail. Perhaps, we will be able to offer an alternative solution. Sharing a couple of screenshots demonstrating actual and expected results would be much appreciated.

              Hi,

              I am sorry.
              Everything works fine, I was looking at the wrong variables…

              Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

              Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.