Create PDF with TCPDF Export, attach to email, then delete

gatekeepa123 22 May, 2022
Hey there

recently updated our site to Joomla 4 and now I'm rebuilding the all the forms with Chronoforms 7.

The pdf files are created on the server and look okay. However, I cant get it to work, so that the created pdf is attached to a following email.I tried to add {var:tcpdf_3} or {var.tcpdf_3.path} to the email action at "Advanced settings" / "Attachments", but only get a blank page after submitting.
Extra question: How can I automatically delete the created pdf file, after it has been sent.

Thank you very much in advance,

Marc
gatekeepa123 22 May, 2022
Array
(
    [end_page_upload] => Array
        (
            [path] => /.../grusskarten/
            [var] => Array
                (
                )

        )

    [end_page_validation] => Array
        (
            [log] => Automatic validation enabled.
            [var] => true
        )

    [tcpdf_3] => Array
        (
            [path] => /.../images/grusskarten-tcpdf/grusskarte.pdf
            [var] => Array
                (
                    [path] => /.../images/grusskarten-tcpdf/grusskarte.pdf
                )

        )

    [email_12] => Array
        (
            [recipients] => Array
                (
                    [0] => info@xxxx.de
                )

            [subject] => Test
            [body] => <h1>Grußkarte</h1>
Sehr geehrte Damen und Herren,<br/><br/>
es wurde eine neue Grußkarte erstellt.
<h2>Informationen</h2>
<table>
<tr><td><strong>Name VersenderIn:</strong><br/><br/></td><td>Test<br/><br/></td></tr>
</table>
<hr/>
<br/><br/>
<table>
<tr><td><strong>Name EmpfängerIn:</strong><br/><br/></td><td>TestTest<br/><br/></td></tr>
<tr><td><strong>Station und Zimmernummer:</strong><br/><br/></td><td>TestTestTest<br/><br/></td></tr>
</table>
Nachricht<br/>
TestTestTestTestTestTestTestTestTestTest<br/><br/>
#1: {"path":"\/...\/images\/grusskarten-tcpdf\/grusskarte.pdf"}
#3: /.../images/grusskarten-tcpdf/grusskarte.pdf
<hr/>

            [from_name] => xxx
            [from_email] => xxx@xxx.com
            [reply_name] => Super User
            [reply_email] => xxx@xxx.com
            [result] => the Mail sent successfully.
            [var] => true
        )

)
GreyHead 23 May, 2022
HI Marc,

I'm not very familiar with CFv7 but will try to help you here.

You don't have anything in the Email Attachments settings. Please see this old CFv4 FAQ which should give you the basic idea.

The simplest way to do the housekeeping and delete old files is to set up a Cron Job on your site and have that run a form every day , or every few hours. In the form add Custom PHP that checks the contents of the uploads folder and deletes all files more that say, one hour old.

Bob
gatekeepa123 24 May, 2022
Hey Bob,

as always: Thank you for taking your time to try to support me.

If you would look at my screenshots: So far I dont use an "Upload"-action, but only a "TCPDF Export"-action "Store" named "tcpdf_3".
In CF6 I had the option to add "{var:tcpdf_3}" in the E-Mail action in the field "Attachment list" and it worked. IN CF7 i tried the same by adding "Attachments" / "Add new attachment" and put "{var:tcpdf_3}" or {var:tcpdf_3.path} in the field "File Path on Server", but it wont work: I only get a blank page after submitting the form.

By the way: If i put {var:tcpdf_3.path} in the E-Mail body, the generated E-Mail shows the complete path correctly.

Do you think I need a file upload action after the tcpdf-action first? Because your link points in that direction...

There is no manual for CF7 yet, right?
gatekeepa123 24 May, 2022
Update:

If I manually enter a 100kb pdf file on the server in "Attachments" in the E-Mail-action, it works. If I try to attach the tcpdf-generated file I get a blank page. There is no error message tho😟

Could it be the file size?
GreyHead 25 May, 2022
Hi Marc,

I doubt it's the file size if it's generated from the form data. But you can check the size by looking at the saved pdf; and double check by attaching that manually.

If you turn the debugger on you will hopefully get some more useful info about what is happening.

Bob
You need to login to be able to post a reply.

VPS & Email Hosting 20% discount
hostinger