0

I generate a PDF from CSS and HTML with ITextRenderer. But I dont know how to get more distance between 9. Some text and the border-bottom of the @top-center.

This is my styling:

@page {
  counter-increment: page; 
  margin-top: 80px;
  @top-center { 
    font-size: 9pt;
    content: "Page Header";
    border-bottom: 2px solid black;
    white-space: pre; 
    margin-bottom: 40px;
  }
}

This is how it looks now: a http://oi58.tinypic.com/fmto5d.jpg

This is the result im looking for.

a http://oi57.tinypic.com/sl09oi.jpg

Sanna Widell
  • 147
  • 3
  • 12
  • You might be able to combine the technique here to get the results you want: http://stackoverflow.com/questions/1360869/how-to-use-html-to-print-header-and-footer-on-every-printed-page – Brian Mar 24 '15 at 15:59

1 Answers1

1

You need to increase the margin-top in your @page definition. The margin boxes are constrained by the amount of space given to them by the @page definition.

Edit: What happens if you set the height of the @top-center box?

According to the specification, your code should work. I'm using something similar in my stylesheet, and it works when I render it with Antennahouse:

@page portrait {
    size: Letter;
    margin-top: 28mm;
    margin-bottom: 28mm;
    margin-left: 25.4mm;
    margin-right: 25.4mm;
       @top-left {
        font-size: 9pt;
        font-family: Arial, sans-serif;
        border-bottom: 0.5pt solid black;
        margin-bottom: 10mm;
        vertical-align: bottom;
        padding-bottom: 1mm;
        content: "Header"; 
    } 
}
Hobbes
  • 1,964
  • 3
  • 18
  • 35
  • If I increase the margin-top: 80px; to for example 120px, the only thing that happens is that the border moves down. It still looks like the first picture, just further down with everything. – Sanna Widell Mar 25 '15 at 08:04
  • I got it working, but by addning a padding-top to the @page. Thanks for keeping me on right track! – Sanna Widell Mar 25 '15 at 12:59