Jean, As always, thanks very much for the help and the quick reply! best, LT
On Mon, Aug 5, 2024 at 12:44 PM Jean Abou Samra <j...@abou-samra.fr> wrote: > Le lundi 05 août 2024 à 11:18 -0700, l t a écrit : > > Hi, > > Wondering if it is possible to have lilypond produce a working relative > url > > link on a pdf, where, if I had a file in the same directory as the > outputted > > PDF, I could do something like this: > > \markup { \with-url #"test.mid" } > > or > > \markup { \with-url #"./test.mid" } > > or > > \markup { \with-url #"/test.mid" } > > > > The first one sort of works while still viewing the output within > Frescobaldi > > (although the actual directory it searches was different than what I > expected), > > but none work in the final PDF output. > > > You cannot get a relative link into the PDF output. I just checked > the PDF 1.7 specification and I was surprised to find that the PDF > format supports it (I didn't check whether common PDF readers actually > understand it), but LilyPond has no support for outputting that. > > On the other hand, you can do > > \markup \with-url "file:///home/you/absolute/path/to/file.mid" > > for an absolute path. You can automate adding the absolute path > of the directory that contains the current input file using a simple > variant of the \withRelativeDir command that was added in version 2.25.12: > > \version "2.24.4" > > fileURL = > #(define-scheme-function (file-name) (string?) > (let* ((input-file (car (ly:input-file-line-char-column (*location*)))) > (input-dir (dirname input-file))) > (string-append "file://" input-dir file-name-separator-string > file-name))) > > \markup \with-url \fileURL "mystery-principle.v" "foo" > > > This doesn't give a true relative URL, because it will keep pointing to the > original target even if you move the PDF file around, but might be good > enough > for your use case. > > Best > Jean > >