AlexTCGPro
Member
Hey!
I'm using TCPDF to generate some on-the-fly PDF files.
I have put the PHP code in a calc element to take advantage of the placeholders of other elements and such. When the calc element is set to calc on load, it works perfectly, however, as none of the other elements have been filled yet that data remains blank.
So, I set the code to run whenever a checkbox element gets set, as to manually run the code after the form has been filled, however, it doesn't work, it outputs garbage data.
Could you give me a hand?
Here's the code I'm using
That should generate the PDF file when the checkbox is set to 1, however it just outputs garbage data, I'm guessing is not executing the 'ob_end_clean()' command.
Removing the 'if' and setting the element to calc on load makes the code work, but I want to generate it on demand, not just on load
I'm using TCPDF to generate some on-the-fly PDF files.
I have put the PHP code in a calc element to take advantage of the placeholders of other elements and such. When the calc element is set to calc on load, it works perfectly, however, as none of the other elements have been filled yet that data remains blank.
So, I set the code to run whenever a checkbox element gets set, as to manually run the code after the form has been filled, however, it doesn't work, it outputs garbage data.
Could you give me a hand?
Here's the code I'm using
Code:
require_once JPATH_SITE . '/tcpdf/tcpdf.php';
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
$pdf->SetFont('helvetica', '', 9);
if ('{pdf_gen___generate_raw}' == 1) {
$pdf->AddPage();
$content = array();
$content[] = '<html>';
$content[] = 'Test' . '{pdf_gen___input1_raw}';
$content[] = '</html>';
$pdf->writeHTML(implode($content), true, 0, true, 0);
$pdf->lastPage();
ob_end_clean();
$pdf->Output('test.pdf', 'D');
}
Code:
https://pastebin.com/2AbmwtKt
Last edited: