[[en6:Main Page|Switch to BlueSpice 5 / 6 Helpdesk Template:Icon]]

Controlled Document:Installation Guide/Advanced/Maintenance scripts/export: Difference between revisions

WikiSysop (talk | contribs)
Created page with "=== 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. Export specification for a single page: <syntaxhighlight lang="json">{ "module": "batch", "target": "filesystem", "params": { "user": "WikiSysop", "title": "Test export", "filesystem-path": "/tmp", "file..."
 
(No difference)

Latest revision as of 10:15, 8 October 2026

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.

Export specification for a single page:

{
	"module": "batch",
	"target": "filesystem",
		"params": {
		"user": "WikiSysop",
		"title": "Test export",
		"filesystem-path": "/tmp",
		"filename": "Test.pdf",
		"template": "StandardPDF"
	},
	"options": {
		"attachments" : true,
		"embed-page-toc": true,
		"title-show-namespace": true
	},
	"pages": [
		{
			"type": "page",
			"target": "ABC:Page_1/Subpage1",
			"label": "Subpage1",
			"rev-id": "1234"
		}
	]
}

Export specification example for mode pageWithLinkedPages or pageWithSubpages

{
	"module": "batch",
	"target": "filesystem",
	"template": "StandardPDF",
	"params": {
		"mode": "pageWithLinkedPages",
		"user": "WikiSysop",
		"title": "Test export",
		"filesystem-path": "/tmp",
		"filename": "Test.pdf",
		"relevantTitle": "Main_Page"
	},
	"options": {
		"debug": true,
		"attachments" : true,
		"embed-page-toc": true,
		"title-show-namespace": true
	}
}


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):

  • mode:
    • pageWithLinkedPages : The pages linked on the page are exported as well.
    • pageWithSubpages: The subpages of the page are exported as well.
      Important:"mode" does not work with module "book"!
  • filename: name of the exported PDF
  • filesystem-path: path to store the exported file
  • target: can be filesystem or download
  • user: username used for export context
  • title: optional title for the PDF
  • template: optional PDF template

Options (options):

  • attachments:true to include linked files
  • embed-page-toc: true to include the page table of contents
  • title-show-namespace: true to avoid following redirects

Page definitions (pages):

  • type: one of page, raw
    • page: wiki content page
    • raw: requires setting of label, rendered as <h1>-tag, mainly used for a special book export
  • label: replaces actual page title
  • target: page name
  • rev-id: export of a specific revision ID of the page instead of the latest revision

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.