How to get last read page to use in Calibre

Albert Astals Cid aacid at kde.org
Wed Apr 21 00:00:53 BST 2021


El dimarts, 20 d’abril de 2021, a les 18:29:48 (CEST), Xwang va escriure:
> Hi to all,

Hi

> 
> I would like to better integrate okular with calibre by writing a 
> calibre plugin which opens the selected PDF file with okular and then 
> saves the number of the last read page on a specific column in my 
> calibre database when I close okular.
> 
> I've seen that okular stores an .xml file for each opened file under 
> ~/.local/share/okular/docdata/ and uses the .xml content to reopen the 
> pdf file at the  last read page.
> 
> Is it possible to have the last read page as a return value when closing 
> okular?

It is technically possible, but it's not going to happen since it doesn't make sense.

> Otherwise is there any function I can call to get the last read page 
> giving the file name? (I presume something similar is used internally by 
> okular to open the file at its latest read page).

The problem functions to call would be to create a Document instance, call openDocument on it and later the viewport function.

That's all C++ exported in the okularcore library. If you can't call that you can get inspired in DocumentPrivate::docDataFileName and DocumentPrivate::loadDocumentInfo but note that we consider those to be private implementation details so they can change at any time.

Cheers,
  Albert

> 
> The plugin is written in python so if any binding with python already 
> exist I will be happy to use it.
> 
> Any suggestion is appreciated!
> 
> Have a nice day
> 
> 






More information about the Okular-devel mailing list