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

Print form as PDF and attach to email button?

Community Beginner ,
Apr 15, 2024 Apr 15, 2024

Copy link to clipboard

Copied

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

Views

767

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

only using acrobat, sent via outlook

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Before the mailDoc command, add this line:

this.flattenPages();

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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;
}

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST

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).

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

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