Is there a way to include a field's value in the filename of a PDF saved with the TCPDF plugin? In reading the documentation is sounds like I should be able to put something like this into the Document File Name field in TCPDF but it does not work:
{lastName}_{firstName}-Evaluation.pdf
But if I put that in there I get exactly that with just the field names in curly brackets as the file name. I want it to be Joe_Smith_Evaluation.pdf.
Is there a way to get those values inserted into the filename or am I just doing it wrong?
{lastName}_{firstName}-Evaluation.pdf
But if I put that in there I get exactly that with just the field names in curly brackets as the file name. I want it to be Joe_Smith_Evaluation.pdf.
Is there a way to get those values inserted into the filename or am I just doing it wrong?
Hi everybody,
after examining the current tcpdf action, the solution seems to be far more simpler than described in the mentioned CFv4 post:
Just define in a custom code event (before the tcpdf action) the var
The file administrator/components/com_chronoforms5/chronoforms/actions/tcpdf/tcpdf.php searches for this var. If it is not declared tcpdf creates its own file name according to the general settings (resp. the ones you made in the file name field).
Be aware that if you use several tcpdf actions they now all get the same file name – so either chose different folders in the settings to save them separatedly or define the var anew before starting the second tcpdf action.
Hope this might help anyone else, too.
Regards,
Herbert
after examining the current tcpdf action, the solution seems to be far more simpler than described in the mentioned CFv4 post:
Just define in a custom code event (before the tcpdf action) the var
$form->data['pdf_file_name']
and give it the desired content.
The file administrator/components/com_chronoforms5/chronoforms/actions/tcpdf/tcpdf.php searches for this var. If it is not declared tcpdf creates its own file name according to the general settings (resp. the ones you made in the file name field).
Be aware that if you use several tcpdf actions they now all get the same file name – so either chose different folders in the settings to save them separatedly or define the var anew before starting the second tcpdf action.
Hope this might help anyone else, too.
Regards,
Herbert
Thanks to Herbert for leading me in the right direction.
When you want to use the fields {firstname} and {lastname} and '_whateverelse' to create a filename the code is looking like this.
Then your filename looks like: firstname_lastname_whateverelse.pdf
Great.
When you want to use the fields {firstname} and {lastname} and '_whateverelse' to create a filename the code is looking like this.
<?php
$form->data['pdf_file_name'] = $form->data['firstname'].'_'.$form->data['lastname'].'_whateverelse';
?>
Then your filename looks like: firstname_lastname_whateverelse.pdf
Great.
In addition to my previous reaction I changed the way of saving files to my server.
The newly created files now get a unique name by adding the date and time, otherwise files with the same name will be overwritten.
Output looks like: 2016-07-25_224255_My_Form_Name_firstname_lastname.pdf
The newly created files now get a unique name by adding the date and time, otherwise files with the same name will be overwritten.
<?php
$form->data['pdf_file_name'] = date("Y-m-d_His").'_'.'My_Form_Name'.'_'.$form->data['firstname'].'_'.$form->data['lastname'];
?>
Output looks like: 2016-07-25_224255_My_Form_Name_firstname_lastname.pdf
This topic is locked and no more replies can be posted.