DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:dw2pdf:pagetool

dw2pdf plugin

Export button in Page Tools

Depending on the wiki template and the dw2pdf configuration settings you will see a button (or link) that allows you to export the current page.

This button uses the do=export_pdf URL parameter for exporting a single page.

Example: DokuWiki template

Since 2013-12-08 Binky release this plugin automatically adds the export button to the page tools of the DokuWiki template and some other templates. When required, you can disable it via the Configuration Manager.

How-to auto-add export button in your template

Since 2017:

If your template uses the new menus (since 2017), which triggers MENU_ITEMS_ASSEMBLY event, then in your menu's the pdf-export button will appear automatically, without any extra styling work.

Before 2017:

When your template has implemented the trigger for the TEMPLATE_PAGETOOLS_DISPLAY event the dw2pdf plugin can extend your templates pagetools.

In the addbutton() method of action.php a case should be added for the template, with the html of your button. Depending on the layout of your template, you might like to improve the style.css and the button images as well.

Other, or previous generation, pagetools instructions

'Default' template

Use the following to add another button in the upper or bottom button row of the default template1)

<form class="button" method="get" action="<?php wl($ID)?>">
  <div class="no">
    <input type="submit" value="Export to PDF" class="button" />
    <input type="hidden" name="do" value="export_pdf" />
    <input type="hidden" name="rev" value="<?php global $REV; echo $REV?>" />
    <input type="hidden" name="id" value="<?php echo $ID?>" />
  </div>
</form>

Or use this for a simple 16×16 icon somewhere in your template:

  <a href="<?php global $REV,$ID; echo exportlink($ID, 'pdf', "rev=$REV")?>">
    <img src="<?php echo DOKU_BASE?>lib/images/fileicons/pdf.png" alt="PDF Export" />
  </a>

You can mix the 2 previous methods, and get a button with an image inside, with this code:

<form class="button" method="get" action="<?php wl($ID)?>">
  <div class="no">
    <button type="submit" class="button">
      <img src="<?php echo DOKU_BASE?>lib/images/fileicons/pdf.png" alt="PDF Export" />
      Export to PDF
    </button>
    <input type="hidden" name="do" value="export_pdf" />
    <input type="hidden" name="rev" value="<?php global $REV; echo $REV?>" />
    <input type="hidden" name="id" value="<?php echo $ID?>" />
  </div>
</form>

Monobook Template

When using the template “monobook for DokuWiki”, to have an Export PDF tab, in /user/tabs.php, use this code

//PDF plugin: export tab
if (file_exists(DOKU_PLUGIN."dw2pdf/action.php") &&
    !plugin_isdisabled("dw2pdf")){
    $_monobook_tabs["tab-export-pdf"]["text"] = $lang["monobook_tab_exportpdf"];
    $_monobook_tabs["tab-export-pdf"]["href"] = wl(getID(), array("do" => "export_pdf"), false, "&");
}

Add translation to file /lib/tpl/monobook/lang/en/lang.php

$lang["monobook_tab_exportpdf"] = "Export as PDF";

Typo Template

When using the typo template, add this code in lib/tpl/typo/tpl_functions.php just before print ' </ul>' . DOKU_LF;

print '<li>'.tpl_link(wl($ID,'do=export_pdf'), 'Export PDF', 'class="action export_pdf" rel="nofollow"',1).'</li>'.DOKU_LF
1)
In /lib/tpl/default/main.php, there are two divs that contain some buttons: <div class="bar" id="bar__top"> and <div class="bar" id="bar__bottom">. Just insert the HTML code inside one of the two divs (left or right)
plugin/dw2pdf/pagetool.txt · Last modified: 2017-11-19 23:26 by Klap-in