Create one PDF
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Create one PDF
Hi,
I was looking at the lessons of LiveCode and i didn't find what i am looking for ( i only found fow to print and how to add bookmarks)...
So, is it possible to create one document PDF and customize it during the execution?
When i say 'Customize' i am thinking in put one logo in one precise place, add text and also create one table (n columns x m rows ) with information to display.
Thanks in advance!!!
Regards,
fko
I was looking at the lessons of LiveCode and i didn't find what i am looking for ( i only found fow to print and how to add bookmarks)...
So, is it possible to create one document PDF and customize it during the execution?
When i say 'Customize' i am thinking in put one logo in one precise place, add text and also create one table (n columns x m rows ) with information to display.
Thanks in advance!!!
Regards,
fko
Re: Create one PDF
You can customize your PDF document as long and as far you can customize.... a card in a stack.
So, change fields content, images and whatever else on a card, and then simply "print" the PDF file.

Code: Select all
ask file "Where to save the document ?" with "mydoc.pdf"
if the result is "cancel" then exit to top
put it&".pdf" into tFile
set the printMargins to 0,0,0,0
open printing to pdf tFile
print this card from 0,0 to 590,940
close printing
Re: Create one PDF
Hi Bangkok,
Thanks for your answer...
I will do it like this...In the beginning i didn't take this option in consideration because i imagine that doing like this was more using one template than create it and customize it from zero...
But yes, maybe the easiest way is to make some templates and customize them...
The only way to print this card is to open it first, no? Becuase i tried and i had one error as the stack was not open...
Or there is one way to print it with no need to open the stack first?
I am trying to generate one PDF and send it by mail...So for me there is no a real necesity to open it before to send it by mail...
regards,
fko
Thanks for your answer...

I will do it like this...In the beginning i didn't take this option in consideration because i imagine that doing like this was more using one template than create it and customize it from zero...
But yes, maybe the easiest way is to make some templates and customize them...

The only way to print this card is to open it first, no? Becuase i tried and i had one error as the stack was not open...
Or there is one way to print it with no need to open the stack first?
I am trying to generate one PDF and send it by mail...So for me there is no a real necesity to open it before to send it by mail...
regards,
fko
Re: Create one PDF
Hi,
Finally I customized some different stacks to fill them with the different info (depending on the case) i would like to put in the PDF i want to send by mail...
And this is working ok...
Now my problem is sending the mail...
I read in the lessons and in the forum and it seems difficult to do what i want ( create one pdf and send it directly by mail) ...
I would like to send one mail, and attach the PDF document i just created before.
I followed the steps in these two lessons:
"How do I Create an HTML E-Mail?" and "How do I Attach a File to an E-Mail?"
I can send one e-mail as it is explaied in the first lesson.
But i can't attach the file...In fact i see that the file is attached but the size is 0 bytes...
I tried this with several files ( PDF, TXT, PNG, etc...) but always the size is 0 bytes...
This is the script of the button Launch:
local lvLaunchString
global gvAttachment
command populateLaunchString @pLaunchString avToken avArgument
if avArgument is empty then exit populateLaunchString
if pLaunchString is not empty then put pLaunchString & "," into pLaunchString
put pLaunchString & avToken & "'" & avArgument & "'" into pLaunchString
end populateLaunchString
on mouseUp
put empty into lvLaunchString
populateLaunchString lvLaunchString, "to=", the text of field "toField"
populateLaunchString lvLaunchString, "cc=", the text of field "ccField"
populateLaunchString lvLaunchString, "subject=", the text of field "subjectField"
populateLaunchString lvLaunchString, "body=", the text of field "bodyField"
populateLaunchString lvLaunchString, "attachment=", gvAttachment
if the platform is "MacOS" then # we are on a Mac
put "/Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin -compose" && lvLaunchString into lvLaunchString
else if the platform is "Win32" then # we are on Windows
put "C:\Program Files\Mozilla Thunderbird\thunderbird.exe -compose" && lvLaunchString into lvLaunchString
else # we do not support this platform
exit to top
end if
set the hideConsoleWindows to true
open process lvLaunchString for update
close process lvLaunchString
put empty into gvAttachment
end mouseUp
And this for the button Attach:
global gvAttachment
on mouseUp
# open the file selection dialog
answer file "Select a File to Attach"
if it is empty then exit mouseUp
# add the selected attachment to other possible attachments
if gvAttachment is not empty then put gvAttachment & "," into gvAttachment
put gvAttachment & it into gvAttachment
end mouseUp
What am i doing worng for the attachment? Sending mails without attachment is working...
I am working in Windows platform, but i also would like it will work to OS, IOS, and Android...
It is a pity that we can't send the mail directly from LiveCode and need to do it from ThunderBird...
Or maybe it is possible but it is me who understood bad?
The application would be more 'clean' and 'clear' if we could do this without pass from another one ( in this case Thunderbird)...
regards,
fko
Finally I customized some different stacks to fill them with the different info (depending on the case) i would like to put in the PDF i want to send by mail...
And this is working ok...
Now my problem is sending the mail...
I read in the lessons and in the forum and it seems difficult to do what i want ( create one pdf and send it directly by mail) ...

I would like to send one mail, and attach the PDF document i just created before.
I followed the steps in these two lessons:
"How do I Create an HTML E-Mail?" and "How do I Attach a File to an E-Mail?"
I can send one e-mail as it is explaied in the first lesson.
But i can't attach the file...In fact i see that the file is attached but the size is 0 bytes...
I tried this with several files ( PDF, TXT, PNG, etc...) but always the size is 0 bytes...
This is the script of the button Launch:
local lvLaunchString
global gvAttachment
command populateLaunchString @pLaunchString avToken avArgument
if avArgument is empty then exit populateLaunchString
if pLaunchString is not empty then put pLaunchString & "," into pLaunchString
put pLaunchString & avToken & "'" & avArgument & "'" into pLaunchString
end populateLaunchString
on mouseUp
put empty into lvLaunchString
populateLaunchString lvLaunchString, "to=", the text of field "toField"
populateLaunchString lvLaunchString, "cc=", the text of field "ccField"
populateLaunchString lvLaunchString, "subject=", the text of field "subjectField"
populateLaunchString lvLaunchString, "body=", the text of field "bodyField"
populateLaunchString lvLaunchString, "attachment=", gvAttachment
if the platform is "MacOS" then # we are on a Mac
put "/Applications/Thunderbird.app/Contents/MacOS/thunderbird-bin -compose" && lvLaunchString into lvLaunchString
else if the platform is "Win32" then # we are on Windows
put "C:\Program Files\Mozilla Thunderbird\thunderbird.exe -compose" && lvLaunchString into lvLaunchString
else # we do not support this platform
exit to top
end if
set the hideConsoleWindows to true
open process lvLaunchString for update
close process lvLaunchString
put empty into gvAttachment
end mouseUp
And this for the button Attach:
global gvAttachment
on mouseUp
# open the file selection dialog
answer file "Select a File to Attach"
if it is empty then exit mouseUp
# add the selected attachment to other possible attachments
if gvAttachment is not empty then put gvAttachment & "," into gvAttachment
put gvAttachment & it into gvAttachment
end mouseUp
What am i doing worng for the attachment? Sending mails without attachment is working...
I am working in Windows platform, but i also would like it will work to OS, IOS, and Android...
It is a pity that we can't send the mail directly from LiveCode and need to do it from ThunderBird...

Or maybe it is possible but it is me who understood bad?
The application would be more 'clean' and 'clear' if we could do this without pass from another one ( in this case Thunderbird)...
regards,
fko
Re: Create one PDF
It's possible.fko wrote: It is a pity that we can't send the mail directly from LiveCode and need to do it from ThunderBird...
Or maybe it is possible but it is me who understood bad?
-you can use a SMTP library :
http://forums.livecode.com/viewtopic.ph ... TP#p104961
-you can "outsource" the work... using a remote server with a special LiveCode script or a PHP script
http://lessons.runrev.com/m/4070/l/8184 ... er-scripts
Re: Create one PDF
Hi,
I tried with Sarah's SMTP Demo but i had one error...i don't remember now exactly but was something like "error sending mail: badread"...
And the second link was for OSX and Unix...And i am doing it in Windows...
And for attachment error, do you have an idea why it is not working? Thanks in advance...
regards,
fko
I tried with Sarah's SMTP Demo but i had one error...i don't remember now exactly but was something like "error sending mail: badread"...
And the second link was for OSX and Unix...And i am doing it in Windows...

And for attachment error, do you have an idea why it is not working? Thanks in advance...

regards,
fko
Re: Create one PDF
Hi,
And since I just checked the Pegasus site for the URL, I found out that it's still alive, and supports even IMAP now! Whow!
It's not easy to configure, but very powerful, and once configured properly, very reliable.
Sending EMails (with any even so alien features) using it via Shell command + cmd line arguments isn't hard, I do it from Access all the time. And since all you need to do is to create the files, then pass them via cmd line arguments, I see no reason why it shouldn't work.
(Pegasus accepts a huge amount of cmd line arguments, basically anything that you can configure at all - and it has no problem to run as multi-user, too ...)
And since Pegasus has proven to be an extremely well behaving piece of software, you might even want to have it running as a windows service, using NSSM ;-))
Hope I was able to point you to some maybe helpful resources!
(I'm still blown away - I spent hours today to search for an IMAP solution that I can use from LC, and now I find out that good old Pegasus is still alive after all these years, and can do this meanwhile - must.try.out!)
Have fun!
since you say:fko wrote:It is a pity that we can't send the mail directly from LiveCode and need to do it from ThunderBird...:-(
Have you ever tried Blat? I haven't tried yet (still using a prehistoric version of Pegasus Mail ...), but what I've seen looks quite good.fko wrote:And i am doing it in Windows...:-(
And since I just checked the Pegasus site for the URL, I found out that it's still alive, and supports even IMAP now! Whow!
It's not easy to configure, but very powerful, and once configured properly, very reliable.
Sending EMails (with any even so alien features) using it via Shell command + cmd line arguments isn't hard, I do it from Access all the time. And since all you need to do is to create the files, then pass them via cmd line arguments, I see no reason why it shouldn't work.
(Pegasus accepts a huge amount of cmd line arguments, basically anything that you can configure at all - and it has no problem to run as multi-user, too ...)
And since Pegasus has proven to be an extremely well behaving piece of software, you might even want to have it running as a windows service, using NSSM ;-))
Hope I was able to point you to some maybe helpful resources!
(I'm still blown away - I spent hours today to search for an IMAP solution that I can use from LC, and now I find out that good old Pegasus is still alive after all these years, and can do this meanwhile - must.try.out!)
Have fun!
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!
Re: Create one PDF
Hi,
Thanks for your answer...
So, i never used Blat...
Even if i know Pegasus mail...
I will look to see if it is easy to implement and if it will be useful for one next version to can use it in Windows, OSX, IOS, Android...
regards,
fko
Thanks for your answer...
So, i never used Blat...

Even if i know Pegasus mail...

I will look to see if it is easy to implement and if it will be useful for one next version to can use it in Windows, OSX, IOS, Android...
regards,
fko
Re: Create one PDF
Hi fko,
Android and iOS already have attachments solved in liveCode.
Simon
Android and iOS already have attachments solved in liveCode.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Create one PDF
Hi Simon,
Yes i already saw that the option for IOS and Android exists...
I was thinking in one solution all in one...
May i have your mind why it is not working the example i copied from the lesson to can attach files in the mails? I made one copy and paste, and i respected also the name of fields and buttons...
To send mails is working fine, but not to attach them...
As the size of the attached files is always 0 bytes...
Thanks in advance!!!
regards,
fko
Yes i already saw that the option for IOS and Android exists...

I was thinking in one solution all in one...

May i have your mind why it is not working the example i copied from the lesson to can attach files in the mails? I made one copy and paste, and i respected also the name of fields and buttons...
To send mails is working fine, but not to attach them...

As the size of the attached files is always 0 bytes...
Thanks in advance!!!

regards,
fko
Re: Create one PDF
Hi fko,
Download this stack:
"Updated stack using composeMail"
from here:
http://quality.runrev.com/show_bug.cgi?id=11895
it's fixed in liveCode 6.6.2
Simon
Download this stack:
"Updated stack using composeMail"
from here:
http://quality.runrev.com/show_bug.cgi?id=11895
it's fixed in liveCode 6.6.2
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Create one PDF
There is another way : a remote emailer.
Have a look at :
http://mandrill.com/
-you can open a free account
-then with LiveCode you can easily compose a JSON query (with email address, subject, attached files etc.), post it to Mandrill... and it will send your email.
Have a look at :
http://mandrill.com/
-you can open a free account
-then with LiveCode you can easily compose a JSON query (with email address, subject, attached files etc.), post it to Mandrill... and it will send your email.
Re: Create one PDF
Of course MailChimp!
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Create one PDF
Hi,
Thanks for the answer...
It seems a good solution...
And it is cool to learn something new...Was a nice council
Now, after learning how it works, i managed to do the below code...
So, from Mandrill i could send one test mail, and then attach one file...Or quite!!!
Because in the test mail i receive i have one attached file even if with one worng name...
This is my document "MyPDF.pdf"
and this where is is placed the file "C:/Users/fko/Downloads/Lc"
So, in the "name" ( of the attachment), i wrote : "C:/Users/fko/Downloads/Lc/MyPDF.pdf"
And this is the wrong attached file i have in the mail i received, as i recieved one "PDF" file with this name "C:/Users/fko/Downloads/Lc/MyPDF.pdf"...
So how i can correct this???
And once is corrected...How i should do from LiveCode to use this code i made??????
function log(obj) {
$('#response').text(JSON.stringify(obj));
}
// create a new instance of the Mandrill class with your API key
var m = new mandrill.Mandrill('MYAPIKEY');
// create a variable for the API call parameters
var params = {
"message": {
"text": "Example text content3",
"subject": "example subject3",
"from_email": "Mymail@gmail.com",
"to": [{"email": "TheOtherMail@hotmail.com"}],
"attachments": [
{
"type": "text/plain",
"name": "C:/Users/fko/Downloads/Lc/MyPDF.pdf",
"content": "ZXhhbXBsZSBmaWxl"
}
],
}
};
function sendTheMail() {
m.messages.send(params, function(res) {
log(res);
}, function(err) {
log(err);
});
}
regards,
fko
Thanks for the answer...

It seems a good solution...

And it is cool to learn something new...Was a nice council
Now, after learning how it works, i managed to do the below code...
So, from Mandrill i could send one test mail, and then attach one file...Or quite!!!

Because in the test mail i receive i have one attached file even if with one worng name...
This is my document "MyPDF.pdf"
and this where is is placed the file "C:/Users/fko/Downloads/Lc"
So, in the "name" ( of the attachment), i wrote : "C:/Users/fko/Downloads/Lc/MyPDF.pdf"
And this is the wrong attached file i have in the mail i received, as i recieved one "PDF" file with this name "C:/Users/fko/Downloads/Lc/MyPDF.pdf"...
So how i can correct this???
And once is corrected...How i should do from LiveCode to use this code i made??????
function log(obj) {
$('#response').text(JSON.stringify(obj));
}
// create a new instance of the Mandrill class with your API key
var m = new mandrill.Mandrill('MYAPIKEY');
// create a variable for the API call parameters
var params = {
"message": {
"text": "Example text content3",
"subject": "example subject3",
"from_email": "Mymail@gmail.com",
"to": [{"email": "TheOtherMail@hotmail.com"}],
"attachments": [
{
"type": "text/plain",
"name": "C:/Users/fko/Downloads/Lc/MyPDF.pdf",
"content": "ZXhhbXBsZSBmaWxl"
}
],
}
};
function sendTheMail() {
m.messages.send(params, function(res) {
log(res);
}, function(err) {
log(err);
});
}
regards,
fko
Re: Create one PDF
This is not LiveCode code.fko wrote: function log(obj) {
$('#response').text(JSON.stringify(obj));
}
// create a new instance of the Mandrill class with your API key
var m = new mandrill.Mandrill('MYAPIKEY');
Use the stack in attachment :
-paste your mandrill key
-type your email address
-select a PDF file
-send
It will help you to understand what you have to do (the JSON query is just... text with a special format).
And then after with the Mandrill API documentation, you can customize to your needs.
- Attachments
-
- TEST_EMAIL mandril.zip
- (1.59 KiB) Downloaded 322 times