• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Is there a way to get the current X and Y position of a PDF?

New Here ,
Dec 22, 2021 Dec 22, 2021

Copy link to clipboard

Copied

Hello,

 

I'm writing to ask if there is a function in the API to allow me to get the current X and Y position within the PDF.

 

More specifically, I'm integrating the PDF Embed API into my project, and I would like to add programmatic scrolling. That is, I would like to have a custom keybind in my application that, when pressed, will scroll the PDF up or down by a certain amount.

 

I've seen that scrolling is possible using the gotoLocation() method exposed by the API, which takes not only a page number, but also an X and Y coordinate.

 

This is great, but unfortunately, there's no easy way to increment the Y coordinate, because I can't find a way to get the current Y coordinate of the PDF/page.

 

One would think using the “SCROLLED” event would be possible, but there are two problems. Firstly, this event returns the scrollTop value, which is in viewport pixels, and hence does not give me the value I need to pass to gotoLocation(). Secondly, using an event would not be reliable in the first place, since I cannot be sure the event is called every single time the position is changed in some way — perhaps the position can change in other situations than a normal scroll.

 

I would appreciate any help in solving this problem!

TOPICS
PDF Embed API

Views

178

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Resources