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

"Undefined array key" error message when exporting page with interwiki links #474

Closed eduardomozart closed 1 year ago

eduardomozart commented 1 year ago

Hello, When trying to generate a PDF using DW2PDF, I'm receiving the following error message:

Warning: Undefined array key 1 in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 8580

Warning: Trying to access array offset on value of type null in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 8580

Warning: Undefined array key 0 in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 6947

Warning: Trying to access array offset on value of type null in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 6947

Warning: Undefined array key 1 in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 8580

Warning: Trying to access array offset on value of type null in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 8580

Warning: Undefined array key 4 in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 8580

Warning: Trying to access array offset on value of type null in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 8580

Warning: Undefined array key 1 in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 6947

Warning: Trying to access array offset on value of type null in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 6947

Warning: Undefined array key 1 in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 6947

Warning: Trying to access array offset on value of type null in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 6947

Warning: Undefined array key 1 in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 6947

Warning: Trying to access array offset on value of type null in /home/robertinho/public_html/wiki/lib/plugins/dw2pdf/vendor/mpdf/mpdf/src/Mpdf.php on line 6947

The README.md file from DW2PDF states that mPDF is compatible up to PHP 7.4, but the mPDF itself already supports PHP 8.

I'm running DokuWiki Release 2022-07-31a "Igor" (stable) with PHP 8.1.

I'm attaching the markdown page (DokuWiki syntax) and the HTML page generated by the plugin as I was able to find the HTML into the data/cache folder.

start_dw2pdf_html.txt start_markdown_dw.txt

For me, this issue seems to be related with the number of images associated with the page. There is the interlink img tags and the number of errors seems to be twice as the number of images into the page (removing the img tag from the HTML file and trying to reparse it again decreases the number of errors).

eduardomozart commented 1 year ago

I'd tried to upgrade mPDF to 8.1.4 (#476) but this didn't seem to fix the issue.

Klap-in commented 1 year ago

If you can trace in the html (e.g. the big chunck of html can be retrieved with https://www.dokuwiki.org/plugin:dw2pdf#how_to_collect_more_debug_info) which specific part triggers the warnings, you could file these warnings as issue to the upstream mpdf library. Please note that filing these issues without small html examples to upstream library is not accepted there, on the other hand, with good examples they are often very helpful.

eduardomozart commented 1 year ago

Thank you @Klap-in, In fact, I was able to reproduce the issue when loading the HTML file directly into the mPDF engine and it seems to be related to the value of the vertical-align CSS property for interwiki links, as "center" didn't exist as a value for this CSS property. I'd created the PR #477 that fixes this issue.