Manual:Extension/PDFCreator: Difference between revisions

Redaktion (talk | contribs)
Created page with "If you have server access, you can customize the PDF templates for your wiki. If your wiki is hosted in the ''BlueSpice cloud'', basic customizations can be made directly in the wiki. These instructions refer to the PDF single page export and the book export. Please note that the book export is only available in''BlueSpice pro''. == Directory paths for templates == === Standard BlueSpice templates === *'''Com..."
 
Redaktion (talk | contribs)
No edit summary
Line 1: Line 1:
If you  have server access, you can customize the PDF templates for your wiki. If your wiki is hosted in the ''BlueSpice cloud'', basic customizations can be made [[Manual:Extension/BlueSpiceUniversalExport/Customization|directly in the wiki]]. These instructions refer to the PDF single page export and the book export. Please note that the book export is only available in''BlueSpice pro''.
{{DISPLAYTITLE:PDF export (template customization)}}


== Directory paths for templates ==
== The export dialog ==
To print a page to PDF, click on the page-icon in the page tools. This opens the export dialog field.


=== Standard BlueSpice templates ===
Select the export settings.
*'''Common:''' extensions/BlueSpiceUEModulePDF/data/PDFTemplates/common
*'''Single page:''' extensions/BlueSpiceUEModulePDF/data/PDFTemplates/BlueSpice
*'''Book:''' extensions/BlueSpiceUEModuleBookPDF/data/PDFTemplates/BlueSpice Book


{{Textbox|boxtype=important|header=|text=The '''Common''' directory contains common files such as  ''page.css'' that defines the page margins.|icon=no}}
* '''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).


=== Safe directories for your own templates ===
By default, the template ''StandardPDF'' shows the wiki's logo (from the [[Manual:Extension/FlexiSkin|skin settings page]]). If there are no custom settings, the default BlueSpice logo is used.
The PDF templates may not be customized in the standard template directories (see above) since an update will overwrite these directories.
[[File:StandardPDF template.png|alt=PDF page with default header and footer content an a Table of Contents|center|thumb|424x424px|Standard PDF layout]]


You need to store your custom PDF templates in safe directories instead.
==Editing the PDF template==
The wiki provides one template for the standard PDF export and one template for the PDF export of [[Manual:Extension/BlueSpiceBookshelf/4-4|books]]. Both templates offer the same elements for customizing:


'''Examples of safe directories:'''
* Header: The page header of each PDF page.
* Content: The content layout
* Footer: The page footer of each PDF page.
* Document preface: An additional cover page. It has predefined content for the book export. It can additionally also be defined for the standard PDF export
* Document appendix: The last page of the PDF export. By default it has no content.
* Styles: Custom css-classes can be defined and applied to any of the PDF layout pages.


*images/<MyPDFTemplates>
'''To edit the PDF templates:'''
*extensions/BlueSpiceFoundation/data/PDFTemplates


== Editing the templates ==
# Open the page MediaWiki:PDFCreator
The PDF templates for single pages and books are very similar.
# 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 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" only apply to the StandardBookPDF template.  


=== Creating your own templates ===
== Customization examples ==
The contents of the directories
Switch to edit mode on the template pages to make your changes.


*extensions/BlueSpiceUEModulePDF/data/PDFTempates
Add a logo that is different from the wiki logo:
*extensions/BlueSpiceUEModuleBookPDF/data/PDFTempates


Copy to "extensions/BlueSpiceFoundation/data/PDFTemplates" and rename it
=== Add a background color to the header and footer ===
In the Styles tab, add:<syntaxhighlight lang="css">
/* add a background color to the header and footer */
.pdfcreator-runningheaderfix, .pdfcreator-runningfooterfix {
background-color: #eee;
}
</syntaxhighlight>This adds a grey background color.


*"common" => "common" (remains)
=== Remove the underline from the header and footer ===
*"BlueSpice" => "MyPageTemplate"
In the Styles tab, add:<syntaxhighlight lang="css">
*"BlueSpice Book" => "MyBookTemplate"
/* remove the border from the header */
.pdfcreator-runningheaderfix > table {
border-bottom: none !important;
}


The template names must be changed later in the associated template.php.
/* remove the border from the header */
.pdfcreator-runningfooterfix > table {
border-top: none !important;
}
</syntaxhighlight>


=== Directory structure of the templates ===
=== Use a different logo than the wiki logo ===
data/PDFTemplates
By default, the parameter <code><nowiki>{{{logo}}}</nowiki></code> displays the wiki logo in the PDF. If you want to define a different logo for the PDF export, you can use a system message.
    |_ common
    |    |_ stylesheets ('''page.css -> Settings for page margins''')
    |
    |_ MyPageTemplate
    |    |_ template.php
    |    |_ template.html
    |    |_ images
    |    |_ stylesheets ('''styles.css -> Logo in Page Header''')
    |
    |_ MyBookTemplate
          |_ template.php
          |_ template.html
          |_ images
          |_ stylesheets ('''styles.css -> Logo in Page Header''')


=== Customization of the templates ===
# Create the page MediaWiki:PDFlogo
 
# Add the image name of a logo that you have uploaded to the wiki and save the page.<syntaxhighlight lang="text">
==== template.php ====
[[File:my-logo.png|alt=my logo name]]
The file <code>template.php</code> contains the description or definition of the template. All css files and, if applicable, fonts that are to be used in the template must be specified here.
</syntaxhighlight>You have now created a page that the wiki can recognize as a system message, because it is located in the MediaWiki namespace.
 
# Replace the<code><nowiki>{{{logo}}}</nowiki></code>-parameter in the Header tab with the syntax for the system message:<syntaxhighlight lang="text">
The images must also be specified, for example the images that should be used in the header.
{{int:PDFlogo}}
 
</syntaxhighlight>
 
 
Special requirements for the book:
 
The PDF template for the book accesses the common directory of the single page template.
For this reason, the '''template.php''' contains a variable '''$sCommonDir''' that points to the directory. If the templates are copied into their own directory, this path must be adjusted.
 
 
 
'''Important changes in the sections:'''
 
<u>Section '''info''':</u>
 
*name => name of the template (e.g. MyPageTemplate). '''MUST''' match the directory name
 
<u>Section '''resources''':</u>
 
*STYLESHEETS => if necessary, specify additional style sheets here. These must also be specified in the template.html. If you use other fonts, they must also be specified here.
*IMAGES => enter the images you want to use here. Example 'images/bs-header.jpg'
 
<u>Section '''messages''':</u>
 
*Here, texts can be assigned to so-called msg keys. These msg keys can be used in the template.html, e.g. the disclaimer.
*en, de, de-formal are the languages. Unlike texts written in template.html, these msg keys are used depending on the language.
 
==== template.html ====
Basic structure of the page. Here, the page number, for example, can be removed from the footer.
If you want to include your own css files, they must be specified here in the '''<head>'''.
 
Example:
  <link href="stylesheets/styles.css" type="text/css" rel="stylesheet" />
 
=== Customization of the style sheets ===
The display can be changed in the style sheets. This concerns e.g.
 
*Margins
*Header with logo
*Headings
*Text colors
*...
 
 
 
<u>'''The most important examples:'''</u>
 
<u>Page margins:</u>
 
'''File:''' common/stylesheets/page.css
 
The '''@page''' area is the normal page in portrait format. The page margins are set in the "margin" line (order: top right bottom left).
 
 
 
<u>Background image:</u>
 
'''File:''' common/stylesheets/page.css
 
The '''@page''' area is the normal page in portrait format. The background image is set in the “background” line.
 
The background image must be specified in the '''template.php'''. (Only used for the single page at BlueSpice.)
 
 
 
<u>Header (logo):</u>
 
'''File:''' MyPageTemplate/stylesheets/page.css
 
or
 
'''File:''' MyBookTemplate/stylesheets/page.css
 
With '''#bs-runningheaderfix''', the logo for the header is set in the "background" line.
 
The logo must be specified in the '''template.php'''.
 
The size of the header and logo can be influenced with the parameters “margin”, “background-size” and “height”. The “width” line should remain at 21cm (entire page width).
 
== Configuring the templates ==
PDF templates cannot be configured via the Wiki.
 
The following lines must be added to LocalSettings.php:
 
*Example for single page:
 
  $GLOBALS['bsgUEModulePDFTemplatePath'] = 'extensions/BlueSpiceFoundation/data/PDFTemplates';
  $GLOBALS['bsgUEModulePDFDefaultTemplate'] = 'MyPageTemplate';
 
*Example for book:
 
  $GLOBALS['bsgUEModuleBookPDFTemplatePath'] = 'extensions/BlueSpiceFoundation/data


== Configuration ==
[[de:Handbuch:Erweiterung/BlueSpiceUniversalExport/PDF_Vorlagen_erstellen]]
[[de:Handbuch:Erweiterung/BlueSpiceUniversalExport/PDF_Vorlagen_erstellen]]

Revision as of 10:57, 14 February 2025


The export dialog

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 the PDF template

The wiki provides one template for the standard PDF export and one template for the PDF export of books. Both templates offer the same elements for customizing:

  • Header: The page header of each PDF page.
  • Content: The content layout
  • Footer: The page footer of each PDF page.
  • Document preface: An additional cover page. It has predefined content for the book export. It can additionally also be defined for the standard PDF export
  • Document appendix: The last page of the PDF export. By default it has no content.
  • Styles: Custom css-classes can be defined and applied to any of the PDF layout pages.

To edit the PDF templates:

  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 PDF 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" only apply to the StandardBookPDF template.

Customization examples

Switch to edit mode on the template pages to make your changes.

Add a logo that is different from the wiki logo:

Add a background color to the 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;
}

By default, the parameter {{{logo}}} displays the wiki logo in the PDF. If you want to define a different logo for the PDF export, you can use a system message.

  1. Create the page MediaWiki:PDFlogo
  2. Add the image name of a logo that you have uploaded to the wiki and save the page.
    [[File:my-logo.png|alt=my logo name]]
    
    You have now created a page that the wiki can recognize as a system message, because it is located in the MediaWiki namespace.
  3. Replace the{{{logo}}}-parameter in the Header tab with the syntax for the system message:
    	{{int:PDFlogo}}
    

Configuration




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