Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Print form as PDF and attach to email button?

Community Beginner ,
Apr 15, 2024 Apr 15, 2024

Hello, i did a quick search but wasnt satisfied with the language i found regarding my question.

 

I have a fillable form i wish to send with email via a button on the form using javascript.

 

When i do this now, acrobat attaches a live fillable file, and not a printed pdf.

 

This is for a class certificate, and must be sent as a printed pdf and not the editable form.

Can someone please help provide the java code to accomplish this? Its more complex than i can work out on my own.

Thanks for the assistance!

 


var cToAddr = "email@address.here"


var cSubLine = "Your Certificate of Achievement"


var cBody = "Thank you for your recent participation at our Continuing Education Session.\r" + "Your Certificate of Achievement is enclosed.\r \r" + "If you have any questions, please do not hesitate to reach us."

 

this.mailDoc({bUI: true, cTo: cToAddr, cSubject: cSubLine, cMsg: cBody});

TOPICS
JavaScript , PDF forms
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 15, 2024 Apr 15, 2024

Is the file going to be sent exclusively from Acrobat, or also from Adobe Reader, or other applications?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 16, 2024 Apr 16, 2024

only using acrobat, sent via outlook

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 16, 2024 Apr 16, 2024

Before the mailDoc command, add this line:

this.flattenPages();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 16, 2024 Apr 16, 2024

That worked great! however buttons on the document set to visible but not print, transfered.

Is there some way to hide them with this approach?

I guess I can try making them white with no borders and just "know" they are there! they are functional buttons that reset some form fields, and create pdf for file records.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 16, 2024 Apr 16, 2024

You can use this code to set all non-printing fields as hidden before flattening the pages:

 

for (var i=0; i<this.numFields; i++) {
	var fname = this.getNthFieldName(i);
	var f = this.getField(fname);
	if (f==null) continue;
	if (f.display==display.noPrint) f.display = display.hidden;
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 16, 2024 Apr 16, 2024

Thank you, that is almost perfect! 

Im finding that the flatten command takes away the repeat functionality of the file.

I am not able to undo this, to continue editing say, the name field, to create the next certificate, and must be careful not to save the file, revert it, then.

I am hoping to have the workflow go something like:

  1. (open file), fill out certificate info, attendee name.
  2. click email submit button (this thread) pdf is attached to email, and i send.
  3. click print pdf button, save a record of this file in class folder.
  4. click reset name button, begin again at step 1.

 

I found that composing the same email, and attaching the pdf was taking way too long, even when copying message body and subject. this concept of "submit via email button" has really saved time in the process. If it could only be replicated as above!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 16, 2024 Apr 16, 2024

Yes, flattening is not reversible. You can simply close the file without saving it afterwards, though, and then re-open it to start over.

The other options are to set the fields as read-only, and then as editable later on (not secure, but easy to do), or to digitally sign the file, then remove the signature later on (secure, but more complicated to perform).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 15, 2024 Apr 15, 2024

This cannot be done from a script on the form itself. 

However, if you are using Acrobat Pro, an automation script can be written to flatten the document and send it.  

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 16, 2024 Apr 16, 2024

Thanks, so i can use script for button on document that will

  1. flatten document
  2. create email and attach flattened document

 

can you help me with a sample script to try?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 20, 2025 Apr 20, 2025

Hi, in case I want to CC the email, how will the javascript code change? Please help me with this 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 20, 2025 Apr 20, 2025
LATEST

Use this:

this.mailDoc({bUI: true, cTo: cToAddr, cSubject: cSubLine, cMsg: cBody, cCc: "me@server.com" });

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines