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

Flatten form before auto submiting through button to client

JMForster
Registered: Feb 23 2011
Posts: 4

I have a working code that creates an email using information in the form fields and attaches a copy of the form to the email to be sent to the client.
 
I have another code that successfully flattens the form removing the non-printable buttons in preperation for a non-editable copy that we hope to submit to the client.
 
What I'm trying to do is figure out how to blend the two togethar where the email is created using the form field data, then the document is flattened and PDF packaged into the email as an "non-form" attachment for the client.
 
I have the below code but it doesn't work. I'm guessing that it doesn't work becasue the fields labels are removed due to the flattening before the part of the code that attaches it to the email is complete. Please help me develop a working code:
 

flattenPages(0,numPages-1,2);
this.syncAnnotScan();
annots = this.getAnnots();
for (var i = 0; i < annots.length; i++) {
annots[i].print = true;
}
 
// This is the form return e-mail. Its hardcoded
// so that the form is always returned to the same address
// Change address on your form
var cToAddr = this.getField("Email Address").value;
 
// First, get the client BCC e-mail address
var cBCCAddr = this.getField("Admin Email").value;
 
// Set the subject and body text for the e-mail message
var cSubLine = "Your Support Work Order";

var cBody = "Dear "
+ this.getField("Primary Site Contact").value +
",\n\n" +
"Attached you will find a PDF copy of today's work order notes for your records. As always your complete satisfaction is our #1 priority. If for any reason you feel the solution provided has not met your expectations, please let us know as all of our solutions and repairs come with a 30 day warranty as outlined in our Terms and Conditions agreement found at . \n\n" +
"You will receive an invoice including the charges from this visit sent to you and the Billing Contact on file this Friday. The invoice will be automatically paid on the following Friday through your method of payment on file. You will have 96 hours from the time the invoice is received to dispute any incorrect charges. \n\n" +
"Thank you for your business, \n\n" +
"Your Support Team \n" +
"Business Name \n" +
"Office: Number \n" +
"Fax: Number \n" +
"Email: Address";
 
// Send the form data as an PDF attachment on an e-mail
this.mailDoc({bUI: true, cTo: cToAddr, cBcc: cBCCAddr,
cSubject: cSubLine, cMsg: cBody});
   
Joseph

Joseph Forster

My Product Information:
Acrobat Pro 9.0, Windows
maxwyss
Registered: Jul 25 2006
Posts: 255
Your suspicion is definitely well founded.

The logical workaround would be to write at the very beginning all the data you need after the flattening into variables, and use them.

HTH.

Max Wyss.

JMForster
Registered: Feb 23 2011
Posts: 4
Thanks Max,

Did I mention that I have no Java experience at all? What I typically do when I need something unusual like this is nose around the forum looking for bits and pieces of other codes that I mash together till I get what I want. Both parts of this code work independently which gets me 75% there, but to complete the last mile I need someone who knows how to do what you’re saying rearrange things for me. If you’re that person I would really appreciate the help!

Joseph

Joseph Forster

JMForster
Registered: Feb 23 2011
Posts: 4
OK, I GOT IT!!

I kept poking at it and rearranging the order and the punctuation and I came up with the following working code. It will gather everything it needs from the fields in the form, flatten the form, then attach the flattened PDF file to email the client all in one acrobat forms button click!! When it flattens it removes the buttons and fields they way I wanted....

// This is the form return e-mail. Its hardcoded
// so that the form is always returned to the same address
// Change address on your form
var cToAddr = this.getField("Email Address").value;

// First, get the client BCC e-mail address
var cBCCAddr = this.getField("Admin Email").value;

// Set the subject and body text for the e-mail message
var cSubLine = "Your Support Work Order";

var cBody = "Dear "
+ this.getField("Primary Site Contact").value +
",\n\n" +
"Attached you will find a PDF copy of today's work order notes for your records. As always your complete satisfaction is our #1 priority. If for any reason you feel the solution provided has not met your expectations, please let us know as all of our solutions and repairs come with a 30 day warranty as outlined in our Terms and Conditions agreement found at . \n\n" +
"You will receive an invoice including the charges from this visit sent to you and the Billing Contact on file this Friday. The invoice will be automatically paid on the following Friday through your method of payment on file. You will have 96 hours from the time the invoice is received to dispute any incorrect charges. \n\n" +
"Thank you for your business, \n\n" +
"Your Support Team \n" +
"Business Name \n" +
"Office: Number \n" +
"Fax: Number \n" +
"Email: Address";

flattenPages(0,numPages-1,2);

// Send the form data as an PDF attachment on an e-mail
this.mailDoc({bUI: true, cTo: cToAddr, cBcc: cBCCAddr,
cSubject: cSubLine, cMsg: cBody});

Joseph Forster

maxwyss
Registered: Jul 25 2006
Posts: 255
Glad to hear that it worked out.

Max Wyss.