Request: DomPDF update to latest version

sunnyjey

Active Member
@cheesegrits & @troester

If possible, please update DomPDF to the latest stable version. Fabrik is using 2 years old Library "dompdf/dompdf": "~v0.8.2" as per this composer file.

Since then domPDF has released 4 versions, the latest being version 0.8.6 released last month. New releases have improved compatibility with the PHP V7.3 and also have multiple new useful additions like digital signature, Acroform and PDF attachment functions. More info HERE

Thank you in advance.
 
Feel free to replace your ./libraries\fabrik\vendor\dompdf\dompdf with their latest version and test if it's working.
 
I just downloaded dompdf files from github and replaced all existing files ( ./libraries\fabrik\vendor\dompdf\dompdf ) with the help of FileZilla, but now getting following error when I try to access PDF:

Code:
Error: Class 'Dompdf\Cpdf' not found: Class 'Dompdf\Cpdf' not found

Screenshot 2020-10-17 at 10.57.10 PM.png

Tried twice, but same error. Can you please try at your end.
 
I spent good amount of time trying to upgrade the dompdf. The upgrade from ~v0.8.2 to ~v0.8.3 by replacing the files in fabrik library folder works without any issues.

But, when you try to upgrade to any of higher version, dompdf shows Error: Class 'Dompdf\Cpdf' not found in the frontend. I have googled for this error and but could not found any solution. The latest version of dompdf provides Acroform fillable input fields.
 
It seems the autoloader is missing.
It's working if explicitly doing
require_once JPATH_SITE .'/libraries/fabrik/vendor/dompdf/dompdf/autoload.inc.php';
in
libraries\fabrik\fabrik\Helpers\Pdf.php in iniDomPdf (around line 131)

But I don't know why. Looking at their README there's no change in initialiasing, already v0.8.2 has the file autoload.inc.php and it has to be loaded to run the Pdf.
So where is/was Fabrik doing it in v0.8.2?
 
After about a year I did a Github Fabrik Update on a test-site.
dompdf now shows version 0.8.6.
Had to find out that images in my PDF's are now really tiny. A hardcoded company logo as well as fileupload images are now shown smaller than thumbnail.
upload_2021-5-27_22-16-8.png
@sunnyjey You don't have problems with images in PDF's?
Debug PDF shows the images in correct size.
Production site still works with updates from Mar-15th 2020.
dompdf version is shown as <75f13c70>
 
I can see these mini images, too.
It's ok with mPDF, so domPDF seems to miss something.

The image size is ok (in details PDF) if you set "PDF Bootstrap"=no in form [Layout] settings.

But I assume then some other CSS may be missing.
So we have to find which CSS rule must be added to get the image size correctly in DomPDF...

Edit:
For fileupload images:
Modify (or override) plugins\fabrik_element\fileupload\layouts\fabrik-element-fileupload-image.php, line 5 (set style= instead of HTML4 height=)
$height = empty($d->height) ? '' : ' style="height:' . $d->height . 'px;width:auto;" ';

How did insert your hardcoded logo? Maybe setting style instead of height/width will help, too.
 
Last edited:
[USER=51711 said:
@sunnyjey[/USER] You don't have problems with images in PDF's?
Debug PDF shows the images in correct size.
Production site still works with updates from Mar-15th 2020.
dompdf version is shown as <75f13c70>

Yes. I am too facing issue of tiny image size in PDF.

Please add image style directly into your bootstrap.php or custom template of detail view php. This will solve the issue.
Code:
<style>
     img { width: 150px; }
</style>

Somehow img styling through custom.css is not working.

Other issues about domPDF:

1. base64 Image : As per domPDF documentation, temporary folder has to define in the component (Fabrik) beforeLoad to render css / font files. Not sure, but it looks temporary folder is not defined. I am facing major issue of displaying base64 images of Google Graphs in PDF.

2. {PAGE_COUNT} : Fabrik displays Page Number {PAGE_NUM} using <span class="pagenum">Page </span>, but it doesn't display Total Number of pages in PDF.

I have searched a lot, but couldn't find the solution to display Page count.

3. PDF Cache : If you do some edit in the form, the detail view shows Updated data, BUT domPDF in fabrik shows cached / non-updated data.
 
Last edited:
I made the change that @troester recommended and the fileupload images in pdf looked good.
However the mini-images in the listbox were distorted. Height was incorrectly Thumbnail size (200px as set in the element with create thumbnail=yes) but width was as small as before (eg.42px).
I finally ended up to change line 5 in fabrik-element-fileupload-image.php to
PHP:
$height =  'style="height:auto;width:auto;" ';
From my point of view, images look good in list view, form view, detail view and PDF (which uses detail view).
I also set the logo style in default.php of my pdf to
HTML:
style="height:auto;width:auto;"
as well.
Logo looks OK as well.

The three dompdf issues that @sunnyjey listed don't seem to hit me.
1. only use my own images in pdf, no google graphs
2. I played a bit with counter(pages) but didn't achieve anything. My PDF's are only 2 pages all the time so ...
3. potentially could hit my user (wife) but no complaints so far.
 
3. PDF Cache : If you do some edit in the form, the detail view shows Updated data, BUT domPDF in fabrik shows cached / non-updated data.
Do you mean a PDF button in the form? This doesn't make sense because the PDF is loading the details view and before you've saved your form the details view contains the original data.
 
Ha, I managed to display the total pages.
1. You must hack libraries\fabrik\fabrik\Helpers\Pdf.php - function iniDomPdf: around line 140 add $options->set("isPhpEnabled", true);

2. In your custom PDF list template's default.php (with some fixed header/footer) add e.g.
Code:
<div id="footdompdf">
 <script type="text/php">
      if ( isset($pdf) ) {
            $font = $fontMetrics->get_font("Arial, Helvetica, sans-serif", "normal");
            $size = 12;
            $pageText = $PAGE_NUM . "of" . $PAGE_COUNT;
            $y = $pdf->get_height() - 24;
            $x = $pdf->get_width() - 15 - $fontMetrics->get_text_width($pageText, $font, $size);
            $pdf->text($x,$y, $pageText, $font, $size);
      }
</script>
This will output "2 of 10" at the absolute position set by $x, $y.
It doesn't matter if you put it in the header or footer, as far as I understand it must be only inside a div that is displayed on every page.

Maybe we can add a textfield for additional PDF options in list layout settings.

@sunnyjey :
In iniDomPdf a 'tempDir' option is set to Joomla's tmp_path.
Maybe there's some other (new?) option missing.
 
Do you mean a PDF button in the form? This doesn't make sense because the PDF is loading the details view and before you've saved your form the details view contains the original data.

No. Through URL.

I managed to display the total pages.

Thank you so much for taking your time and finding hackable solution for Total page. It would be wonderful, it this is possible without hacking the file. Maybe @cheesegrits should add additional PDF option.

In iniDomPdf a 'tempDir' option is set to Joomla's tmp_path.

No idea. To display base64 images of Google Graphs in PDF, I am currently converting base64 image to png using PHP codes and then storing temp folder and using this url to display graphs in PDF. I have checked with mPDF, base64 images are nicely displayed in the PDF, but due to multiple reasons I cannot use mPDF.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top