These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Print Button to include emailing of data only

wdrspens
Registered: Jul 22 2008
Posts: 94
Answered

Using LiveCycle Designer ES (8.2.1...) there are two very useful pre-coded Print and Reset Buttons.
However I would like to email all the data immediately prior to Printing or Resetting.
What code do I add in between the following two lines on the Print Button to ensure that the data, and only the data, is emailed?
Code:
form1.MainContent.PrintButton1::click - (JavaScript, client)

xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 0, 0, 0, 0);

I assume it is the same code that I add between the following two lines on the Reset Button:
Code:
form1.MainContent.ResetButton1::click - (JavaScript, client)

xfa.host.resetData();

I have the code for emailing the whole form, but it is only the data that I want to email, and preferably only the data that is neither calculated nor null.

I do not mind emailing the null data, but would definitely prefer not to email the calculated data.

Many thanks

David

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Do this all in code instead of using on of the preset buttons. That way you have more control over the process.
Somthing like this

event.target.mailForm(...);
xfa.host.print(...);
xfa.host.resetData();

You can find out more about the "mailForm" function from the Acrobat JavaScript Reference.

There might be a timing problem with the reset so soon after the other operations. If this is an issue then move the reset code to the "PostPrint" event.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

wdrspens
Registered: Jul 22 2008
Posts: 94
Dear Thom,

Thank you very much for your answer, but it assumes a level of ability which is not present. It is the code that is contained within the elipsis of event.target.mailForm(...) that has me stumped.

The Acrobat JavaScript Reference, if by that you mean, as I am sure you do, the pdf document called JavaScript for Acrobat API Reference, is not easy to interpret.

I have found mailForm which suggests the code would be:
event.target.mailForm(false,"another [at] isp [dot] com";another2 [at] anotherisp [dot] com","","","The subject of the email"","The body of the email");
Would that be right?
Again thank you very much
David
wdrspens
Registered: Jul 22 2008
Posts: 94
Dear Thom,

Thank you it worked and a .fdf file was sent by email - however the only problem is that I cannot import an .fdf file into the form. I need the export to be in .xml format. I could design a file in Acrobat using the same field nomenclature so that I could import the .fdf data, but that would not import the data sent from a dynamic form with multiple instances of the same data field names, although with different data content.
Any suggestions?
Thank you very much
David
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Now that you've gotten this to work, there is a similar function for sending XML.
Use:

event.target.submitForm({cURL:"another [at] isp [dot] com",cSubmitAs:"XML"});The submitForm function is quite a bit more complex than the "mailForm" function. Notice the difference in syntax, with the curly braces and the named input arguments. Read this article for more info on using it to email data:

http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/submitting_data/

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

wdrspens
Registered: Jul 22 2008
Posts: 94
Dear Thom,

To show you how naive I am, I copied your suggestion event.target.submitForm({cURL:"another [at] isp [dot] com",cSubmitAs:"XML"});
replacing another [at] isp [dot] com with my required email address, and when I pressed the button in Acrobat, I got the message box:
Security Warning
The document is trying to connect to
file:///G:/Documents/.../another [at] isp [dot] com
If you trust the site, choose Allow. If you do not trust the site, choose Block.
I pressed Allow and got the message:
Error: Nothing Done
Error Code URL
Invalid server Response http://another [at] isp [dot] com/I therefore read the article to which you referred me, but it is very different although I tried it, but it failed completely:
I tried:
event.target.submitForm({mailto:"another [at] isp [dot] com",cSubmitAs:"XML"});The problem I have is that in your article there are no curly brackets, but you use them in the suggestion you made to me. I am getting lost.

Many thanks for your help

David
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Sorry about the problems David. I was in error the first time. You've done great so far finding and fixing my mistakes. You're code above is only off by the placement of one quote. It should look like this, with the "mailto" inside the URL string.

event.target.submitForm({cURL:"mailto:another [at] isp [dot] com",cSubmitAs:"XML"});Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

wdrspens
Registered: Jul 22 2008
Posts: 94
Dear Thom,

You are so kind and helpful. It worked this time and has solved my problem.

Thank you so very much.

David