No edit summary Tag: 2017 source edit |
No edit summary Tag: 2017 source edit |
||
Line 5: | Line 5: | ||
You can export PDF files from your MediaWiki installation via the command line by using a specification file in JSON format. | You can export PDF files from your MediaWiki installation via the command line by using a specification file in JSON format. | ||
==== Create a JSON | ==== Create a JSON specification file ==== | ||
This file defines all the parameters for the export process. Below is a minimal example: | This file defines all the parameters for the export process. Below is a minimal example: | ||
<syntaxhighlight lang="json">{ | <syntaxhighlight lang="json">{ | ||
Line 64: | Line 64: | ||
}</syntaxhighlight> | }</syntaxhighlight> | ||
==== Start | ==== Start export from CLI ==== | ||
Once your JSON file is ready, run the following command to start the export: | 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> | <code>php extensions/PDFCreator/maintenance/CreatePDF.php cache/specification.json</code> | ||
=== Available | === Available parameters === | ||
==== General | ==== General parameters (<code>params</code>): ==== | ||
* <code>filename</code>: Name of the exported PDF. | * <code>filename</code>: Name of the exported PDF. | ||
Line 88: | Line 88: | ||
* <code>no-redirect</code>: <code>true</code> to avoid following redirects. | * <code>no-redirect</code>: <code>true</code> to avoid following redirects. | ||
==== Page | ==== Page definitions (<code>pages</code>): ==== | ||
* <code>type</code>: One of <code>page</code>, <code>pageWithSubpages</code>, <code>pageWithLinkedPages</code>. | * <code>type</code>: One of <code>page</code>, <code>pageWithSubpages</code>, <code>pageWithLinkedPages</code>. | ||
Line 100: | Line 100: | ||
Replace <code>{MW_ROOT}</code> with your MediaWiki installation path. | Replace <code>{MW_ROOT}</code> with your MediaWiki installation path. | ||
=== Migration from | === 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: | 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 | ==== Old format ==== | ||
<syntaxhighlight lang="json">{ | |||
"module": "pdf", | "module": "pdf", | ||
"attachments": 1, | "attachments": 1, | ||
Line 112: | Line 112: | ||
"target-file-name": "All.pdf", | "target-file-name": "All.pdf", | ||
"target-file-path": "/path/to/target-file" | "target-file-path": "/path/to/target-file" | ||
}</ | }</syntaxhighlight> | ||
==== New | ==== New format ==== | ||
<syntaxhighlight lang="json">{ | |||
"module": "batch", | "module": "batch", | ||
"params": { | "params": { | ||
Line 132: | Line 132: | ||
} | } | ||
] | ] | ||
}</ | }</syntaxhighlight> | ||
==== Key | ==== Key changes ==== | ||
{| class="wikitable" | {| class="wikitable" | ||
!Old Parameter | !Old Parameter | ||
Line 168: | Line 168: | ||
|Renamed and moved into <code>params</code> | |Renamed and moved into <code>params</code> | ||
|} | |} | ||
Revision as of 09:56, 25 April 2025
Review PDF export compatibility!The PDF export script for BlueSpice 4 is different.
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:
{
"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"
}
]
}
You can expand this file to include more pages, templates, or custom options. Here’s a more advanced example:
{
"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"
}
]
}
Start export from CLI
Once your JSON file is ready, run the following command to start the export:
php extensions/PDFCreator/maintenance/CreatePDF.php cache/specification.json
Available parameters
General parameters (params
):
filename
: Name of the exported PDF.filesystem-path
: Path to store the exported file.target
: Can befilesystem
ordownload
.user
: Username used for export context.title
: Optional title for the PDF.template
: Optional PDF template.logo
: Optional logo URL.export-date
,export-time
: Timestamp data for PDF metadata.
Options (options
):
attachments
:true
to include media files.suppress-links
:true
to disable links in the PDF.embed-page-toc
:true
to include a table of contents.no-redirect
:true
to avoid following redirects.
Page definitions (pages
):
type
: One ofpage
,pageWithSubpages
,pageWithLinkedPages
.target
: Page name.label
: Custom label (optional).params
: Page-specific options (e.g.,rev-id
,status
).
Automating with CronJob
To automate regular exports, set up a CronJob:
php {MW_ROOT}/extensions/PDFCreator/maintenance/CreatePDF.php --specification-file={MW_ROOT}/extensions/BlueSpiceFoundation/data/spec.json
Replace {MW_ROOT}
with your MediaWiki installation path.
Migration from older format
If you're using the legacy pdf
or bookpdf
module format, migrate to the new batch
format using the following mapping:
Old format
{
"module": "pdf",
"attachments": 1,
"recursive": 1,
"title": "MyPDF",
"target": "localfilesystem",
"target-file-name": "All.pdf",
"target-file-path": "/path/to/target-file"
}
New format
{
"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"
}
]
}
Key changes
Old Parameter | New Parameter | Notes |
---|---|---|
module=pdf
|
module=batch
|
Unified module name |
attachments
|
options.attachments
|
Moved into options , uses true/false
|
recursive
|
Removed | Use pageWithLinkedPages instead
|
title
|
params.title
|
Moved into params
|
target=localfilesystem
|
params.target=filesystem
|
Updated value |
target-file-name
|
params.filename
|
Renamed and moved into params
|
target-file-path
|
params.filesystem-path
|
Renamed and moved into params
|