Creating and emailing PDF as attachment

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ewansmac
Posts: 15
Joined: Tue Oct 25, 2011 7:59 am

Creating and emailing PDF as attachment

Post by ewansmac » Wed Jun 10, 2015 1:25 pm

I am trying to create a PDF file and send it as an attachment in an email. The code I have works OK in IOS but when I run it in Android, the email is created minus the attachment.

I am not quite sure if it is creating the PDF attachment and not attaching it or if its not creating the PDF file. Is there any way I can browse and check if the PDF has been created?.

The code created is below:

global gSalesQualifier_PrimaryeMailAddress, gSalesQualifier_SecondaryeMailAddress, gProjectTitle, gEngineerName, gVisitDate, gUUID
## Load location and file name into PDF path variable
put specialfolderPath("documents") & "/SalesQualifierID " & gUUID & ".pdf" into tPDFPath
## Creat PDB file and store in PDF Print location
set the printScale to 0.95
set the printMargins to "0,0,0,0"
set the printPaperSize to "595,842"
open printing to pdf tPDFPath
print card "SalesQualifier_Print"
close printing
## Create email message and attach stored PDF file
put tPDFPath into tAttachment["file"]
put "PDF" into tAttachment["type"]
put "/Sales Qualifier ID " & gUUID & ".pdf" into tAttachment["name"]
mobileComposeMail "Sales Qualifier Report ID: " & gUUID & " - Title: " & gProjectTitle , gSalesQualifier_PrimaryeMailAddress,gSalesQualifier_SecondaryeMailAddress,, "Please find attached a copy of the Sales Qualifier Report, ID: " & gUUID & " for a sales visit dated " & gVisitDate & " relating to enquiry title " & gProjectTitle & " by " & gEngineerName & ".", tAttachment
## Co back to General Details card on completion of email send.
go card "GeneralDetails1"
close this stack

Can anyone point me in the correct direction.

Thanks

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Creating and emailing PDF as attachment

Post by jmburnod » Wed Jun 10, 2015 1:34 pm

Hi,
No experience with androïd but

Code: Select all

put (there is a file tPDFPath)
return true/false on iOS
Best regards
Jean-Marc
https://alternatic.ch

ewansmac
Posts: 15
Joined: Tue Oct 25, 2011 7:59 am

Re: Creating and emailing PDF as attachment

Post by ewansmac » Wed Jun 10, 2015 3:37 pm

Thanks Jean-Marc,

The answer is no using your advice, it would appear that the PDF has not been created.

On further investigation, I have discovered that the command 'open printing to pdf' is not supported in Android, do you have any advice how to create a PDF in Android.

Thanks

Post Reply