CalcBuilder Forum

Do you support plugins to extend or integrate with Calcbuilder?

User TheFencepedia 2025-04-17 18:09:51

Hi,

Do you have any plugin event to listen to after generating the PDF file?

I want to keep track of the calculator submitted data along with the PDF generated file, so I think of saving them in a separate database table but I can't find out where to add this code snippet provided that the field names are the real field names from the calculator configuration, not in the field_1234 format. I mean I need to know which field is project name, client name, etc.. and there are many calculators their so it would be easier to deal with the field with the readable names I have entered in the calculator configuration.

Thanks for your help.

Moonsoft support 2025-04-20 09:27:34

Hi,
the calculator doesn't throw any 'event' after getting the results, but if you want to add any additional process you can introduce your code at the end of the php section of the calculator. At that point, you have available the same 'user friendly' variable names you have configured for each field. so you can store them or process them as required.

Hope this helps, regards
Silvia Martín
Moonsoft Team

User TheFencepedia 2025-04-21 05:56:10

Thank you so much.

Is it possible to generate a PDF version of the results in the PHP section?
If yes, please provide a code sample I can use to get get the PDF file path.

Thanks!

Moonsoft support 2025-04-22 16:21:25

Hi,
yes, you can introduce any valid php code there, so using the mpdf library that is included in the extension, you could do something like:

$_content_pdf="My content";
require_once(JPATH_COMPONENT . "/Library/vendor/autoload.php");
$_mpdf = new \Mpdf\Mpdf();
$_mpdf->WriteHTML($_content_pdf);
$filename = rand(1000, 9000) . "_cb.pdf";
$pdf_path = JPATH_ROOT . $_solution->save_pdf_folder . DIRECTORY_SEPARATOR . $filename;
$_mpdf->Output($pdf_path, 'F');


and set/get the location of the file at $pdf_path. The content of the pdf can be valid html, here the official docs of the library in case you need more details:

https://mpdf.github.io/reference/mpdf-functions/writehtml.html

Hope this helps, regards
Silvia Martín
Moonsoft Team

...
Support/development

Perfect for small code changes or to correct any bug at your site

Buy now!
...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!