Links
Link important words to other wiki articles or even other websites. It will help readers understand the context.
Okay, got itYou do not have permission to edit this page, for the following reason:
You do not have permission to edit this page, for the following reason:
You can view and copy the source of this page.
Templates used on this page:
Return to Setup:Installation Guide/Advanced/Maintenance scripts/CreatePDF.
{{Textbox|boxtype=warning|header=Review PDF export compatibility!|text=The [[en4:Setup:Installation_Guide/Advanced/Maintenance_scripts/export|PDF export script for BlueSpice 4]] is different. If you want to migrate your BlueSpice 4 script to BlueSpice 5, [[#Migration_from_older_format|consult the migration info]].|icon=yes}}
=== PDF Export from CLI ===
You can export PDF files from your MediaWiki installation via the command line by using a specification file in JSON format.
==== Create a JSON specification file ====
This file defines all the parameters for the export process. Below is a minimal example:
<syntaxhighlight lang="json">{
"module": "batch",
"params": {
"filename": "MyExport.pdf",
"filesystem-path": "/app/d/pdfcreator/cache",
"target": "filesystem",
"user": "WikiSysop"
},
"options": {
"attachments": true
},
"pages": [
{
"type": "page",
"target": "Main_Page"
}
]
}</syntaxhighlight>
You can expand this file to include more pages, templates, or custom options. Here’s a more advanced example:
<syntaxhighlight lang="json">{
"module": "batch",
"params": {
"filename": "FullExport.pdf",
"filesystem-path": "/var/pdf_exports",
"target": "filesystem",
"user": "ExportAdmin",
"title": "My Export Title",
"template": "AdvancedTemplate",
"logo": "<nowiki>https://example.com/logo.png</nowiki>",
"export-date": "2025-04-25",
"export-time": "14:00"
},
"options": {
"attachments": true,
"suppress-links": false,
"embed-page-toc": true,
"no-redirect": true
},
"pages": [
{
"type": "page",
"target": "Main_Page",
"label": "Hauptseite"
},
{
"type": "pageWithSubpages",
"target": "Category:Documentation",
"label": "Dokumentation"
},
{
"type": "pageWithLinkedPages",
"target": "Help:Editing",
"label": "Bearbeitungshilfe"
}
]
}</syntaxhighlight>
==== Start export from CLI ====
Once your JSON file is ready, run the following command to start the export:
<code>php extensions/PDFCreator/maintenance/CreatePDF.php cache/specification.json</code>
=== Available parameters ===
==== General parameters (<code>params</code>): ====
* <code>filename</code>: Name of the exported PDF.
* <code>filesystem-path</code>: Path to store the exported file.
* <code>target</code>: Can be <code>filesystem</code> or <code>download</code>.
* <code>user</code>: Username used for export context.
* <code>title</code>: Optional title for the PDF.
* <code>template</code>: Optional PDF template.
* <code>logo</code>: Optional logo URL.
* <code>export-date</code>, <code>export-time</code>: Timestamp data for PDF metadata.
==== Options (<code>options</code>): ====
* <code>attachments</code>: <code>true</code> to include media files.
* <code>suppress-links</code>: <code>true</code> to disable links in the PDF.
* <code>embed-page-toc</code>: <code>true</code> to include a table of contents.
* <code>no-redirect</code>: <code>true</code> to avoid following redirects.
==== Page definitions (<code>pages</code>): ====
* <code>type</code>: One of <code>page</code>, <code>pageWithSubpages</code>, <code>pageWithLinkedPages</code>.
* <code>target</code>: Page name.
* <code>label</code>: Custom label (optional).
* <code>params</code>: Page-specific options (e.g., <code>rev-id</code>, <code>status</code>).
=== Automating with CronJob ===
To automate regular exports, set up a CronJob:
<code>php {MW_ROOT}/extensions/PDFCreator/maintenance/CreatePDF.php --specification-file={MW_ROOT}/extensions/BlueSpiceFoundation/data/spec.json</code>
Replace <code>{MW_ROOT}</code> with your MediaWiki installation path.
=== Migration from older format ===
If you're using the legacy <code>pdf</code> or <code>bookpdf</code> module format, migrate to the new <code>batch</code> format using the following mapping:
==== Old format ====
<syntaxhighlight lang="json">{
"module": "pdf",
"attachments": 1,
"recursive": 1,
"title": "MyPDF",
"target": "localfilesystem",
"target-file-name": "All.pdf",
"target-file-path": "/path/to/target-file"
}</syntaxhighlight>
==== New format ====
<syntaxhighlight lang="json">{
"module": "batch",
"params": {
"filename": "All.pdf",
"filesystem-path": "/path/to/target-file",
"target": "filesystem",
"title": "MyPDF"
},
"options": {
"attachments": true
},
"pages": [
{
"type": "page",
"target": "Main_Page"
}
]
}</syntaxhighlight>
==== Key changes ====
{| class="wikitable"
!Old Parameter
!New Parameter
!Notes
|-
|<code>module=pdf</code>
|<code>module=batch</code>
|Unified module name
|-
|<code>attachments</code>
|<code>options.attachments</code>
|Moved into <code>options</code>, uses <code>true/false</code>
|-
|<code>recursive</code>
|Removed
|Use <code>pageWithLinkedPages</code> instead
|-
|<code>title</code>
|<code>params.title</code>
|Moved into <code>params</code>
|-
|<code>target=localfilesystem</code>
|<code>params.target=filesystem</code>
|Updated value
|-
|<code>target-file-name</code>
|<code>params.filename</code>
|Renamed and moved into <code>params</code>
|-
|<code>target-file-path</code>
|<code>params.filesystem-path</code>
|Renamed and moved into <code>params</code>
|}
{{Textbox|boxtype=warning|header=Review PDF export compatibility!|text=The [[en4:Setup:Installation_Guide/Advanced/Maintenance_scripts/export|PDF export script for BlueSpice 4]] is different. If you want to migrate your BlueSpice 4 script to BlueSpice 5, [[#Migration_from_older_format|consult the migration info]].|icon=yes}}
=== PDF Export from CLI ===
You can export PDF files from your MediaWiki installation via the command line by using a specification file in JSON format.
==== Create a JSON specification file ====
This file defines all the parameters for the export process. Below is a minimal example:
<syntaxhighlight lang="json">{
"module": "batch",
"params": {
"filename": "MyExport.pdf",
"filesystem-path": "/app/d/pdfcreator/cache",
"target": "filesystem",
"user": "WikiSysop"
},
"options": {
"attachments": true
},
"pages": [
{
"type": "page",
"target": "Main_Page"
}
]
}</syntaxhighlight>
You can expand this file to include more pages, templates, or custom options. Here’s a more advanced example:
<syntaxhighlight lang="json">{
"module": "batch",
"params": {
"filename": "FullExport.pdf",
"filesystem-path": "/var/pdf_exports",
"target": "filesystem",
"user": "ExportAdmin",
"title": "My Export Title",
"template": "AdvancedTemplate",
"logo": "<nowiki>https://example.com/logo.png</nowiki>",
"export-date": "2025-04-25",
"export-time": "14:00"
},
"options": {
"attachments": true,
"suppress-links": false,
"embed-page-toc": true,
"no-redirect": true
},
"pages": [
{
"type": "page",
"target": "Main_Page",
"label": "Hauptseite"
},
{
"type": "pageWithSubpages",
"target": "Category:Documentation",
"label": "Dokumentation"
},
{
"type": "pageWithLinkedPages",
"target": "Help:Editing",
"label": "Bearbeitungshilfe"
}
]
}</syntaxhighlight>
==== Start export from CLI ====
Once your JSON file is ready, run the following command to start the export:
<code>php extensions/PDFCreator/maintenance/CreatePDF.php cache/specification.json</code>
=== Available parameters ===
==== General parameters (<code>params</code>): ====
* <code>filename</code>: Name of the exported PDF.
* <code>filesystem-path</code>: Path to store the exported file.
* <code>target</code>: Can be <code>filesystem</code> or <code>download</code>.
* <code>user</code>: Username used for export context.
* <code>title</code>: Optional title for the PDF.
* <code>template</code>: Optional PDF template.
* <code>logo</code>: Optional logo URL.
* <code>export-date</code>, <code>export-time</code>: Timestamp data for PDF metadata.
==== Options (<code>options</code>): ====
* <code>attachments</code>: <code>true</code> to include media files.
* <code>suppress-links</code>: <code>true</code> to disable links in the PDF.
* <code>embed-page-toc</code>: <code>true</code> to include a table of contents.
* <code>no-redirect</code>: <code>true</code> to avoid following redirects.
==== Page definitions (<code>pages</code>): ====
* <code>type</code>: One of <code>page</code>, <code>pageWithSubpages</code>, <code>pageWithLinkedPages</code>.
* <code>target</code>: Page name.
* <code>label</code>: Custom label (optional).
* <code>params</code>: Page-specific options (e.g., <code>rev-id</code>, <code>status</code>).
=== Automating with CronJob ===
To automate regular exports, set up a CronJob:
<code>php {MW_ROOT}/extensions/PDFCreator/maintenance/CreatePDF.php --specification-file={MW_ROOT}/extensions/BlueSpiceFoundation/data/spec.json</code>
Replace <code>{MW_ROOT}</code> with your MediaWiki installation path.
=== Migration from older format ===
If you're using the legacy <code>pdf</code> or <code>bookpdf</code> module format, migrate to the new <code>batch</code> format using the following mapping:
==== Old format ====
<syntaxhighlight lang="json">{
"module": "pdf",
"attachments": 1,
"recursive": 1,
"title": "MyPDF",
"target": "localfilesystem",
"target-file-name": "All.pdf",
"target-file-path": "/path/to/target-file"
}</syntaxhighlight>
==== New format ====
<syntaxhighlight lang="json">{
"module": "batch",
"params": {
"filename": "All.pdf",
"filesystem-path": "/path/to/target-file",
"target": "filesystem",
"title": "MyPDF"
},
"options": {
"attachments": true
},
"pages": [
{
"type": "page",
"target": "Main_Page"
}
]
}</syntaxhighlight>
==== Key changes ====
{| class="wikitable"
!Old Parameter
!New Parameter
!Notes
|-
|<code>module=pdf</code>
|<code>module=batch</code>
|Unified module name
|-
|<code>attachments</code>
|<code>options.attachments</code>
|Moved into <code>options</code>, uses <code>true/false</code>
|-
|<code>recursive</code>
|Removed
|Use <code>pageWithLinkedPages</code> instead
|-
|<code>title</code>
|<code>params.title</code>
|Moved into <code>params</code>
|-
|<code>target=localfilesystem</code>
|<code>params.target=filesystem</code>
|Updated value
|-
|<code>target-file-name</code>
|<code>params.filename</code>
|Renamed and moved into <code>params</code>
|-
|<code>target-file-path</code>
|<code>params.filesystem-path</code>
|Renamed and moved into <code>params</code>
|}