While generating a PDF from multiple XHTML files (a website) I tried to keep the links from one page to the other intact. The links are not anchor links on one page but pretty basic hrefs. E.g. http://localhost/a/ has a link to http://localhost/b/ like:
Most links are "path-absolute" so starting with "/" but some may also be relative like "../c/". The links are all referring to a directory only as the actual "file" is not always index.html but may also be generated or dynamic like index.jsp or similar.
After generating the PDF directly from feeding all URLs into Prince using a simple Python script in which the end result is something like:
The resulting PDF has then all links as URL links in it so e.g. the link on "/a/" is a link to "http://localhost://b/". Effectively the PDF links are unusable and for now I disabled them using prince-link: none in the stylesheet.
But I figured there should be a solution to let prince rewrite all links with something like prince-link: url(target-url) but I don't know how to use it. Is there a way to find out the target-url of the page where e.g. "/b/ is generated to?
The only workaround I could think of is to rewrite all links to something like a href="#b" and give page "b" an body/@id but I hope this should be easier with a few lines in the CSS?
Thanks for any hint.
// file a/index.html
a href="/b/"
Most links are "path-absolute" so starting with "/" but some may also be relative like "../c/". The links are all referring to a directory only as the actual "file" is not always index.html but may also be generated or dynamic like index.jsp or similar.
After generating the PDF directly from feeding all URLs into Prince using a simple Python script in which the end result is something like:
subprocess.call(['prince', 'http://localhost://a/', 'http://localhost://b/', 'test.pdf'])
The resulting PDF has then all links as URL links in it so e.g. the link on "/a/" is a link to "http://localhost://b/". Effectively the PDF links are unusable and for now I disabled them using prince-link: none in the stylesheet.
But I figured there should be a solution to let prince rewrite all links with something like prince-link: url(target-url) but I don't know how to use it. Is there a way to find out the target-url of the page where e.g. "/b/ is generated to?
The only workaround I could think of is to rewrite all links to something like a href="#b" and give page "b" an body/@id but I hope this should be easier with a few lines in the CSS?
Thanks for any hint.