I am pretty new to pressbooks, so this is probably an easy question for you guys
I use a self-hosted version of pressbooks and use the McLuhan Theme right now. I also use mPDF for the pdf export. I want to style the head of a chapter with adding the page number and giving it a blue background.
So I navigated to Design -> Custom Styles -> PDF and added this lines:
Unfortunately after exporting the book nothing happend to the styling, neither do I have the page numbers in the head of the page nor is anything blue.
Hi @phellwig, as far as I know, CSS added via Custom Styles is not used by the mPDF export module (which is a community project maintained by @brad at BCcampus rather than the Pressbooks team); the PDF styles youâve added to Custom Styles would be applied to PDF exports using the Prince PDF or DocRaptor PDF export modules that are included in Pressbooks core. @brad may have some insights into how you could add custom styles to your mPDF exports.
Hi @ned, thanks for this very useful information. I didnât knew of these ârestrictionsâ. I will give DocRaptor a try and wait if @brad can tell me more about mPDF.
mPDF does indeed support custom styles, though there are some limitations with what CSS is supported - mPDF inherits kneadCss() from prince/class-pdf.php which pulls in Custom Styles
The issue here is that the CSS thatâs being declared creates undesirable behaviour in mPDF. @page when declared creates an unwanted page break each time itâs called. Unfortunately, if I donât strip it out it creates really long documents with many blank pages.