Caldera form pdf file
Install Run Action addon then add a action on process
as shown in fig:
Install dompdf (open source) which using composer inside you theme folder
Using this command
Composer require dompdf
Than add the following code to yours functions.php file
require_once '/vendor/autoload.php';
use Dompdf\Dompdf;
add_action('create_pdf','create_pdf_fun');
function create_pdf_fun($data)
{
$html = 'First Name:'.$data['first_name'].'<br>
Last Name:'.$data['last_name'].'<br>
Email:'.$data['email_address'].'<br>
message:'.$data['message'].'<br>
Question:'.$data['comments_questions'];
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$output = $dompdf->output();
$subdir = wp_get_upload_dir();
$upload_path = 'wp-content/uploads'.$subdir['subdir'].'/'.rand(1,2000).'test.pdf';
file_put_contents($upload_path, $output);
}
use Dompdf\Dompdf;
add_action('create_pdf','create_pdf_fun');
function create_pdf_fun($data)
{
$html = 'First Name:'.$data['first_name'].'<br>
Last Name:'.$data['last_name'].'<br>
Email:'.$data['email_address'].'<br>
message:'.$data['message'].'<br>
Question:'.$data['comments_questions'];
// instantiate and use the dompdf class
$dompdf = new Dompdf();
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$output = $dompdf->output();
$subdir = wp_get_upload_dir();
$upload_path = 'wp-content/uploads'.$subdir['subdir'].'/'.rand(1,2000).'test.pdf';
file_put_contents($upload_path, $output);
}
Thank you for giving your time!
Nice
ReplyDeleteNice article. Please check What is WordPress functions.php?
ReplyDelete