Generating PDF's from form submissions
This document describes how to set up the PDF plugin to use HTML from the current page. Demo
Module Setup
RsForm - Thank You message
Form Properties ⇾ Form Info ⇾ Edit the Thank You Message
note the id=thankyou.
<div id="thankyou">
<h2>{FullName:value}</h2>
<p>{whats-up:value}</p>
</div>
<p>Thank-you for your submission. You can save it as PDF using the button below.</p>
<p> </p>
RsForm Override
Finally, you will need an override.
Create or edit: [ROOT]/templates/<template>/com_rsform/rsform/default.php
<?php
defined('_JEXEC') or die('Restricted access');
$session = JFactory::getSession();
$formparams = $session->get('com_rsform.formparams.formId' . $this->formId);
?>
<?php if ($this->params->get('show_page_heading', 0)) { ?>
<h1><?php echo $this->escape($this->params->get('page_heading')); ?></h1>
<?php } ?>
<?php echo RSFormProHelper::displayForm($this->formId); ?>
<?php
if ($formparams && !empty($formparams->formProcessed)) {
echo Joomla\CMS\HTML\HTMLHelper::_('content.prepare', '{loadmoduleid <module id>}');
}
Alternative method
Another method would be to include the PDF button directly into the thank-you message without using an override for RsForm but using an override for the mod_c2pdf.
First step would be to add {loadmoduleid <module id>}
to your thank-you message
Then in Script called after form has been processed
$thankYouMessage = Joomla\CMS\HTML\HTMLHelper::_('content.prepare', $thankYouMessage);
Finally, you will need an override for _section.php replacing the addInlineScript
with an echo
(see _section.php)