Manual:Extension/PDFCreator/Custom cover sheets: Difference between revisions

No edit summary
No edit summary
Tag: 2017 source edit
 
Line 137: Line 137:
</syntaxhighlight>
</syntaxhighlight>


== More variations ==
<!-- == More variations ==
<gallery widths="280" heights="350">
<gallery widths="280" heights="350">
File:PDFCreator Custom cover sheet var2.png|Variation 2|link=Manual:Extension/PDFCreator/Custom cover sheets/var2
File:PDFCreator Custom cover sheet var2.png|Variation 2|link=Manual:Extension/PDFCreator/Custom cover sheets/var2
</gallery>
</gallery> -->
*

Latest 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

Cover page with logo, background image, title, subtitle and contact information
Custom cover page
Important!

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:

  1. Go to the page Special:PDF_templates.
  2. Copy the template StandardBookPDF.
    special page "PDF templates" with selected standard book pdf to be copied
    Copy a template
  3. Enter a name for the new template.
  4. 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:

  1. Select your PDF template. This brings up the PDFCreator page for your template.
  2. Open the page in edit mode.
  3. Switch to the tab Document preface.
  4. 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>
    
  5. Switch to the tab Styles.
  6. 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;
    }
    
    Code view of the template example "StandardHandbookPDF"
    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:

Metadata dialog with new template selected
Book metadata

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

export dialog with selected template in Book export mode
Export dialog on a wiki page that is part of a book


Cover image considerations

The PDFCreator is looking for a cover image in the following places:

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:

Metadata dialog of the bookshelf
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 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

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>




PDF exclude - start

To submit feedback about this documentation, visit our community forum.

PDF exclude - end