pdf_report as attachment

I’m totally stucked. :frowning:

I have a form, and I want on Update, to create a pdf and send it as attachment.

1.- I try with sc_set_pdf_name but this macro works on Grids only.
2.- I have a PDF_Report application, but i can’t be able to locate the file on the _lib folder.

I really need help on this.

okay, i am no expert but i found something in the code says send email with attachment, and i guess you already know the sc_set_pdf_name known!?

just thought

Thanks for the response.

Maybe I’m missing something, but the macro sc_set_pdf_name works on Grid only. So, in a Form the macro does not work. When the macro sc_set_pdf_name = “sc_my_new_file.pdf”; is included OnScriptInit, the form crashes.

Some help will very appreciated.

sorry, not that expert really, i know form is less that grid supported in macros, guys over here (aducom, jsb, giu and other other) helped me a lot with these limiation by creating workarounds and java solutions… but still scriptcase form support is not much as grid… there is version 8 coming soon, i am optimistic somehow, lets see.

After several attempts, I found a solution, maybe isn’t the best way but definitely works.

This is a two step procedure:
1.- In PDFreport app, In LayoutPDF>code add sc_pdf_output(“test.pdf”,“F”); on very bottom. This will store a pdf file on the app folder.
2.- In Events>OnScriptInit add Send an email with attachment script from Scriptcase example libraries. setting ‘test.pdf’ on mail attachment array.

Thats it. when the PDFreport app is loaded, the file is created and the mail is shooted.

Hope this works for you.

thank you for sharing this, i am sure it will help many others as well :slight_smile:


[QUOTE=itsme3;24397]thank you for sharing this, i am sure it will help many others as well :slight_smile:


I missed this one obviously. For a lot of reasons I sometimes need to create a pdf from html. That goes horrible with FPDF, but well with TCPDF. Then you have a physical pdf file in hand. Above solution apply but you can also put it on the form etc. You can upload TCPDF somewhere in your root and create an include for that.

Thanks aducom
Can you explain a little more how integrate the TCPDF?
Any input is well received.

Hi Albert, could u provide an example? We all hunger for the solution :slight_smile:

Thank you for the solution, i have initiated this method however substitute the email to field with the customer email variable, however it seems to send the attachment located in the path indicated and then generates a new pdf after that, so its sending the previous runs attachment, can you maybe think of why its doing that or how I can attempt to repair it? the sc_sendmail is on record event, wont seem to run on scriptinit.

what is the name of your pdf generated? In order to send the new pdf (not previous) the files has to have a unique name.