Dompdf output rendering

ontarget

Active Member
Hi i have a standard template for pdf output i have used on loads of projects - see below:
However i just updated to j385 and Fabrik 381 and the output on the pdf ignores <br> <p> tags leaving a squashed looking output! Any ideas why. Thanks

PHP:
<?php
/**
* Bootstrap List Template - Default
*
* @package     Joomla
* @subpackage  Fabrik
* @copyright   Copyright (C) 2005-2013 fabrikar.com - All rights reserved.
* @license     GNU/GPL http://www.gnu.org/copyleft/gpl.html
* @since       3.1
*/

// No direct access
defined('_JEXEC') or die('Restricted access');

$pageClass = $this->params->get('pageclass_sfx', '');

// Hannes

echo "<img src='logo.png' /><br/>";
echo "<h1>CPD Course Attendance Certificate </h1>";
echo $this->newv;  // Get var from view


foreach ($this->rows as $group) {
    // print_r($group);
    echo "<br />";
    echo '<h2>' . $group[0]->data->aed_reg_list2___first_name_raw." ";
    echo $group[0]->data->aed_reg_list2___last_name_raw."<br />";
    echo "Teaching Council Number: ".$group[0]->data->aed_reg_list2___school_tn_raw . '</h2>';
    echo "<br />";
    echo "<p><strong>COURSE:</strong> ".$group[0]->data->aed_reg_list2___course_title_raw."</p>";
    echo "<p><strong>DATE:</strong> ".$group[0]->data->aed_reg_list2___course_date_raw."</p>";
    echo "<p><strong>HOURS:</strong> ".$group[0]->data->aed_reg_list2___hours_raw."</p>";
    echo "<p><strong>STATUS:</strong> ".$group[0]->data->aed_reg_list2___attended."</p>";
}




?>
 

Attachments

  • Drumcondra Education Centre Course booking system (4).pdf
    16.2 KB · Views: 27
Yes i downloaded from git then unzipped the archive in root directory of joomla.
Previous fabrik version was 3.7
 
I just downloaded the latest libraries from git and unzipped it in my root.
With Fabrik debugPDF on the html output looks fine but I still had the same issue with incorrect rendering.
To fix the issue i took a known good system - zipped all the directories and files except for joomla images / templates / configuration.php
I then unpacked this version over the system with the pdf issues and the pdf output works. Sorry that i can't help identify the file it was probably something not being updated
 
Hi Hugh
I had pretty much a duplicate site (just different templates) which was running j385 and F3.8.1. For this site the pdf rendering was working.
 
I just downloaded the latest libraries from git and unzipped it in my root.
Only libraries?
Can you try a complete GitHub update?

On the "failing" site: Did you first update Fabrik (on Joomla 3.7.x) and then Joomla? (Then some files are not copied because Joomla3.8 folders are missing)
Can you try a complete GitHub update?
 
Hi Troester
I initially did a full git update for f381 on this site - downloading and unzipping it to my root dir. I checked the joomla backend went through the discover process etc and all fabrik plugins etc were updated to 381.
Hugh asked had i updated the libraries - so to be sure i downloaded the libraries again from git and uploaded them. Same result on the pdf.
Client is putting me under pressure so i just replaced the files (except for template and images dir and configuration.php) with a duplicate site running j385 and f381 and the pdf rendering worked.
I am happy to give you ftp acces if you want to check anything
 
Only libraries?
Can you try a complete GitHub update?

On the "failing" site: Did you first update Fabrik (on Joomla 3.7.x) and then Joomla? (Then some files are not copied because Joomla3.8 folders are missing)
Can you try a complete GitHub update?

I updated joomla first to j385 from j375 then I updated fabrik to 3.8.1 - I always do it this way.
 
hmm
I tried "your" code on my test site, PDF is ok.

If you were running Fabrik3.7 with PDF you had a GitHub version.
If updating via Joomla you must additionally install the Fabrik library to get the new domPDF stuff (or update from GitHub again).
 
Thanks Troester - yes i always update from git so i know the pdf library was present. The pdf was working to a degree but the layout looked funny see my first attachment.
I am working on another dev site with a pdf output so if i encounter the issue again i will let you know. Thanks for al the help
 
I think I have the same/similar problem.

I did an update using Joomla update from to 3.8.5. I'd have to look to see what I updated from (I took a backup and will install it and see) but I think it was 3.8.x something.
The system is supposed to render a pdf and attach it to an email.

My PDF attached to an email is now not working in two ways.
- The file name is not correct.
- The content, specifically the part rendered from the repeated group using {content} and a plugin is not working.

For example.
A working one will have the file name
Colorado Rate Resource Form 2017-2020-xxx.pdf
where xxx is a record number.

The current one is named
-xxx.pdf
All the first part of the name is blank.

I'm pretty sure this one had been installed from a full git, but I tried installing Fabrik Library just in case.

No Joy.

I'll install the version before the update tomorrow and provide validation that it works, and clarification on what version that it was.

But - if any of this rings a bell......

Bob
 
Sounds like a different issue.

Do you use a layout override for the name? The fabrik-pdf-title.php one.

-- hugh
 
Morning update,

I installed the backup that I took prior to the last upgrade.
In that system it works fine. The pdf created for mail is rendered correctly and the file has the appropriate name so this is clearly and update issue.

The working site is:
Joomla 3.8.2
Fabrik 3.8
Fabrik Library 3.7
(also Module tag-cloud is 3.1 and fabrik package is 3.5.1)

The non-working site is:
Joomla 3.8.5
Fabrik 3.8.1
Fabrik Library 3.8.1
(Module tag-cloud 3.1, package 3.5.1)

What do you suggest.
I need to get the live site working - for now I may move back to the previous work version, but unfortunately there have been user changes so that is problematic. I'll have to look at the databases to see if I can update to retain users data.
 
Updated the working site to Joomla 3.8.5.
Still works. Now to see if I can make Fabrik 3.8.1 work
I see in the changes for 3.8.1 it says "Updated DOMPDF to latest Composer library version"

I'm using some custom template stuff - does this break that?
I can't find any real description on what that means.

--------
Proceeding - did the joomla update of Fabrik.
it broke.
Now I'll do the githup update.
 
Last edited:
Well - crap.

Did the github update and the system remains broken. Sigh..

Behaviour of the system.
- Upon submit of the record
- Generate an email and attach a pdf.
- The pdf file name is not generated correctly. Has only -xxx.pdf where -xxx is the record number. The pre-naming convention is bad
- The pdf file is no longer formatted correctly.
- The repeated group is no longer formatted correctly.

I suspect I had done some customization to the pdf generation code because it was a real struggle to get it working 1.5 years ago. I tracked changed files, but I suspect I missed one and overwrote with something.

The question is - is it better to try to roll back or fix it.....
 
Okay - I successfully rolled back the Fabrik update and updated my user data (hopefully!).

I guess I'll hold off on any fabrik updates till I can spend the time to figure out what broke. The site this is on is not long for the world, so maybe it will survive.
 
First off, a reminder that you should never update a "mission critical" live site first, always do an Akeeba archive, install a sandbox, and update that and test that first, especially if you have fairly dynamic user data. Even better, stay involved in Fabrik between releases. Maintain a sandbox of your site, and occasionally do a github update on it and test, so you can raise any potential issues prior to the next release. This is especially true if you have any custom code in the equatiion. I don't mean to sound like I'm lecturing, I'm simply explaining best practices for running mission critical systems on open source software, to avoid this kind of situation.

I see in the changes for 3.8.1 it says "Updated DOMPDF to latest Composer library version"

I'm using some custom template stuff - does this break that?

Potentially, yes.

I can't find any real description on what that means.

It means I updated DOMPDF, the 3rd party library we use for generating PDF (as J! doesn't ship with one), to the latest. The Composer part means that DOMPDF have switched from a static build (which we have to download by hand) to a version integrated with the Composer dependency manager. If you are familiar with Linux package managers (apt-get, yum), think of Composer as a package manager for PHP. Instead of manually downloading libraries, we now just specify them in a config file ...

https://github.com/Fabrik/fabrik/blob/master/libraries/fabrik/composer.json

... and during each Fabrik release cycle, run "composer update" to fetch the latest versions of those packages (subject to the version constraints in the config), and all the packages they in turn depend on.

So the Composer part isn't really significant, it's just the mechanism by which we include 3rd party packages into Fabrik. What is significant is that the latest version of DOMPDF has had some major changes. Most of them are for the good, some of them not so much. The upshot is that DOMPDF on the whole now does a better job of rendering HTML to PDF, but (like any major version update in a large project) introduces new wrinkles.

The other significant change might be, as Troester pointed out, the way we process the HTML before we hand it to DOMPDF. In particular, this may well not be as tolerant about HTML markup problems. It'll have to be valid HTML. Whereas before if you missed out (say) a closing div somewhere, it would probably render. Now it probably won't.

The best way to tell is to set PDF debug mode, and generate the view you are having issues with (in this case it'd be a details view of the form being submitted, so index.php?option=com_fabrik&view=details&formid=X&rowid=Y&format=pdf. In pdf debug mode, that will show you the raw HTML we would otherwise pass to DOMPDF. Go to https://validator.w3.org/ and either enter that URL (if it is publicly accessible), or copy the source from your browser and paste it. You'll get a truck load of warnings (entities and such), but what you are looking for is errors, especially things like missing closing tags, or duplicate IDs.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top