splitbrain / dokuwiki-plugin-dw2pdf

A fork of Luigi Micco's PDF export plugin for DokuWiki
http://www.dokuwiki.org/plugin:dw2pdf
55 stars 68 forks source link

Numbered headings possible #360

Closed whnr closed 1 year ago

whnr commented 5 years ago

Hi! I tried to use the numbered headings through css: https://www.dokuwiki.org/tips:numbered_headings . They work as expected on pages and show up as well in the &debughtml=html. However it's not working in the exported pdf. I guess it is mPDF missing counter, :before and :after? Any idea how to get those in the PDF? ––Florian

ruud12 commented 5 years ago

Hello, in case you are still interested i had the same issue and changed the renderer.php, see https://github.com/ruud12/dokuwiki-plugin-dw2pdf/blob/master/renderer.php. I changed the "public function header() {}" code

vincowl commented 5 years ago

@ruud12 I can't reproduce a PDF generation with numbered headings using your modified renderer.php. I am using bootstrap3 theme and managed to have headings numbered through modified CSS files. Numbered headings are displayed correctly in HTML wiki display and in printable version (through Ctrl+P), but headings are no more numbered as soon as I am using dw2pdf features. Any idea ?

vincowl commented 5 years ago

@ruud12 It finally works. I simply had forgotten to clear the cache through a touch conf/local.php. Great job. I am now having a look at how to make it configurable through an option in the plugin's configuration manager. Thanks !

vincowl commented 5 years ago

OK. It works. I am submitting this as a PR (cf PR #410)

ruud12 commented 5 years ago

@vincowl: Good to hear that it works. Thanks for the improvements and PR, I have been a bit lazy in not improving the code to make it a config option in DW.

vincowl commented 4 years ago

@ruud12 I am facing troubles with PDF headers numbering. I want to numberize h1 levels too. I changed two lines from renderer.php :

if ($isnumberedheadings) {
    if ($level > 1) {

to

if ($isnumberedheadings) {
    if ($level > 0) {

and

for ($i=2; $i<=$level; $i++) {
    $header_prefix .= $this->header_count[$i].".";
}

to

for ($i=1; $i<=$level; $i++) {
    $header_prefix .= $this->header_count[$i].".";
}

That works perfectly when I want to render a single PDF. But when I try to generate a PDF book via bookcreator, h1 levels are all numbered with a 1 and not 1, 2, 3, ... Do you know how dw2pdf works under the hood ? I mean, does it parses the whole dokuwiki code to html and then to PDF through MPDF, or does it apply this workflow to each page and 'merges' produced PDFs ? Or is the renderer rebuilt at each page generation (this would reset the counter to 0) ?

Plus : do you have an idea how to debug this ? I can't manage how to do it with bookcreator

ruud12 commented 4 years ago

@vincowl: Unfortunately I don't have much experience with the bookcreator plugin. I use the include plugin to create product manuals (you could call it books). The manuals are 50+ pages and it works fine for the company I work. In the beginning I tried using the bookcreator plugin, but as I use a lot of nested included pages to keep everything as dynamic as possible it became unusable with bookcreator. Also the large number of to be included pages and header level was not easy to manage for me in bookcreator. I would suggest trying the include plugin to create a "book". So you will basically have one large page which is the entire book. Then the headers will also work fine.

I suppose bookcreator gathers all pages and processes them one by one, but i'm not sure. Maybe it is possible to use a global php variable for the level counters instead of the current ones that are only valid within the class. Probably bookcreator calls the renderer several times and thus the counters start at zero again.

For debugging I just use the "&do=export_xhtml" method instead of "&do=export_pdf" (like the pdf export button). The displayed html is used for the mpdf generator.

vincowl commented 4 years ago

@ruud12 Thanks ! I improved dw2pdf plugin using static properties. I was also looking at the "include" solution, but right now, my books doesn't have a so much complex structure, but it surely will !! Cf 069f0c9