Revision as of 08:33, 25 August 2026 by Meryam Sahin (talk | contribs) (Created page with "{{DISPLAYTITLE:Custom cover sheets}} '''PDFCreator''' templates support custom cover pages with additional elements such as a logo, title, subtitle, and contact information. Advanced cover page customizations are made directly in the template definition on the <code>MediaWiki:PDFCreator</code> page. {{Textbox|boxtype=important|header=Important|text=After customizing a cover page directly on the ''MediaWiki:PDFCreator'' page, maintain the template there. Changes made to t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

PDFCreator templates support custom cover pages with additional elements such as a logo, title, subtitle, and contact information. Advanced cover page customizations are made directly in the template definition on the MediaWiki:PDFCreator page.

ImportantAfter customizing a cover page directly on the MediaWiki:PDFCreator page, maintain the template there. Changes made to the same template on Special:PDF templates can overwrite the customizations.

Create a custom cover page

Create a custom cover page by copying an existing PDF template and modifying its Document preface and Styles sections.
The following example creates a cover page with:

  • the wiki logo
  • a background image
  • a book title and subtitle
  • contact information
Cover page with logo, background image, title, subtitle and contact information
Custom cover page

Copy an existing template

To create a PDF template with a custom cover page:

  1. Go to Special:PDF templates.
  2. Copy the StandardBookPDF template.
  3. Enter a name for the new template.
  4. Click Copy.
Special page "PDF templates" with StandardBookPDF selected for copying
Copy a template

Customize the template

After copying the template, open its definition on MediaWiki:PDFCreator.

  1. Select the new PDF template.
  2. Open the template in edit mode.
  3. Switch to the Document preface tab.
  4. Replace the existing content with the following markup:
<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>Address line 1</div>
        <div>Address line 2</div>
        <div>City</div>
        <div>Other contact information</div>
    </div>
</div>
  1. Switch to the Styles tab.
  2. Append the following CSS rules to the existing 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;
}
  1. Select Save.
Code view of the template example "StandardHandbookPDF"
PDFCreator template page

Apply the template

After saving the template, export a book with the new template. Apply the template in one of the following ways:

  • Add the template to the book metadata.
  • Select the template in the PDF export dialog when exporting a book.
Metadata dialog with the custom template selected
Book metadata
Export dialog with the custom template selected in Book mode
PDF export dialog for a book

Cover image behavior

For a book PDF export, PDFCreator checks the following locations for a cover image:

  1. The bookshelf-image defined in the book metadata.
  2. The default cover image defined in the PDFCreator settings of the Config manager.

If neither location provides a cover image, the template can use a background color instead.
The template uses a cover image when the Document preface contains the pdfcreator-intro wrapper class:

<div class="pdfcreator-intro">
...
</div>

For example, the following rule provides a blue background when no cover image is available:

.pdfcreator-type-intro {
    background-color: #3E5389; /*only visible if no cover-image is available */
    ...
}

Cover page parameters

The example uses book-title and book-subtitle to display title information from the book metadata.
If the book does not have a book-title, the template does not print a title on the cover page when it uses the book-title parameter.

Book metadata dialog with book title and subtitle settings
Book title and subtitle settings

A template that uses book-title is intended for book exports with a book title defined in the book metadata.
To use the template for page exports or for books without a defined book-title, create a separate template. In the Document preface tab, replace {{{book-title}}} with {{{title}}} or Extension/PDFCreator/Custom cover sheets.

Cover page variations

To remove the wiki logo from the cover page, remove or comment out the line that inserts the logo parameter:

<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>Address line 1</div>
        <div>Address line 2</div>
        <div>City</div>
        <div>Other contact information</div>
    </div>
</div>

Center the cover content

This variation centers the logo, book title, and book subtitle vertically on the cover page. The background image retains its full height.

Cover page with background image and vertically centered logo, book title and book subtitle
Centered cover content

Open MediaWiki:PDFCreator and select the PDF template. Add the following content to the appropriate tabs.

Cover page layout

Replace the content of the Document preface tab with:

<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 class="pdfcreator-intro-text">
            <div>Address line 1</div>
            <div>Address line 2</div>
            <div>City</div>
            <div>Other contact information</div>
        </div>-->
    </div>
</div>

The example includes an additional area for introductory text. The area is commented out. Remove the comment markers to display the text.

CSS rules

Append the following CSS rules to the standard content of the Styles tab:

/*Custom cover sheet styles*/

.pdfcreator-type-intro {
    background-color: #3E5389; /*only visible if no cover-image is available */
    background-position:center 0; 
    background-size:100% auto;
    max-height:29.7cm;
    overflow:hidden; 
}

.pdfcreator-intro-logo {
    position: absolute;
    padding: 0.3cm 1.75cm;
    width: 21cm;
    top:12.5cm;
    max-height: 2.6cm;
    overflow: hidden;
    background-color: #ffffff;
}

.pdfcreator-intro-title {
    top: 14cm;
    left: 0cm;
    padding:1cm 1.75cm;
    width:21cm;
    background:#ffffff;
    opacity:0.3;
    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 {
    padding-top:2cm;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3em;
    width: 17.5cm;
}