No edit summary Tag: 2017 source edit |
No edit summary |
||
| Line 1: | Line 1: | ||
To create a custom cover sheet with more than just the title and a background, you need to add some custom formatting to a PDF template. | To create a custom cover sheet with more than just the title and a background, you need to add some custom formatting to a PDF template. For this purpose, making the changes from page Special:PDF templates is usually not sufficient. In that case, you change the necessary formatting directly in the definition for your PDF template. | ||
Simply follow the example below to get the following layout variation. | |||
== Example layout == | == Example layout == | ||
| Line 112: | Line 114: | ||
[[File:PDFCreator book title and subtitle.png|alt=Metadata dialog of the bookshelf|center|thumb|550x550px|Book title and subtitle settings]] | [[File:PDFCreator book title and subtitle.png|alt=Metadata dialog of the bookshelf|center|thumb|550x550px|Book title and subtitle settings]] | ||
If you want to be flexible and use the PDF template also in Page export mode or for books that do not have a book-title defined, you need to create a separate PDF-template where you define <code><nowiki>{{{title}}}</nowiki></code> or <code><nowiki>{{PAGENAME}}</nowiki></code> instead of <code><nowiki>{{{book-title}}}</nowiki></code> in the ''Document preface'' tab, since there currently is no fallback-mechanism. | If you want to be flexible and use the PDF template also in Page export mode or for books that do not have a book-title defined, you need to create a separate copy of your PDF-template where you define <code><nowiki>{{{title}}}</nowiki></code> or <code><nowiki>{{PAGENAME}}</nowiki></code> instead of <code><nowiki>{{{book-title}}}</nowiki></code> in the ''Document preface'' tab, since there currently is no fallback-mechanism. | ||
== Variations == | == Variations == | ||
| Line 134: | Line 136: | ||
</div> | </div> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== More variations == | == More variations == | ||
Revision as of 13:37, 22 October 2025
To create a custom cover sheet with more than just the title and a background, you need to add some custom formatting to a PDF template. For this purpose, making the changes from page Special:PDF templates is usually not sufficient. In that case, you change the necessary formatting directly in the definition for your PDF template.
Simply follow the example below to get the following layout variation.
Example layout

When you customize the cover sheet as described, you need to maintain it exclusively via the page MediaWiki:PDFCreator.
Changing the cover page from the page Special:PDF templates will overwrite your changes.
Copying an existing template
To create a PDF template with a custom cover sheet, we first copy an existing template. For the example we copy the StandardBookPDF template to a new template called StandardHandbookPDF.
To create a new PDF template from an existing one:
- Go to the page Special:PDF_templates.
- Copy the template StandardBookPDF.

Copy a template - Enter a name for the new template.
- Click Copy.
Customizing the template
From the page Special:PDF_templates click on the template name for your new template. StandardHandbookPDF. This brings up the page MediaWiki:PDFCreator.
To customize the cover sheet:
- Select your PDF template. This brings up the PDFCreator page for your template.
- Open the page in edit mode.
- Switch to the tab Document preface.
- Replace the default content with the following content:
<div class="pdfcreator-intro"> <div class="pdfcreator-intro-logo">{{{logo}}}</div> <div class="pdfcreator-intro-title">{{{book-title}}} <div class="pdfcreator-intro-subtitle">{{{book-subtitle}}}</div> </div> <div class="pdfcreator-intro-text"> <div>Adress line 1</div> <div>Adress line 2</div> <div>City</div> <div>Other contact info</div> </div> </div>
- Switch to the tab Styles.
- Append the following CSS rules to the end of the existing CSS styles.
/*Custom cover sheet styles*/ .pdfcreator-type-intro { background-color: #3E5389; /*only visible if no cover-image is available */ background-position:center 1.5cm; max-height:14cm; overflow:hidden; } .pdfcreator-intro-logo { position: absolute; padding: 0.3cm 1.75cm; width: 21cm; max-height: 2.6cm; overflow: hidden; background-color: #ffffff; } .pdfcreator-intro-title { top: 15.5cm; font-size: 32px; color: #3E5389; font-weight: 800; line-height: 1.5em; } .pdfcreator-intro-subtitle { display:block; font-size: 18px; color: #3E5389; font-weight: 600; line-height: 1.3em; margin-top:0.5cm; } .pdfcreator-intro-text { position:absolute; font-size: 14px; font-weight: 600; line-height: 1.3em; top:25.5cm; left:1.75cm; width: 17.5cm; }

PDFCreator template page
Print a book with this template. There are two ways of applying the new template:
Adding it to the metadata of a book:

Selecting it from the Export dialog of a book page in Book print mode:

Cover image considerations
The PDFCreator is looking for a cover image in the following places:
- the
bookshelf-imagein the metadata of the book. If none exists: - the
default cover imageset in the Config manager PDFCreator settings. If none exists
The cover image is only applied if the Document preface uses the wrapper class "pdf-creator-info":
<div class="pdfcreator-intro">
...
</div>
If no cover image exists, the template we just created shows a blue background color instead:
.pdfcreator-type-intro {
background-color: #3E5389; /*only visible if no cover-image is available */
...
}
Title or book-title?
The template is created to print PDFs from books. It assumes that each book has a book-title set in the book's meta data. If no book-title exists, no title is printed on the cover page:

If you want to be flexible and use the PDF template also in Page export mode or for books that do not have a book-title defined, you need to create a separate copy of your PDF-template where you define {{{title}}} or {{PAGENAME}} instead of {{{book-title}}} in the Document preface tab, since there currently is no fallback-mechanism.
Variations
Removing the logo
If you do not want to show the wiki's logo at the top of the cover sheet, you can simply comment out the line that inserts the logo:
<div class="pdfcreator-intro">
<!--<div class="pdfcreator-intro-logo">{{{logo}}}</div>-->
<div class="pdfcreator-intro-title">{{{book-title}}}
<div class="pdfcreator-intro-subtitle">{{{book-subtitle}}}</div>
</div>
<div class="pdfcreator-intro-text">
<div>Adress line 1</div>
<div>Adress line 2</div>
<div>City</div>
<div>Other contact info</div>
</div>
</div>
More variations
-
Variation 2