bithost-gmbh / pdfviewhelpers

TYPO3 CMS extension that provides various Fluid ViewHelpers to generate PDF documents.
GNU General Public License v3.0
44 stars 21 forks source link

Since 2.3.2 the PDF template background is above background and borders of pdf:html #165

Closed mxpgmbh closed 4 years ago

mxpgmbh commented 4 years ago

Describe the bug I use a template PDF with some background image (e.g., some circles) and add text with the pdf:htmlViewHelper to it. In the ViewHelper I draw a table (some data points) and define background and borders with CSS (so the table gets more readable).

Since version 2.3.2 of pdfviewhelpers the PDF background gets drawn over the background and borders of the table. The text iteself is in front of the background.

Here a screenshot, how it looks like with the bug:
with_bug

Here a screenshot how it should look like:
without_bug Environment

TYPO3 version(s): 9.5.19 pdfviewhelpers version: >= 2.3.2

Steps to reproduce I can probably provide you with the corresponding PDF and the TypoScript config I use as well as the Fluid Template. I do have to check with our customer first though, if I can give you the data or if I have to annonymize it first.

Expected behavior PDF is created as before, the template PDF ist under the text written on it

Possible solution No idea, I downgraded to 2.3.1 for the moment.

maechler commented 4 years ago

@mxpgmbh Thanks for reporting! That could be related to the FPDI and TCPDF updates done in v2.3.2: https://github.com/bithost-gmbh/pdfviewhelpers/blob/master/CHANGELOG.md#232---june-1-2020

If you could try to downgrade FPDI to v2.2.0 and test it again, that would be great. The source is located in EXT:pdfviewhelpers/Resources/Private/PHP/fpdi/.

FPDI: https://www.setasign.com/products/fpdi/downloads -> older versions

If else you could provide me your template, that would nice as well. You could also send it privately via email: https://www.bithost.ch/unternehmen/

mxpgmbh commented 4 years ago

I sent you an email with an example mini extension demonstrating the bug,

maechler commented 4 years ago

@mxpgmbh It seems to be related to this change: https://github.com/bithost-gmbh/pdfviewhelpers/commit/027163c26336f21562067911d3247144f965c4b6

I will have to further investigate this. You could go back to the previous behaviour by providing your own BasePDF class:

plugin.tx_pdfviewhelpers.settings {
        config {
                class = Vendor\YourExtension\Model\MyPDF
        }
}
<?php
namespace Vendor\YourExtension\Model;

class MyPDF extends \Bithost\Pdfviewhelpers\Model\BasePDF
{
    /**
     * @inheritDoc
     */
    public function renderHeader()
    {
        parent::renderHeader();

        $this->setPageMark();
    }
}

It seems however that this does only work for manual page breaks and not for automatic page breaks.

maechler commented 4 years ago

@mxpgmbh I think I found the correct way to fix this: https://github.com/bithost-gmbh/pdfviewhelpers/commit/9a94a1fc75fe4c379b0ea132864ae6553d908a5d

According to the TCPDF documentation setPageMark() needs to be called after an image is placed in the background to allow the content to be rendered in front of the background:

This function must be called after calling Image() function for a background image.

The same seems to apply if we use a PDF template in the background. I will create a new release this week.

maechler commented 4 years ago

I just released v2.3.4 which fixes this issue. If you like the extension, please consider giving it a star on GitHub :)

mxpgmbh commented 4 years ago

Sorry for the late reply, with work and vacation, I was just now be able to test the new version.

It works now as expected, thanks!