Skip to content

Instantly share code, notes, and snippets.

@ssddanbrown
Last active May 17, 2024 08:49
Show Gist options
  • Select an option

  • Save ssddanbrown/bcc9d2e73ec8144a7f4807fd10ddc863 to your computer and use it in GitHub Desktop.

Select an option

Save ssddanbrown/bcc9d2e73ec8144a7f4807fd10ddc863 to your computer and use it in GitHub Desktop.
BookStack PDF Export header & footer
@if ($format === 'pdf')
<style media="print">
.print-header-footer {
position: fixed;
width: 100%;
}
.print-footer {
position: fixed;
bottom: -40px;
width: 100%;
}
.print-header-footer-inner {
max-width: 840px;
margin: 0 auto;
color: #666;
}
.print-page-number:after {
content: "Page "counter(page);
}
@page {
margin-top: 100px;
margin-bottom: 80px;
}
</style>
<div class="print-header-footer" style="top: -60px;">
<div class="print-header-footer-inner">
<div style="float: left; opacity: 0.6;">
<img height="42" src="data:image/png;base64,{{ base64_encode(file_get_contents(theme_path('logo.png'))) }}">
</div>
<div style="float: right;">
<div class="print-page-number"></div>
</div>
</div>
<div style="clear:both;"></div>
</div>
<div class="print-header-footer" style="bottom: -40px;">
<div class="print-header-footer-inner">
<div style="float: left;">
Copyright 2022
</div>
<div style="float: right;">
<div class="print-page-number"></div>
</div>
</div>
<div style="clear:both;"></div>
</div>
@endif

This gist is to provide the resultant code of a BookStack video guide. The code existed at themes/custom/layouts/parts/export-body-start.blade.php relative to the BookStack installation folder.

This uses the visual theme system so you need to have an theme folder active in your instance. The code assumes you have a logo.png file in the root of your custom theme folder.

@ssddanbrown
Copy link
Copy Markdown
Author

@Limerick-gh is this for page exports? If so then {{ $page->book->name ?? '' }} may work. Check it doesn't break book/chapter exports though.

@Limerick-gh
Copy link
Copy Markdown

Awesome, this works as expected! Thank you so much for your prompt reply! Much appreciated!
And yes this was for page export.
Will pay attention on book/chapter exports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment