ipgnomedbusgdbusbusctl

How do I get the current page number from an open PDF document in Evince using DBus?


If I open a PDF document inside evince (GNOME Document Viewer), how do I get the current page number using DBus?

using zathura I could get the page number using the following command:

busctl get-property --user org.pwmt.zathura.PID-1123767 \
 /org/pwmt/zathura \ 
org.pwmt.zathura pagenumber

(I have used D-Feet to get the bus, object, and interface names).

However, when it comes to Gnome evince, I can't find any API to retrieve the current page number.

Are there any options to achieve that?

P.S: I am using evince 3.36.10 on Ubuntu 20.04


Solution

  • I think there is no way to retrieve that information using DBus. However, one can use GVFS (Gnome Virtual File System) to retrieve the metadata relevant to the page number:

    gio info -a "metadata::evince::page" /path/to/the/pdf/file
    

    This informations is updated whenever you scroll the page.

    One important note (according to my tests) is that the document should not be under /tmp directory as it appears that those metadata are not saved.