Create a relative hyperlink to file?

I am trying to create a Writer document with a number of links to files
in the same directory as the odt file itself. Using absolute paths
everything works perfectly, but relative links (eg. file://abc.xyz)
always fail with a "not an *absolute* URL" error.

TIA

Dave

PS. Apologies if this is a duplicated post.

you need 3 '/', see: https://en.wikipedia.org/wiki/File_URI_scheme

I should be: file:///abc.xyz
not: file://abc.xyz

Hi,
Does not seem to work with something like file://./abc.xyz either.Rémy.

No. Exactly the same error message.

Hi Dave,

I am trying to create a Writer document with a number of links to files
in the same directory as the odt file itself. Using absolute paths
everything works perfectly, but relative links (eg. file://abc.xyz)
always fail with a "not an *absolute* URL" error.

Du erzeugst den Hyperlink mit Strg+K und dann Dokument?

Versuche nicht den Link von Hand einzugeben sondern benutze _immer_ den Dateiauswahl-Button rechts vom Sprungziel-Eingabefeld. Dazu muss die zu verlinkende Datei natürlich schon mit der Textdatei zusammen im gleichen Ordner liegen. Lass dich nicht von der Anzeige täuschen. Sie zeigt nicht den gespeicherten Text. In der Datei ist der Link relativ gespeichert. Solche Links sind eigentlich immer relativ, außer der Weg geht über Laufwerksgrenzen hinaus.

Wenn du nicht sicher bist, was dort gespeichert ist, dann öffne die Datei z.B. mit 7Zip und gucke in die content.xml hinein.

Mit freundlichen Grüßen
Regina

Hi Dave,

please excuse, same in English:

Hi Dave,

I am trying to create a Writer document with a number of links to files
in the same directory as the odt file itself. Using absolute paths
everything works perfectly, but relative links (eg. file://abc.xyz)
always fail with a "not an *absolute* URL" error.

You create the hyperlink with Ctrl+K and then Document?

Do not try to manually enter the link, but _always_ use the button at the right side of the Target input field. Of cause the target needs to be already in the same folder as the text file.

Be not confused by the shown text. It does not show, what is stored in the file. The link is stored as relative. Such links are usually stored as relativ, even if not in the same folder. Only if a target is on a different drive, the link is absolute.

If you are unsure about the saved text, open the file e.g. with 7Zip and look into the content.xml. You will find the link starting with ../

Kind regards
Regina

Hi Dave,

I am trying to create a Writer document with a number of links to files
in the same directory as the odt file itself. Using absolute paths
everything works perfectly, but relative links (eg. file://abc.xyz)
always fail with a "not an *absolute* URL" error.

The links will be saved als relative links in the file. Try to move the
file to another folder - together with the other documents. It will work.

Have a look in the *.odt-file in content.xml:
<text:a xlink:type="simple" xlink:href="../LibreOffice/Bilder_gross.odt"
will open the document Bilder_gross.odt, which is in a subfolder of the
document I have created.

For documents you could set in the further settings for a Hyperlink:
Text: "My Document". Then there will be shown only the name "My
Document" for the document. Not the absolute path to the file, which is
saved only for the shown text in the document, not for the real path to
the file. This information of the path is misleading.

Regards

Robert

Hi Dave,

please excuse, same in English:

No problem. Your English is a million times better than my tiny
understanding of German.

Hi Dave,

I am trying to create a Writer document with a number of links to files
in the same directory as the odt file itself. Using absolute paths
everything works perfectly, but relative links (eg. file://abc.xyz)
always fail with a "not an *absolute* URL" error.

You create the hyperlink with Ctrl+K and then Document?

Do not try to manually enter the link, but _always_ use the button at
the right side of the Target input field. Of cause the target needs to
be already in the same folder as the text file.

Be not confused by the shown text. It does not show, what is stored in
the file. The link is stored as relative. Such links are usually stored
as relativ, even if not in the same folder. Only if a target is on a
different drive, the link is absolute.

If you are unsure about the saved text, open the file e.g. with 7Zip and
look into the content.xml. You will find the link starting with ../

Kind regards
Regina

Hi Regina,

Many thanks for taking the time to reply.

The odt document and the linked files are all in the same local directory.

I open the hyperlink dialog either by the menu, toolbar or keyboard
Ctrl+K. I do not manually enter the link. In the hyperlink dialog I
select the "Open File" button to the right of "Document > Path", see:
http://www.mediafire.com/view/33hc7qwbjtc7dlp/Hyperlink_Dialog.png/file
Selecting the file from the open file dialog ALWAYS adds the full
(ABSOLUTE) path to the hyperlink in the document.

Maybe I have misunderstood or misinterpreted your explanation, but I
cannot find anything in the hyperlink dialog that provides an option to
create a RELATIVE hyperlink to to another file.

I should add that part of my reason for asking this question is that if
I can get this to work it will form the basis of a section in the next
edition of our official Writer Guide, so so telling our readers to unzip
odt files is definitely not an acceptable option.

Thanks & Kind Regards
Dave

Hi Robert,

Many thanks for taking the time to reply.

If you look at my original post and my reply to Regina the odt file and
the hyperlinked files are are already in the same directory, so I see no
reason why moving them to another location would change anything.

It really doesn't matter what appears in content.xml. The critical point
is that keyboard Ctrl+click on the hyperlink in the odt file generates a
"not an *absolute* URL" error.

Sorry if I have misunderstood or misinterpreted the explanation you and
Regina have kindly given, but I need to clearly explain this for
inexperienced users in the next edition of the official LibreOffice
Writer Guide.

Kind Regards
Dave

Hi Dave,

I have now used an English UI, and now the correct fields. Open Hyperlink-dialog, click Document. Click "Open File" button at the ride side of the Document Path field.

I have tried with system open file dialog and with LO's own dialog. It works in both cases. Ctrl-click opens e.g. a linked .odt file in LibreOffice.

I work on Windows 10. What OS do you use? Perhaps there is an error in Linux?

Kind regards
Regina

Regina -

FWIW, I just tried it in LO 6.1.5.2 under Debian Linux 10 and it worked as you said, without an error message, and with the very misleading appearance of the absolute path in LO (but with the relative path appearing in content.xml).

- Robert F.

Personally, I think this is a bug. In Debian 64 bit, what you have found gives the same error for versions, 6.2.8, 6.3.6, and 7.0.1.

Dan

I just tried in UbuntuStudio 20.04.1 with LO 6.4.5.2 and the procedure works fine as Regina said.

But as Robert says, too, the path is indicated in the absolute form in the Document Path field. Right clicking on the link and selecting Edit Hyperlink also shows an absolute path. But inspection of content.xml confirms that the path is relative.

If the file with the hyperlink is moved to a different directory, the link updates showing again an absolute path as though the linked file has also been moved. But, of course, the link no longer works because it was relative and all the files concerned are no longer in the same directory.

I rechecked on a Windows10 box (up to date) with LO 6.3.5.2 and the behaviour is exactly the same, showing an absolute path when really it is relative.

Indicating an absolute path in the linking dialogue is misleading.

Philip

Hi Regina & all,

Even though I was following instructions to the letter I must have been
doing something wrong wrong yesterday. Today I started the computers
(Win 10-2004 x64 & Linux Kernel 5.8 x64) running LO 7.0.1.2, opened the
odt file and the relative links worked perfectly. I am still unsure of
how to explain the appearance of absolute paths over the links when
writing up the user guides, but that is a different issue.

Having got the odt file working, I am now looking for a way to get those
relative links working in an exported PDF copy of the file. I have tried
several different export options, but clicking the links in the PDF file
always returns the "File <Absolute Path> not found" error.
Any thoughts or suggestions about this would be welcome.

Thanks for all your help.

Best Regards
Dave

What version of LibreOffice are you using, and what is the exact wording of the error message? At least with recent versions of LibreOffice, the wording of the error message when clicking the link should be: "'file://abc.xyz/' cannot be passed to an external application to open it (e.g., it might not be an absolute URL, or might denote no existing file)."

And note that <file://abc.xyz/> is not a relative URL, it is an absolute file URL with an "abc.xyz" authority, which is interpreted by LibreOffice at least on Windows to denote the root directory of some (most likely non-existing) abc.xyz UNC share.

Hi Stephan,

Thanks for taking the time to reply, but as I said in response to Regina
and others later in this thread: "Today I started the computers
(Win 10-2004 x64 & Linux Kernel 5.8 x64) running LO 7.0.1.2, opened the
odt file and the relative links worked perfectly." I am unable to
discover or explain why it did not work initially.

My issue now is to find a way to get those relative links working in an
exported PDF copy of the file. I have tried several different export
options, but clicking the links in the PDF file always returns the "File
<Absolute Path> not found" error.

Best Regards
Dave

PS. I am subscribed to the list so the cc isn't necessary. :wink:

Is there someone able to shine a light on this subject?

Thing is that links break when mailing or moving and that is a serious flaw.

For example, I would expect a template name without path in a document xml, result in a search for that template in:

  * the designated template folder
  * the home folder
  * the folder where the document lives

Apparently this does not work, not even one folder is consulted.

Is there some sort of a search path available? A policy? It would really be helpful if this subject is discussed and I would love to see a contribution.

Nobody?

The lack of response is probably a confirmation that there is no mechanism to keep links to various external sources up to date.

It is probably save to state that if you want to repair a link lacking an interface element, then unzipping, editng xml and zipping is the only way.

Odd but okay.

>> Thing is that links break when mailing or moving and that is a
>> serious flaw.
>>
>> For example, I would expect a template name without path in a
>> document xml, result in a search for that template in:
>>
>>   * the designated template folder
>>   * the home folder
>>   * the folder where the document lives
>>
>> Apparently this does not work, not even one folder is consulted.
>>
>> Is there some sort of a search path available? A policy? It would
>> really be helpful if this subject is discussed and I would love to
>> see a contribution.

The lack of response is probably a confirmation that there is no
mechanism to keep links to various external sources up to date.

Which suggests that this is probably the wrong forum to discuss it.
Either a bug report or another mailing list would seem appropriate,
though I don't know which of
https://www.libreoffice.org/get-help/mailing-lists/ is appropriate. :frowning: