Forum How do I...?

Creating pdf from multiple XHTML pages - links not working

roychen
Hello,

I'm using the console version of Prince to create a PDF from multiple XHTML pages, unfortunately, the final version of the links in the PDF file don't seem to work - they still point to web links, and launch my browser when clicked on.

Prince was run on the command line, on these two pages with the following command:

prince -v test1.html test2.html -o test.pdf

Any help would be much appreciated.
roychen
Sorry for the double post, but the forum didn't allow me to post URLs untill I had at least one post (I wanted to include the XHTML files I was using, which had links).

Here are two sample pages that I've been trying to get to work:

test1.html

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE html PUBLIC
     "-//W3C//DTD XHTML 1.1//EN"
     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
<head>
<title>test 1</title>

</head>
<body>
<p>This is test 1.</p>
<p><a href="#testing">This is a link to an anchor.</a></p>
<p><br /></p>
<p><a href="test2.html#top">This is a link to page2.</a></p>
<p><br /></p>
<p><a id="testing">This is the section linked to by the anchor.</a></p>
</body>
</html>


test2.html
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE html PUBLIC
     "-//W3C//DTD XHTML 1.1//EN"
     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
<head>
<title>test 2</title>
</head>

<body>
<p><a id="top" /></p>
<p>This is test 2.</p>
<p><a href="test1.html#testing">This is a link to test1.</a></p>
</body>
</html>
mikeday
Currently there is a limitation where internal links to empty anchor elements don't always work. Placing the anchor id on a top-level block element or an anchor that contains text should solve the problem, and we'll try to fix this issue for a future release of Prince.
roychen
In test1.html, there is a non-empty <a id="testing"> .. </a> element.

Also, in both files there are external links to each other - test1.html links to test2.html and vice versa. Those links don't work as well once ran through Prince.

So, the partial solution now is to do one of the following?

1. Enclose <a id .. > .. </a> elements in perhaps a <div> element,

2. Insert some text, or perhaps a #nbsp; in between <a id ..> and </a>

Thanks for your help.
mikeday
Actually the first option was to put the id attribute directly on a <h1> or <div> element, which is perfectly legal in HTML 4, it doesn't need to be on a standalone <a> element. Adding some text within the empty anchor is another option that also works.
roychen
Hello, I've tried all the solutions you propose, but none of them work still. Perhaps I'm missing something really obvious :(

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE html PUBLIC
     "-//W3C//DTD XHTML 1.1//EN"
     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
<head>
<title>test 1</title>

</head>
<body>
<p>This is test 1.</p>
<p><a href="test1.html#testing">This is a link to a div id.</a></p>
<p><a href="test1.html#testing2">This is a link to a h1 id.</a></p>
<p><a href="test1.html#testing3">This is a link to an a id.</a></p>
<p><br /></p>
<p><br /></p>
<p><br /></p>
<div id="testing">Using a div id</div>
<p><br /></p>
<p><br /></p>
<p><br /></p>
<h1 id="testing2">Using a h1 id</h1>
<p><br /></p>
<p><br /></p>
<p><br /></p>
<p><a id="testing3">Using an anchor</a></p>
</body>
</html>


As you can see, I've tried linking to <div>, <h1> and <a> elements. None of them work in the PDF, they still launch my browser to open the original HTML file.

I'm running the latest version of Prince, 6.0 rev 4, through the command line, by "prince -v test1.html -o test.pdf".

I hope it's just me that's missing something dreadfully obvious here..
mikeday
That is strange. Which program are you using to view the generated PDF file? Could you email the PDF file to me? (mikeday@yeslogic.com)
roychen
I've tried opening it in both Adobe Acrobat Reader 8.1 and Acrobat Professional 8.0, doesn't work in both.

I'll email you the pdf and HTML now, thanks!
mikeday
It seems that this is a bug in Prince, but only when running on Windows. We'll fix it for the next maintenance release, due for release shortly. Thanks for reporting the issue! :)
roychen
Thanks, good to know that I wasn't doing something wrong.

Would you have any idea when the next version is likely to be released?
mikeday
Hopefully in the next few days, we're just building the packages now.
mikeday
The new maintenance release is out today, and should fix the issue affecting internal links on Windows.
David J Prokopetz
I don't think this one is quite fixed. Consider the following example:

http://www.penguinking.com/files/xml/example/

Sorry for the length - this test is derived from a work in progress.

In brief, example1.xml and example2.xml both use the same stylesheet (example.css). They both use XInclude to pull in other XML files; in both cases, the XML files they're pulling in are identical. The only difference is that example1.xml pulls the files in from the same folder in which it resides, while example2.xml pulls them in from a subfolder.

You'll find the relevant bits around line 164 of example.css, and line 11 of chapter1.xml.

If you convert them both using Prince 6.0 rev 5 for Windows, the cross-reference appears to work in example1.xml, but not in example2.xml.
mikeday
This is a different issue, specific to XInclude. Let's discuss it back in the other thread, as this one is already getting rather long.