Using relative path in the pdf annotation
Brought to you by:
andreasb123,
auroux
I want to use my xournal annotation on windows and on my android tablet (I use XOJTools). But, there is an isssue. When I open an xoj file on my tablet, a message box say that the original path of the pdf don't exist.
IMHO, it's best to link pdf with a relative path in xoj files. This will keep abastract the file usage.
The problem is that, due to symlinks etc., it is not possible in linux
to determine a canonical (or even reliable) relative path between two
files with given absolute paths that are not in a same directory. (The
case where the path for the pdf is in a subdirectory of the xoj ought to
work but doesn't seem general enough. Otherwise, /path/to/../file.pdf is
not necessarily the same as /path/file.pdf, so /path/to/file.xoj cannot
refer to "../file.pdf" when it wants "/path/file.pdf").
If you need the ability to move things together, just keep the xoj file
and the pdf file in the same directory (or make a symlink to the .pdf in
the directory containing the .xoj). Xournal should silently open the pdf
without complaining if it can be found in the same location as the xoj,
regardless of the absolute path encoded in the .xoj file.
Denis
Ah, I read too quickly, the error occurs when opening in XOJTools.
Basically, you need to make a feature request for XOJTools so that it
looks for the pdf in the same directory as the xoj if the absolute path
can't be found.
Note that, even if I were to put relative paths in .xoj files generated
by xournal (which I don't want to do in general due to the issue I
pointed out), XOJTools and xournal would still both need to be modified
to be able to look for a pdf in a relative path. This is because,
assuming Android has a notion of "current working directory" the way
windows and linux do, the current working directory of XOJTools/xournal
is typically NOT that of the .xoj file -- it's usually your home
directory or the directory containing the xournal executable file. So
trying to open a relative path doesn't do what you think, instead one
needs to manually rebuild an absolute path from the relative path and
the location of the .xoj.
Best,
Denis
I'm already keeping my files in the same directory. But, the program (Xournal on Windows and XOJTools on Android) alert me always.
On 10/02/2014 03:39 PM, nickg0210 wrote:
Ah. Xournal on Windows should not complain. I think this is related to
an issue with directory path separators ('/' in linux vs. '\' in
windows) that I hope was fixed in a recent code update. If so, there's a
bug in 0.4.8 but the next release should fix this. Sorry!
Denis
UPDATE: After re-reading Dennis' remarks it appears he knew the below already.
The problem is that the .pdf.xoj file contains a full path to the corresponding .pdf file. Consider what happens if pdf and xoj are in the same directory, but you then move them together to a different directory. Upon opening the xoj file, xournal will complain that the pdf file cannot be found, and will ask you to find it manually. This happens, as I indicated, even if the files are in the same directory.
For me, it would make sense that an xoj looks for the pdf in the same directory, at least when the absolute path does not lead to the pdf file, for whatever reason,
I'm not asking you to get rid of the absolute path, because it does have some uses, for example if there is some document in a read-only shared location that maybe you would like to make some notes on. But if the absolute path fails, for whatever reason, look for the pdf file where the xoj file is. Maybe issue an alert, ask for an OK, but don't ask us to look up the pdf file manually.
Last edit: reikred 2015-12-20
On 12/20/2015 09:04 AM, reikred wrote:
It shouldn't do that. Can you give a specific example?
In principle, xournal looks first in the specified absolute path; if
that file doesn't exist, then it looks in the directory containing the
xoj file. So if the two are in the same directory, it should work as you
want.
Or are you using the windows version? (there are still some bugs in the
windows version about file paths, especially if there are non-English
characters in the
file names or directory names).
It already does. (at least in the linux version; can't test the windows
version right now, it should do the same but might be broken).
Denis
--
Denis Auroux
UC Berkeley, Department of Mathematics
817 Evans Hall, Berkeley CA 94720-3840, USA
auroux@math.berkeley.edu
Hi Denis,
I created the xoj on windows, and then copied both pdf and xoj to linux, same dir. Then the problem occurs. So, yeah, it may be the case that this is a bug in the windows version, or that the linux version does not know how to derive ./file.pdf from a windows-style path C:\path\to\file.pdf.
UPDATE: The linux2windows copy direction does not appear to cause any problem for xournal on windows deriving/finding .\file.pdf when the linux version wrote (presumably) /path/to/file.pdf
So the problem appears to occur only when making the xoj on windows, then copying to linux.
Last edit: reikred 2015-12-20