Indice

dw2pdf plugin

For plugin developers, who want to export to PDF

If you're a plugin developer and want to make your syntax plugin compatible with the PDF export, here are a few tips:

Custom HTML for PDF export

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;
}

Fetch images without HTTP request

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:

Use custom placeholders in HTML templates

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: