'PluginPDF',
'documentation' => 'PluginPDF',
'description' => tra('For customized PDF generation, to override global PDF settings.'),
'tags' => [ 'basic' ],
'prefs' => [ 'wikiplugin_pdf' ],
'format' => 'html',
'iconname' => 'pdf',
'introduced' => 17,
'params' => [
'printfriendly' => [
'name' => tra('Print Friendly PDF'),
'description' => tra('Print friendly option will change theme background color to white and text /headings color to black. If set to \'n\', theme colors will be retained in pdf'),
'type' => 'list',
'default' => '',
'options' => [
['text' => 'Default','value' => ''],
['text' => 'Yes','value' => 'y'],
['text' => 'No','value' => 'n'],
],
],
'orientation' => [
'name' => tra('PDF Orientation'),
'description' => tra('Landscape or portrait'),
'type' => 'list',
'default' => $prefs['print_pdf_mpdf_orientation'],
'options' => [
['text' => 'Default','value' => ''],
['text' => 'Portrait','value' => 'P'],
['text' => 'Landscape','value' => 'L'],
],
],
'pagesize' => [
'name' => tra('PDF page size'),
'description' => tra('ISO Standard sizes: A0, A1, A2, A3, A4, A5 or North American paper sizes: Letter, Legal, Tabloid/Ledger (for ledger, select landscape orientation)'),
'type' => 'list',
'options' => [
['text' => 'Default','value' => ''],
['text' => 'Letter','value' => 'Letter'],
['text' => 'Legal','value' => 'Legal'],
['text' => 'Tabloid/Ledger','value' => 'Tabloid/Ledger'],
['text' => 'A0','value' => 'A0'],
['text' => 'A1','value' => 'A1'],
['text' => 'A2','value' => 'A2'],
['text' => 'A3','value' => 'A3'],
['text' => 'A4','value' => 'A4'],
['text' => 'A5','value' => 'A5'],
['text' => 'A6','value' => 'A6']
]
],
'toc' => [
'name' => tra('Generate table of contents'),
'description' => tra('Set if table of contents will be autogenerated before PDF content'),
'type' => 'list',
'default' => $prefs['print_pdf_mpdf_toc'],
'options' => [
['text' => 'Default','value' => ''],
['text' => 'On','value' => 'y'],
['text' => 'Off','value' => 'n'],
],
],
'toclinks' => [
'name' => tra('Link TOC with content'),
'description' => tra('Link TOC headings with content on PDF document'),
'type' => 'list',
'default' => 'n',
'options' => [
['text' => 'Default','value' => ''],
['text' => 'Yes','value' => 'y'],
['text' => 'No','value' => 'n'],
],
],
'tocheading' => [
'name' => tra('TOC heading'),
'description' => tra('Heading to be appeared before table of content is printed'),
'tags' => ['advanced'],
'type' => 'text',
'default' => $prefs['print_pdf_mpdf_tocheading'],
'shorthint' => 'For example:Table of contents'
],
'toclevels' => [
'name' => tra('TOC levels'),
'description' => tra('Will be autopicked from content of document, for example:H1|H2|H3'),
'tags' => ['advanced'],
'type' => 'text',
'default' => "H1|H2|H3",
'shorthint' => ''
],
'pagetitle' => [
'name' => tra('Show Page title'),
'description' => tra('Print wiki page title with pdf'),
'tags' => ['advanced'],
'type' => 'list',
'default' => '',
'options' => [
['text' => 'Default','value' => ''],
['text' => 'Yes','value' => 'y'],
['text' => 'No','value' => 'n']
]
],
'header' => [
'name' => tra('PDF header text'),
'description' => tra('Enter Wiki Syntax / HTML code / Plain text.
Possible values: Custom HTML / Wiki Syntax / text , {PAGENO}, {DATE j-m-Y}, Page {PAGENO} of {NB}, Left text| Center Text | Right Text.
Set header value as off, to turn off header from page'),
'tags' => ['basic'],
'type' => 'text',
'default' => $prefs['print_pdf_mpdf_header'],
],
'footer' => [
'name' => tra('PDF footer text'),
'description' => tra('Possible values: HTML / Wiki Syntax / Plain text, {include page="wiki_page_name"} {PAGENO}, {DATE j-m-Y}.
For example: {PAGETITLE}|Center Text|{PAGENO}, Page {PAGENO} of {NB}, {include page="wiki_page_name"}.
Set footer value as off, to remove footer from page'),
'type' => 'text',
'default' => $prefs['print_pdf_mpdf_footer'],
],
'margin_left' => [
'name' => tra('Left margin'),
'description' => tra('Numeric value.For example 10'),
'type' => 'text',
'default' => $prefs['print_pdf_mpdf_margin_left'],
'size' => '2',
'filter' => 'digits',
],
'margin_right' => [
'name' => tra('Right margin'),
'description' => tra('Numeric value, no need to add px. For example 10'),
'type' => 'text',
'default' => $prefs['print_pdf_mpdf_margin_right'],
'size' => '2',
'filter' => 'digits',
],
'margin_top' => [
'name' => tra('Top margin'),
'description' => tra('Numeric value, no need to add px. For example 10'),
'type' => 'text',
'default' => $prefs['print_pdf_mpdf_margin_top'],
'size' => '2',
'filter' => 'digits',
],
'margin_bottom' => [
'name' => tra('Bottom margin'),
'description' => tra('Numeric value, no need to add px. For example 10'),
'type' => 'text',
'default' => $prefs['print_pdf_mpdf_margin_bottom'],
'size' => '2',
'filter' => 'digits',
],
'margin_header' => [
'name' => tra('Header margin from top of document'),
'description' => tra('Only applicable if header is set. Numeric value only, no need to add px.Warning: Header can overlap text if top margin is not set properly'),
'type' => 'text',
'default' => $prefs['print_pdf_mpdf_margin_header'],
'size' => '2',
'filter' => 'digits',
],
'margin_footer' => [
'name' => tra('Footer margin from bottom of document'),
'description' => tra('Only applicable if footer is set.Numeric value only, no need to add px. Warning: Footer can overlap text if bottom margin is not set properly'),
'type' => 'text',
'default' => $prefs['print_pdf_mpdf_margin_footer'],
'size' => '2',
'filter' => 'digits',
],
'hyperlinks' => [
'name' => tra('Hyperlink behaviour in PDF'),
'description' => tra(''),
'tags' => ['advanced'],
'type' => 'list',
'default' => '',
'options' => [
['text' => 'Default','value' => ''],
['text' => 'Off (Links will be removed)','value' => 'off'],
['text' => 'Add as footnote (Links will be listed at end of document)','value' => 'footnote'],
]
],
'autobookmarks' => [
'name' => tra('Generate PDF Bookmarks'),
'description' => tra('Values H1-H6,separated by | For example H1|H2|H3'),
'tags' => ['advanced'],
'type' => 'text',
'default' => 'h1|h2|h3',
],
'columns' => [
'name' => tra('Number of columns'),
'description' => tra(''),
'tags' => ['advanced'],
'type' => 'list',
'default' => '',
'options' => [
['text' => 'Default - 1 Column','value' => ''],
['text' => '2 Columns','value' => '2'],
['text' => '3 Columns','3'],
['text' => '4 Columns','4'],
]
],
'password' => [
'name' => tra('PDF password for viewing'),
'description' => tra('Secure confidential PDF with password, leave blank if password protected is not needed'),
'type' => 'password',
'default' => $prefs['print_pdf_mpdf_password'],
],
'watermark' => [
'name' => tra('Watermark text'),
'description' => tra('Watermark text value, for example: Confidential, Draft etc. '),
'type' => 'text',
'default' => '',
],
'watermark_image' => [
'name' => tra('Watermark image, enter full URL'),
'description' => tra('Full URL of watermark image'),
'type' => 'text',
'default' => '',
],
'background' => [
'name' => tra('Page background color'),
'description' => tra('Enter a valid CSS color code.'),
'type' => 'text',
'default' => '',
],
'background_image' => [
'name' => tra('Page background image'),
'description' => tra('Enter the full URL.'),
'type' => 'text',
'default' => '',
],
'coverpage_text_settings' => [
'name' => tra('CoverPage text settings'),
'description' => tra('Heading|Subheading|Text Alignment|Background color|Text color|Page border|Border color. Enter settings separated by |,sequence is important,leave blank for default. For example {PAGETITLE}|Tikiwiki|Center|#fff|#000|1|#ccc'),
'type' => 'text',
'default' => '',
],
'coverpage_image_settings' => [
'name' => tra('Coverpage image URL'),
'description' => tra('Enter the full URL.'),
'type' => 'text',
'default' => '',
],
],
];
}
function wikiplugin_pdf($data, $params)
{
//return if not printing PDF
if (! empty($_GET['display']) && strstr($_GET['display'], 'pdf') == '') {
return;
}
//included globals to check mpdf selection as pdf generation engine
global $prefs;
//checking if mdpf is default PDF generation engine, since plugin is only set for mpdf.
if ($prefs['print_pdf_from_url'] != 'mpdf') {
return WikiParser_PluginOutput::internalError(tr('For pluginPDF, please select mpdf as default PDF engine from Print Settings.'));
}
$paramList = '';
//creating string of data paramaters set by user
foreach ($params as $paramName => $param) {
$paramList .= $paramName . "='" . $param . "' ";
}
return "";
}