Closed whnr closed 1 year 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
@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 ?
@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 !
OK. It works. I am submitting this as a PR (cf PR #410)
@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.
@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
@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.
@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
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 missingcounter
,:before
and:after
? Any idea how to get those in the PDF? ––Florian