For the header, we want to have our logo in the top left corner and the title of the document in the center. To get started, we put our logo in the src/main/asciidoc/theme
folder. In our example, it is called pegus-digital-logo.png
. Add this to the pegus-digital-theme.yml
file:
header:
height: $base_line_height_length * 3
recto:
left:
content: image:pegus-digital-logo.png[width=120]
center:
content: '{document-title}'
What we have in the configuration is:
-
height
: set the height of the header. By default, the header is limited in height and not enough to display the logo.
-
image
declaration in the left
/content
section. We can tweak the size of the image with the width
declaration on the image.
-
{document-title}
in the center
of the header
The resulting PDF looks like this:
So we have the content in the header we want, but the styling could be a bit better. We will add a small line beneath the header to offset it from the main content and adjust the page margins so the content is not so close to the header as it is now:
page:
margin: [0.7in, 0.67in, 0.67in, 0.67in]
header:
height: $base_line_height_length * 3.5
border_color: dddddd
border_width: 0.25
recto:
left:
content: image:pegus-digital-logo.png[width=120]
center:
content: '{document-title}'
We are using inches for the margins because the default stylesheet also uses inches, but there are different measurement units that you can use. The resulting PDF:
Again, we only have this on the recto pages since we defined it like that. If we want the verso pages to be exactly the same, we can refer to what we have on the recto side in the verso configuration:
header:
height: $base_line_height_length * 3.5
border_color: dddddd
border_width: 0.25
recto:
left:
content: image:pegus-digital-logo.png[width=120]
center:
content: '{document-title}'
verso:
left:
content: $header_recto_left_content
center:
content: $header_recto_center_content
Any key in the YAML configuration can be referenced with $path_to_the_key
. In our example, it allows us to define the content for the header in 1 place.
With this, we have our header on the verso side as well: