Meryam Sahin (talk | contribs) No edit summary |
Meryam Sahin (talk | contribs) m (username removed) (log details removed) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 22: | Line 22: | ||
# Open the template in edit mode. | # Open the template in edit mode. | ||
# Switch to the '''Document preface''' tab. | # Switch to the '''Document preface''' tab. | ||
# Replace the existing content with the following markup: | # Replace the existing content with the following markup: <syntaxhighlight lang="html"> | ||
<syntaxhighlight lang="html"> | |||
<div class="pdfcreator-intro"> | <div class="pdfcreator-intro"> | ||
<div class="pdfcreator-intro-logo">{{{logo}}}</div> | <div class="pdfcreator-intro-logo">{{{logo}}}</div> | ||
| Line 39: | Line 38: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
# Switch to the '''Styles''' tab. | # Switch to the '''Styles''' tab. | ||
# Append the following CSS rules to the existing styles: | # Append the following CSS rules to the existing styles: <syntaxhighlight lang="css"> | ||
<syntaxhighlight lang="css"> | |||
/*Custom cover sheet styles*/ | /*Custom cover sheet styles*/ | ||
Latest revision as of 09:42, 25 August 2026
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.
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
Copy an existing template
To create a PDF template with a custom cover page:
- Go to
Special:PDF templates. - Copy the StandardBookPDF template.
- Enter a name for the new template.
- Click Copy.
Customize the template
After copying the template, open its definition on MediaWiki:PDFCreator.
- Select the new PDF template.
- Open the template in edit mode.
- Switch to the Document preface tab.
- 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>
- Switch to the Styles tab.
- 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; }
- Select Save.
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.
Cover image behavior
For a book PDF export, PDFCreator checks the following locations for a cover image:
- The bookshelf-image defined in the book metadata.
- 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.
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
Remove the logo
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.
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;
}