Manual:Extension/PDFCreator: Difference between revisions

Redaktion (talk | contribs)
No edit summary
Redaktion (talk | contribs)
No edit summary
Line 58: Line 58:
!Footer
!Footer
|The page footer of each PDF page. The basic structure is:<syntaxhighlight lang="html">
|The page footer of each PDF page. The basic structure is:<syntaxhighlight lang="html">
<div class="pdfcreator-runningheaderfix">
<div class="pdfcreator-runningfooterfix">
<table>
<table>
<tr>
<tr>
<td>
<td>
<div class="pdfcreator-runningheader-logo">
<span>{{int:pdfcreator-pdf-disclaimer}}</span>
{{{logo}}}
</td>
</div>
<td>
<span>{{int:pdfcreator-pdf-export-time}}:{{#time:d.m.Y|now}}</span>
</td>
</td>
<td>
<td>
<h1 class="title">{{{title}}}</h1>
<span>{{int:pdfcreator-pdf-param-currentpagenumber-label}} </span>{{{currentpagenumber}}}
<span> {{int:pdfcreator-pdf-param-totalpagescount-label}} </span>{{{totalpagescount}}}
</td>
</td>
</tr>
</tr>
Line 90: Line 92:
|
|
|}
|}
== Configuration ==
The wiki configuration allows to set a default template for the PDF Page export and a default cover background image for cover pages.
[[File:PDFCreator config.png|alt=Konfiguration for the default page export template and default cover image|center|thumb|650x650px|PDFCreator Konfiguration]]
=== Default export template for pages ===
The default template is shown when users select an export template in "Page" mode. It is also used when clicking on the PDF link for the [[Manual:Extension/ContentDroplets|Content Droplet]] ''PDF Link'' .
Templates of type "Page" usually do not have a cover page defined.
[[File:PDFCreator config default page template.png|alt=PDF export dialog with default page template selected|center|thumb|550x550px|Default page template]]
=== Default cover background image ===
Admins can also set a default cover background image. It is applied whenever the document preface of the template contains the standard "intro"-wrapper:<syntaxhighlight lang="html">
<div class="pdfcreator-intro">
....
</div>
</syntaxhighlight>
[[File:PDFCreator config cover.png|alt=Example default image on an exported cover sheet.|center|thumb|424x424px|Default image for the cover sheet]]
{{Textbox|boxtype=note|header=Note:|text=If a book has a custom bookshelf-image set in its metadata, the custom bookshelf-image is used instead.|icon=yes}}


== Adding a new template ==
== Adding a new template ==
Line 166: Line 187:
Instead of using cover images, you can define some designs based on colors.  
Instead of using cover images, you can define some designs based on colors.  
{{Textbox|boxtype=important|header=Important:|text=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!|icon=yes}}
{{Textbox|boxtype=important|header=Important:|text=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!|icon=yes}}
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.<gallery widths="220" heights="300" perrow="34">
Here is an example and the needed HTML/CSS for the PDF layout.  <gallery widths="220" heights="300" perrow="34">
File:Manual:Cover-bgcolor-stripe-EN.png|BookStyle1
File:Manual:Cover-bgcolor-stripe-EN.png|BookStyle1
File:Manual:Cover-bgcolor-topbottom-EN.png|BookStyle2
File:Manual:Cover-bgcolor-middle-withtext-EN.png|BookStyle2
</gallery>
</gallery>


Line 208: Line 227:
/* Subtitle */
/* Subtitle */
.pdfcreator-bookStyle1-subtitle {font-size:16pt; margin:1cm 1cm 1cm 1.8cm; color:#555555}
.pdfcreator-bookStyle1-subtitle {font-size:16pt; margin:1cm 1cm 1cm 1.8cm; color:#555555}
</syntaxhighlight>'''Cover page 2'''<syntaxhighlight lang="text">
<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>
</syntaxhighlight>'''Cover page 3'''<syntaxhighlight lang="text">
<!-- 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>
</syntaxhighlight>
</syntaxhighlight>
== Migrating existing BlueSpice cloud PDF templates ==
== 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:
BlueSpice 4 cloud has one standard template that can be customized in the wiki. Its elements are defined in the following pages:


* MediaWiki:UniversalExport/PDF/Default/Header.html
* MediaWiki:UniversalExport/PDF/Default/Header.html
Line 243: Line 236:
* MediaWiki: UniversalExport/PDF/Default/Styles.less
* 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.  
These pages have been replaced in BlueSpice 5. You need to transfer the content of these pages to one or more new PDF layouts.  


'''To move the content:'''
'''To move the content:'''
#'''Open''' the page ''MediaWiki:PDFCreator.''
#'''Open''' the page ''MediaWiki:PDFCreator.''
# '''Select''' the template you want to edit.  
# '''Select''' the template you want to edit or [[Pagedraft:Manual:Extension/PDFCreator#Adding a new template|create a new one]].  
# '''Add''' the content of your templates to the according tabs:  
# '''Add''' the content of your templates to the appropriate  tabs:  
## Header.html -> Header tab
## Header.html -> Header tab
## Footer.html -> Footer tab
## Footer.html -> Footer tab
Line 254: Line 247:
## Styles.less -> Styles tab
## Styles.less -> Styles tab
# '''Correct''' the style-references  for the header and footer wrappers:<!-- TABLE HERE -->
# '''Correct''' the style-references  for the header and footer wrappers:<!-- TABLE HERE -->
Comparison of the default template content of ''BlueSpice 4 cloud'' and ''BlueSpice 5 cloud'':
{| class="wikitable" style="width: 100%;"
!
!BlueSpice 4
!BlueSpice 5
|-
!Header
|<syntaxhighlight lang="text">
{|
| {{{logo}}} || || {{{title}}}
|}
</syntaxhighlight>Note:
* The header-wrapper was created in the background and marked by the id="runningheaderfix". This ID no longer exists, but could be added manually to the new wrapper element.
|The page header 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>
|-
!Content
|
|The content layout. The basic structure is:<syntaxhighlight lang="html">
{{{content}}}
</syntaxhighlight>
|-
!Footer
|<syntaxhighlight lang="text">
{|
| {{{exportdate}}} || {{int:universal-export-pdf-default-disclaimer}} || {{{currentpagenumber}}} / {{{totalpagescount}}}
|}
</syntaxhighlight>Note:
* The footer-wrapper was created in the background and marked by the id="runningfooterfix". This ID no longer exists, but could be added manually to the new wrapper element.
* The parameter <code><nowiki>{{{exportdate}}}</nowiki></code> no longer exists.  It can be replaced with the [[mediawikiwiki:Help:Extension:ParserFunctions##time|parser function]] <code><nowiki>{{#time:m/d/Y|now}}</nowiki></code> or with the [[mediawikiwiki:Help:Magic_words#Date_and_time|MediaWiki magic words]] <code><nowiki>{{CURRENTMONTH}}</nowiki>/<nowiki>{{CURRENTDAY}}</nowiki>/<nowiki>{{CURRENTYEAR}}</nowiki></code>
|<syntaxhighlight lang="html">
<div class="pdfcreator-runningfooterfix">
<table>
<tr>
<td>
<span>{{int:pdfcreator-pdf-disclaimer}}</span>
</td>
<td>
<span>{{int:pdfcreator-pdf-export-time}}:{{#time:d.m.Y|now}}</span>
</td>
<td>
<span>{{int:pdfcreator-pdf-param-currentpagenumber-label}} </span>{{{currentpagenumber}}}
<span> {{int:pdfcreator-pdf-param-totalpagescount-label}} </span>{{{totalpagescount}}}
</td>
</tr>
</table>
</div>
</syntaxhighlight>
|-
!Document preface
|<syntaxhighlight lang="html">
{| style="width: 100%; text-align: right;"
|{{{logo}}}
|}
{| style="margin-top: 10cm;"
| <span style="font-size: 18px; font-weight:bold;">{{{title}}}</span>
|-
|{{{subtitle}}}
|-
|}
</syntaxhighlight>Note:
* the parameter <code><nowiki>{{{backgroundcover}}}</nowiki></code> was available to set a background image for the cover sheet. This parameter no longer exists.
* The background image is now set when the wrapper <nowiki><div class="pdfcreator-intro">...</div></nowiki>exists:
** It shows the default cover image defined in the Config manager settings. If no image is set, no background image is printed unless
** a bookshelf-image is defined in the metadata for a book.
|<syntaxhighlight lang="html">
<div class="pdfcreator-intro">
<div class="pdfcreator-intro-title">{{{title}}}</div>
</div>
</syntaxhighlight>Note: If you do not want to use a predefined cover background image in a template (e.g. from the configuration manager setting or the bookshelf-image of a book), do not use a wrapper with class <code>pdfcreator-intro</code>.
|-
!Document appendix
|n/a
|The last page of the PDF export. It has no predefined basic structure.
|-
!Styles
|default styles.
|Style declarations for the CSS classes that are used in any of the template elements. There are no predefined styles.
|-
!Description
|n/a
|Allows to document the template and its usage purpose.
|}
The following parameters no longer exist and need to be replaced with MediaWiki magic words:
The following parameters no longer exist and need to be replaced with MediaWiki magic words:
{| class="wikitable"
{| class="wikitable"
|+
|+Obsolete parameters
!Parameter
!Parameter
!Description
!Description
Line 284: Line 383:
|Subtitle of the book
|Subtitle of the book
|<nowiki>{{{book-subtitle}}}</nowiki>
|<nowiki>{{{book-subtitle}}}</nowiki>
|}
|}{{#dpl:title=BlueSpiceConfigManager|include=#PDFCreator}}
 
== Configuration ==
{{#dpl:title=BlueSpiceConfigManager|include=#PDFCreator}}
[[de:Handbuch:Erweiterung/BlueSpiceUniversalExport/PDF_Vorlagen_erstellen]]
[[de:Handbuch:Erweiterung/BlueSpiceUniversalExport/PDF_Vorlagen_erstellen]]

Revision as of 14:38, 21 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-runningfooterfix">
	<table>
		<tr>
			<td>
				<span>{{int:pdfcreator-pdf-disclaimer}}</span>
			</td>
			<td>
				<span>{{int:pdfcreator-pdf-export-time}}:{{#time:d.m.Y|now}}</span>
			</td>
			<td>
				<span>{{int:pdfcreator-pdf-param-currentpagenumber-label}} </span>{{{currentpagenumber}}} 
				<span> {{int:pdfcreator-pdf-param-totalpagescount-label}} </span>{{{totalpagescount}}}
			</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

Configuration

The wiki configuration allows to set a default template for the PDF Page export and a default cover background image for cover pages.

Konfiguration for the default page export template and default cover image
PDFCreator Konfiguration

Default export template for pages

The default template is shown when users select an export template in "Page" mode. It is also used when clicking on the PDF link for the Content Droplet PDF Link .

Templates of type "Page" usually do not have a cover page defined.

PDF export dialog with default page template selected
Default page template

Default cover background image

Admins can also set a default cover background image. It is applied whenever the document preface of the template contains the standard "intro"-wrapper:

<div class="pdfcreator-intro">
....
</div>
Example default image on an exported cover sheet.
Default image for the cover sheet
Note:If a book has a custom bookshelf-image set in its metadata, the custom bookshelf-image is used instead.


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 is an example and the needed HTML/CSS for the PDF layout.

BookStyle1

Document preface:

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

Document preface:

/* Logo */
.pdfcreator-bookStyle1-logo {margin:1cm; text-align:right}

/* Color block */
.pdfcreator-bookStyle1-colorblock  {position:absolute; height:2cm; width:1.8cm; background-color:#3a3b3c; 
margin:4cm 0 0 0;  z-index:-500}

.pdfcreator-bookStyle1-colorblock-accent {position:absolute; height:2cm; width:24cm; background-color:#3366cc; 
margin:4cm 0 0 1.8cm;  z-index:-500}

/* Title */
.pdfcreator-bookStyle1-title {font-size:28pt;font-weight:bold;margin:8.5cm 1cm 1cm 1.8cm;color:#333333;}

/* Subtitle */
.pdfcreator-bookStyle1-subtitle {font-size:16pt; margin:1cm 1cm 1cm 1.8cm; color:#555555}

Migrating existing BlueSpice cloud PDF templates

BlueSpice 4 cloud has one standard template that can be customized in the wiki. Its elements are 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 new PDF layouts.

To move the content:

  1. Open the page MediaWiki:PDFCreator.
  2. Select the template you want to edit or create a new one.
  3. Add the content of your templates to the appropriate 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:


Comparison of the default template content of BlueSpice 4 cloud and BlueSpice 5 cloud:

BlueSpice 4 BlueSpice 5
Header
{|
| {{{logo}}} || || {{{title}}}
|}
Note:
  • The header-wrapper was created in the background and marked by the id="runningheaderfix". This ID no longer exists, but could be added manually to the new wrapper element.
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
{|
| {{{exportdate}}} || {{int:universal-export-pdf-default-disclaimer}} || {{{currentpagenumber}}} / {{{totalpagescount}}}
|}
Note:
  • The footer-wrapper was created in the background and marked by the id="runningfooterfix". This ID no longer exists, but could be added manually to the new wrapper element.
  • The parameter {{{exportdate}}} no longer exists. It can be replaced with the parser function {{#time:m/d/Y|now}} or with the MediaWiki magic words {{CURRENTMONTH}}/{{CURRENTDAY}}/{{CURRENTYEAR}}
<div class="pdfcreator-runningfooterfix">
	<table>
		<tr>
			<td>
				<span>{{int:pdfcreator-pdf-disclaimer}}</span>
			</td>
			<td>
				<span>{{int:pdfcreator-pdf-export-time}}:{{#time:d.m.Y|now}}</span>
			</td>
			<td>
				<span>{{int:pdfcreator-pdf-param-currentpagenumber-label}} </span>{{{currentpagenumber}}} 
				<span> {{int:pdfcreator-pdf-param-totalpagescount-label}} </span>{{{totalpagescount}}}
			</td>
		</tr>
	</table>
</div>
Document preface
{| style="width: 100%; text-align: right;"
|{{{logo}}}
|}
{| style="margin-top: 10cm;"
| <span style="font-size: 18px; font-weight:bold;">{{{title}}}</span>
|-
|{{{subtitle}}}
|-
|}
Note:
  • the parameter {{{backgroundcover}}} was available to set a background image for the cover sheet. This parameter no longer exists.
  • The background image is now set when the wrapper <div class="pdfcreator-intro">...</div>exists:
    • It shows the default cover image defined in the Config manager settings. If no image is set, no background image is printed unless
    • a bookshelf-image is defined in the metadata for a book.
<div class="pdfcreator-intro">
	<div class="pdfcreator-intro-title">{{{title}}}</div>
</div>
Note: If you do not want to use a predefined cover background image in a template (e.g. from the configuration manager setting or the bookshelf-image of a book), do not use a wrapper with class pdfcreator-intro.
Document appendix n/a The last page of the PDF export. It has no predefined basic structure.
Styles default styles. Style declarations for the CSS classes that are used in any of the template elements. There are no predefined styles.
Description n/a Allows to document the template and its usage purpose.


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

Obsolete parameters
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}}
title Title of the book {{{title}}} (or - if set in the book metadata - the {{{book-title}}})
subtitle Subtitle of the book {{{book-subtitle}}}




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