Hi.
I have imported into LibreOffice Draw a PDF datasheet for an electronics part, which table of contents is deprived of hyperlinks. It is a 300 pages document and it is perfectly imported into LODraw — except maybe fonts are not 100% identical since the document was created on a Windows machine and I’m running Draw on Manjaro Linux. Anyway this is not the reason I am asking here.
I’d like to automate the task of creating a hyperlink on page numbers in the TOC. The latter is about ten pages long, each of which contains a few dozens of entries. Although generating a PDF back again seems to work flawlessly, doing it all manually is extremely tedious as I need more than a dozen keystrokes to update a single link. It is also prone to errors.
What I’d like is to automate it all. A typical TOC line appears as follows:
<section ID> <text> ......................... <page n°>
Fields are separated with spaces, although it doesn’t really matter.
So I’d like to insert a hyperlink to the adequate page on the page number. I can think of two scenarios:
- clicking twice on the page number inside the text frame, then run a macro that inserts the hyperlink to the required page (which keyboard equivalent is: Ctrl+K, Tab, Tab, Tab, Tab, Enter or Space, , Enter, Tab, Enter, Tab, Enter - the last two Tab/Enter are meant to close the dialog boxes);
- the macro scans all the text frames on the page from pages 2 to 10 and inserts the hyperlink where a given pattern matches.
The latter option would be ideal to me.
I have never programmed under LibreOffice but I am a developer. How could/would I implement such a functionality?
Here are the operations I suppose I would need in order to achieve this:
- enumerate text frames in a document (which name follows a known pattern);
- retrieve the text;
- lookup for the last characters and make sure they’re digits (ideally, that match a page number)
- Insert the hyperlink, preferably by program instead of showing the dialogue.
The thing is I have no idea how to do any of that.
Thanks a lot in avance for any hint/suggestion/guideline.
C.F.