Forum Bugs

Can't seem to get links to work

abhik
Hey all,

I'm running prince 10 and using the following HTML:

<body>
  <div class='page-break'>
    <a href='#hello'>to Hello</a>
    <a href='#again'>to Again</a>
  </div>
  <div class='page-break'>
    <h1 id='hello'>Hello</h1>
  </div>
  <div class='page-break'>
    <h1 id='again'>Again</h1>
  </div>
</body>


w/CSS:

@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro:200,300,400,600,700,900,200italic,300italic,400italic,600italic,700italic,900italic);
body {
  font-family: "Source Sans Pro", sans-serif;
  font-size: 12pt; }

img {
  content: attr("src", url); }

br {
  content: '\A';
  white-space: pre;
  background: none; }

h1 {
  display: block;
  text-align: center;
  font-size: 24pt;
  font-weight: 900; }

a {
  display: block; }

.page-break {
  display: block;
  page-break-after: always; }

/*# sourceMappingURL=test.css.map */


and running:

prince --debug -s test.css test.xml -o test.pdf


The generated PDF does not have PDF links from the anchors to the headings. Any idea what I'm doing wrong?
  1. test.pdf8.3 kB
    The generated PDF

Edited by abhik

abhik
Ah figured it out via this link: https://github.com/rachelandrew/css-for-print

Needed to create a proper html file:

<!DOCTYPE html>
<html lang='en-US' dir='ltr'>
  <head>
    <meta charset='utf-8' />
  </head>
  <body>
    <div class='page-break'>
      <a class='xref' href='#hello'>to Hello</a>
      <a class='xref' href='#again'>to Again</a>
    </div>
    <div class='page-break'>
      <h1 id='hello'>Hello</h1>
    </div>
    <div class='page-break'>
      <h1 id='again'>Again</h1>
    </div>
  </body>
</html>


A link to a sample project in Github would be helpful!
mikeday
Right, for XML documents the HTML elements need to be in the HTML namespace, whereas for HTML documents they are placed in the namespace automatically.

I would probably recommend using HTML for convenience, unless you need to mix in other XML elements or use other XML tools.