Manual:Extension/PDFCreator: Difference between revisions

Redaktion (talk | contribs)
No edit summary
Redaktion (talk | contribs)
No edit summary
Tag: 2017 source edit
Line 17: Line 17:
[[File:StandardPDF template.png|alt=PDF page with default header and footer content an a Table of Contents|center|thumb|424x424px|Standard PDF layout]]
[[File:StandardPDF template.png|alt=PDF page with default header and footer content an a Table of Contents|center|thumb|424x424px|Standard PDF layout]]


==Editing the PDF templates==
==Editing existing PDF templates==
You can edit the existing standard PDF or Book PDF template directly in the wiki. In addition to the existing templates, you can add your own custom templates. When printing a page or book, users can choose between these templates.
You can edit the existing standard PDF or Book PDF template directly in the wiki. In addition to the existing templates, you can add your own custom templates. When printing a page or book, users can choose between these templates.


In addition, each book can be associated with a particular template when it is printed from the Books page.
In addition, each book can be associated with a particular template when it is printed from the Books page.
'''To edit an existing template:'''
# '''Open''' the page ''MediaWiki:PDFCreator.''
# '''Select''' the template you want to edit. As an example, we select the ''StandardPDF'' template.
# '''Open''' the page in edit mode. This shows you the current layout of each PDF element. You can click on any tab to switch between the template elements you want to customize.
# Click the ''Help-''button to see the available parameters you can add to each PDF layout section.  The parameters with prefix "book"  are metadata that are defined in books and will not have any effect on pages that are not associated with a book.


=== Template elements ===
=== Template elements ===
Line 49: Line 57:
|-
|-
!Footer
!Footer
|The page footer of each PDF page. The basic structure is:
|The page footer of each PDF page. The basic structure is:<syntaxhighlight lang="html">
<div class="pdfcreator-runningheaderfix">
<table>
<tr>
<td>
<div class="pdfcreator-runningheader-logo">
{{{logo}}}
</div>
</td>
<td>
<h1 class="title">{{{title}}}</h1>
</td>
</tr>
</table>
</div>
</syntaxhighlight>
|-
|-
!Document preface
!Document preface
|The cover page. It is meant for the book export, but can also be used for a page export. The basic structure for a book cover page is:<syntaxhighlight lang="text">
|The cover page. It is meant for the book export, but can also be used for a page export. The basic structure for a book cover page is:<syntaxhighlight lang="html">
<div class="pdfcreator-intro">
<div class="pdfcreator-intro">
<div class="pdfcreator-intro-title">{{{title}}}</div>
<div class="pdfcreator-intro-title">{{{title}}}</div>
Line 68: Line 91:
|}
|}


=== Existing templates ===
== Adding a new template ==
To edit an existing template:
Each PDF template is a subpage of the page MediaWiki:PDFCreator.
# '''Open''' the page ''MediaWiki:PDFCreator.''
 
# '''Select''' the template you want to edit. As an example, we select the ''StandardPDF'' template.
To create a new PDF template:
# '''Open''' the page in edit mode. This shows you the current layout of each PDF element. You can click on any tab to switch between the PDF elements you want to customize.
 
# Click the ''Help-''button to see the available parameters you can add to each PDF layout section.  The parameters with prefix "book"  are metadata that are defined in books and will not have any effect on pages that are not associated with a book.
# '''Go''' to the page MediaWiki:PDFCreator.
# '''Add''' a subpage (for example from the menu of the wiki'''New''-button).
# '''Enter''' the html-layout and parameters for each template element.
# '''Save''' the new template.
 
It is now available as a selection when exporting pages to PDF.


== Customization examples for the header and footer ==
== Customization examples for the header and footer ==
Switch to edit mode on the template pages to make your changes.


=== Use a custom logo ===
=== Custom logo ===
By default, the parameter <code><nowiki>{{{logo}}}</nowiki></code> displays the wiki logo in the PDF. You can also directly reference an uploaded image as your logo for your different PDF templates. Here, we add a custom logo to the header of a template:
By default, the parameter <code><nowiki>{{{logo}}}</nowiki></code> displays the wiki logo in the PDF. You can also directly reference an uploaded image as your logo for your different PDF templates. Here, we add a custom logo to the header of a template:


Line 98: Line 125:
</syntaxhighlight>
</syntaxhighlight>


=== Print a semantic property ===
=== Semantic property ===
It is also possible to print a semantic property in the footer. The following example prints the value of the property "Classification" of a page  in the PDF footer.<syntaxhighlight lang="text">
It is also possible to print a semantic property in the footer. The following example prints the value of the property "Classification" of a page  in the PDF footer.<syntaxhighlight lang="text">
<div class="pdfcreator-runningfooterfix">
<div class="pdfcreator-runningfooterfix">
Line 105: Line 132:
</syntaxhighlight>
</syntaxhighlight>


=== Add a background color to the header and footer ===
=== Background color for header and footer ===


In the Styles tab, add:<syntaxhighlight lang="css">
In the ''Styles'' tab, add:<syntaxhighlight lang="css">
/* add a background color to the header and footer */
/* add a background color to the header and footer */
.pdfcreator-runningheaderfix, .pdfcreator-runningfooterfix {
.pdfcreator-runningheaderfix, .pdfcreator-runningfooterfix {
Line 115: Line 142:


=== Remove the underline from the header and footer ===
=== Remove the underline from the header and footer ===
In the Styles tab, add:<syntaxhighlight lang="css">
In the ''Styles'' tab, add:<syntaxhighlight lang="css">
/* remove the border from the header */
/* remove the border from the header */
.pdfcreator-runningheaderfix > table {
.pdfcreator-runningheaderfix > table {
Line 128: Line 155:


== Customization examples for the cover page ==
== Customization examples for the cover page ==
The cover page can be changed from the ''Document preface''-tab.  It is usually only used for the book template. The default elements are:
The cover page can be changed from the ''Document preface''-tab.  It is mainly used forbook templates. The default elements are:


* Book title
* Title
* Logo
* Logo
* Cover image: If a cover image is explicitely set by the user, the cover image is printed automatically. It does not have a parameter.  The generated preview images on the bookshelf are '''not''' printed on the PDF cover.
* Bookshelf image: If a cover image is explicitely set by the user, the cover image is printed automatically. It does not have a parameter.  The automatically generated preview images on the bookshelf are '''not''' printed on the PDF cover.
 
=== Adding a white background to the logo ===


====Using background colors====
====Using background colors====
Line 185: Line 214:
</div>
</div>
</syntaxhighlight>
</syntaxhighlight>
== Migrating existing BlueSpice cloud PDF templates ==
In BlueSpice 4 cloud, there was one standard template that could be customized in the wiki. Its elements were defined in the following pages:
* MediaWiki:UniversalExport/PDF/Default/Header.html
* MediaWiki:UniversalExport/PDF/Default/Footer.html
* MediaWiki: UniversalExport/PDF/Default/Cover page.html
* MediaWiki: UniversalExport/PDF/Default/Styles.less
These pages have been replaced in BlueSpice 5. You need to transfer the content of these pages to one or more PDF layouts.
'''To move the content:'''
#'''Open''' the page ''MediaWiki:PDFCreator.''
# '''Select''' the template you want to edit.
# '''Add''' the content of your templates to the according tabs:
## Header.html -> Header tab
## Footer.html -> Footer tab
## Cover page -> Document prefixtab
## Styles.less -> Styles tab
# '''Correct''' the style-references  for the header and footer wrappers:<!-- TABLE HERE -->
The following parameters no longer exist and need to be replaced with MediaWiki magic words:
{| class="wikitable"
|+
!Parameter
!Description
!Replace with
|-
|url
|URL of the wiki page
|<nowiki>{{fullurl:{{FULLPAGENAME}}}}</nowiki>
|-
|user
|username of user who printed the page
|
|-
|exportdate
|date of PDF-creation
|<nowiki>{{CURRENTMONTH}}/{{CURRENTDATE}}/{{CURRENTYEAR}}</nowiki>
|-
|exporttime
|time of PDF-creation
|<nowiki>{{CURRENTTIME}}</nowiki>
|-
|
|
|
|}
== Configuration ==
== Configuration ==
{{#dpl:title=BlueSpiceConfigManager|include=#PDFCreator}}
{{#dpl:title=BlueSpiceConfigManager|include=#PDFCreator}}
[[de:Handbuch:Erweiterung/BlueSpiceUniversalExport/PDF_Vorlagen_erstellen]]
[[de:Handbuch:Erweiterung/BlueSpiceUniversalExport/PDF_Vorlagen_erstellen]]

Revision as of 16:40, 18 February 2025


Exporting a page or a book

To print a page to PDF, click on the page-icon in the page tools. This opens the export dialog field.

Select the export settings.

  • Mode:
    • Page: Prints the page.
    • Page with subpages: Prints the page and all its subpages. This option is only shown if the page has subpages.
    • Page with linked pages: Prints the page and the pages that are linked directly from this page.
  • Template:
    • StandardPDF: This prints the page or pages without a cover sheet (unless the template has been edited).
    • StandardBookPDF: This adds a cover sheet to the PDF (unless the template has been edited).

By default, the template StandardPDF shows the wiki's logo (from the skin settings page). If there are no custom settings, the default BlueSpice logo is used.

PDF page with default header and footer content an a Table of Contents
Standard PDF layout

Editing existing PDF templates

You can edit the existing standard PDF or Book PDF template directly in the wiki. In addition to the existing templates, you can add your own custom templates. When printing a page or book, users can choose between these templates.

In addition, each book can be associated with a particular template when it is printed from the Books page.


To edit an existing template:

  1. Open the page MediaWiki:PDFCreator.
  2. Select the template you want to edit. As an example, we select the StandardPDF template.
  3. Open the page in edit mode. This shows you the current layout of each PDF element. You can click on any tab to switch between the template elements you want to customize.
  4. Click the Help-button to see the available parameters you can add to each PDF layout section. The parameters with prefix "book" are metadata that are defined in books and will not have any effect on pages that are not associated with a book.

Template elements

Each template consists of the same elements:

Header The page header of each PDF page. The basic structure is:
<div class="pdfcreator-runningheaderfix">
	<table>
		<tr>
			<td>
				<div class="pdfcreator-runningheader-logo">
					{{{logo}}}
				</div>
			</td>
			<td>
				<h1 class="title">{{{title}}}</h1>
			</td>
		</tr>
	</table>
</div>
Content The content layout. The basic structure is:
{{{content}}}
Footer The page footer of each PDF page. The basic structure is:
<div class="pdfcreator-runningheaderfix">
	<table>
		<tr>
			<td>
				<div class="pdfcreator-runningheader-logo">
					{{{logo}}}
				</div>
			</td>
			<td>
				<h1 class="title">{{{title}}}</h1>
			</td>
		</tr>
	</table>
</div>
Document preface The cover page. It is meant for the book export, but can also be used for a page export. The basic structure for a book cover page is:
<div class="pdfcreator-intro">
	<div class="pdfcreator-intro-title">{{{title}}}</div>
</div>
Document appendix The last page of the PDF export. It has no predefined basic structure.
Styles Style declarations for the CSS classes that are used in any of the template elements. There are no predefined styles.
Description

Adding a new template

Each PDF template is a subpage of the page MediaWiki:PDFCreator.

To create a new PDF template:

  1. Go to the page MediaWiki:PDFCreator.
  2. Add a subpage (for example from the menu of the wiki's New-button).
  3. Enter the html-layout and parameters for each template element.
  4. Save the new template.

It is now available as a selection when exporting pages to PDF.

Customization examples for the header and footer

By default, the parameter {{{logo}}} displays the wiki logo in the PDF. You can also directly reference an uploaded image as your logo for your different PDF templates. Here, we add a custom logo to the header of a template:

  1. <div class="pdfcreator-runningheaderfix">
    	<table>
    		<tr>
    			<td>
    				<div class="pdfcreator-runningheader-logo">
    					[[File:my-logo.png|alt=my logo name]]
    				</div>
    			</td>
    			<td>
    				<h1 class="title">{{{title}}}</h1>
    			</td>
    		</tr>
    	</table>
    </div>
    

Semantic property

It is also possible to print a semantic property in the footer. The following example prints the value of the property "Classification" of a page in the PDF footer.

<div class="pdfcreator-runningfooterfix">
	{{#show:{{FULLPAGENAME}}|?Classification}}
</div>

Background color for header and footer

In the Styles tab, add:

/* add a background color to the header and footer */
.pdfcreator-runningheaderfix, .pdfcreator-runningfooterfix {
background-color: #eee;
}

This adds a grey background color.

Remove the underline from the header and footer

In the Styles tab, add:

/* remove the border from the header */
.pdfcreator-runningheaderfix > table {
border-bottom: none !important;
}

/* remove the border from the header */
.pdfcreator-runningfooterfix > table {
border-top: none !important;
}

Customization examples for the cover page

The cover page can be changed from the Document preface-tab. It is mainly used forbook templates. The default elements are:

  • Title
  • Logo
  • Bookshelf image: If a cover image is explicitely set by the user, the cover image is printed automatically. It does not have a parameter. The automatically generated preview images on the bookshelf are not printed on the PDF cover.

Using background colors

Instead of using cover images, you can define some designs based on colors.

Important:If a book has a cover, it will be printed over the layout that is defined in the customized cover layout. Layouts therefore have to be tested in combination with cover images!

Here are some examples and the needed source text for the page MediaWiki:UniversalExport/PDF/Default/Cover page.html. To use them, simply overwrite the existing content in that page.

Cover page 1

<!-- Logo -->
<div style="margin:1cm; text-align:right">
{{{logo}}}
</div>
<!-- Color block -->
<div style="position:absolute; height:2cm; width:1.8cm; background-color:#3a3b3c; 
margin:4cm 0 0 0;  z-index:-500">
</div>
<div style="position:absolute; height:2cm; width:24cm; background-color:#3366cc; 
margin:4cm 0 0 1.8cm;  z-index:-500">
</div>
<!-- Title -->
<div style="font-size:28pt;font-weight:bold;margin:8.5cm 1cm 1cm 1.8cm;color:#333333;">{{{title}}}
</div>
<!-- Subtitle -->
<div style="font-size:16pt; margin:1cm 1cm 1cm 1.8cm; color:#555555">{{{subtitle}}}
</div>

Cover page 2

<div id="coverpage" style="height:29.7cm; width:21cm; margin:-1cm 0 0 -1.5cm;background: #cdcdcd; overflow:hidden;">
<div style="min-height:10cm; background:white; margin:2cm 0 0 0; padding:1cm">
<!-- Logo -->
{| style="width: 100%; text-align: right;"|
|{{{logo}}}
|}
<!-- Titelblock -->
<div style="font-size: 32pt; font-weight:bold; padding:0 1cm; margin:4.5cm 0 0.5cm 0;color:#333333; background:white">{{{title}}}</div>
<div style="font-size: 24pt; margin-top:0; padding:0 1cm; color:#555555;">{{{subtitle}}}
</div>
</div>

Cover page 3

<!-- Logo -->
{| style="width: 100%; text-align: right;"
|{{{logo}}}
|}
<!-- Title block with background color -->
<div style="background-color:#c6752d; margin:4.5cm -2cm 0 -2cm; padding:2cm 2cm 3cm 2cm;">
<div style="font-size: 24pt; font-weight:bold;  margin-bottom:0.5cm; color:#ffffff;">{{{title}}}
</div>
<!-- Subtitle block -->
<div style="font-size: 18pt; margin-top:0.5cm; color:#efefef">{{{subtitle}}}
</div>
</div>

Migrating existing BlueSpice cloud PDF templates

In BlueSpice 4 cloud, there was one standard template that could be customized in the wiki. Its elements were defined in the following pages:

  • MediaWiki:UniversalExport/PDF/Default/Header.html
  • MediaWiki:UniversalExport/PDF/Default/Footer.html
  • MediaWiki: UniversalExport/PDF/Default/Cover page.html
  • MediaWiki: UniversalExport/PDF/Default/Styles.less

These pages have been replaced in BlueSpice 5. You need to transfer the content of these pages to one or more PDF layouts.

To move the content:

  1. Open the page MediaWiki:PDFCreator.
  2. Select the template you want to edit.
  3. Add the content of your templates to the according tabs:
    1. Header.html -> Header tab
    2. Footer.html -> Footer tab
    3. Cover page -> Document prefixtab
    4. Styles.less -> Styles tab
  4. Correct the style-references for the header and footer wrappers:

The following parameters no longer exist and need to be replaced with MediaWiki magic words:

Parameter Description Replace with
url URL of the wiki page {{fullurl:{{FULLPAGENAME}}}}
user username of user who printed the page
exportdate date of PDF-creation {{CURRENTMONTH}}/{{CURRENTDATE}}/{{CURRENTYEAR}}
exporttime time of PDF-creation {{CURRENTTIME}}

Configuration




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