⇐ dw2pdf plugin
If you're a plugin developer and want to make your syntax plugin compatible with the PDF export, here are a few tips:
print.css
/print.less
and PDF export will probably work out of the boxpdf.css
/pdf.less
(it will replace the print.css
/print.less
)
If you want to provide custom HTML for the PDF export you should check if the renderer is a renderer_plugin_dw2pdf
when rendering xhtml
.
function render($mode, $renderer, $data){ if($mode == 'xhtml') { if(is_a($renderer,'renderer_plugin_dw2pdf')){ // this is the PDF export, render simple HTML here }else{ // this is normal XHTML for Browsers, be fancy here } return true; } return false; }
By default, dw2pdf
will fetch embedded images via HTTP. If you want to embed local image files without going through HTTP, you can give their location by writing an img
tag using the dw2pdf://
pseudo protocol:
$R->doc .= '<img src="dw2pdf:///full/path/to/some/image.png">';
Examples:
Dw2pdf provides an event called PLUGIN_DW2PDF_REPLACE
, which gives other plugins access to replacement patterns and all processed template parts, including cover and citation.
Example usage in the action component of your plugin:
PLUGIN_DW2PDF_REPLACE
event, one called before and the other after the event.$event->data['replace']
$event->data['content']