Skip to main content
Participating Frequently
August 26, 2023
Answered

Is it possible to send a flattened version of a PDF form but also keep the original fillable form?

  • August 26, 2023
  • 2 replies
  • 2331 views

My PDF form has a "Submit Form" button which submits the form to an e-mail address. I have worked out how to get this to send as a flattened/non-fillable PDF, however, this then also makes the form fields in the 'original' read only. 

 

Is there a way that when the user fills in the form, presses the submit form button, the e-mail attachment is read only but also keeps the original file fillable? 

 

Hope this makes sense. Thank you.

    This topic has been closed for replies.
    Correct answer try67

    What you can do is use a script to set the fields as read-only before the submit command, then set them back as editable afterwards. Something like this:

     

    for (var i=0; i<this.numFields; i++) {
    	var fname = this.getNthFieldName(i);
    	var f = this.getField(fname);
    	if (f==null) continue;
    	f.readonly = true;
    }
    
    this.mailDoc({cTo: "me@server.com"});
    
    for (var i=0; i<this.numFields; i++) {
    	var fname = this.getNthFieldName(i);
    	var f = this.getField(fname);
    	if (f==null) continue;
    	f.readonly = false;
    }

     

    Note that this by no means prevents the contents of the fields from being edited. If you want to achieve that then the user will have to digitally sign the file before sending it, but then you won't be able to make the fields editable afterwards that easily...

    2 replies

    try67
    Community Expert
    try67Community ExpertCorrect answer
    Community Expert
    August 26, 2023

    What you can do is use a script to set the fields as read-only before the submit command, then set them back as editable afterwards. Something like this:

     

    for (var i=0; i<this.numFields; i++) {
    	var fname = this.getNthFieldName(i);
    	var f = this.getField(fname);
    	if (f==null) continue;
    	f.readonly = true;
    }
    
    this.mailDoc({cTo: "me@server.com"});
    
    for (var i=0; i<this.numFields; i++) {
    	var fname = this.getNthFieldName(i);
    	var f = this.getField(fname);
    	if (f==null) continue;
    	f.readonly = false;
    }

     

    Note that this by no means prevents the contents of the fields from being edited. If you want to achieve that then the user will have to digitally sign the file before sending it, but then you won't be able to make the fields editable afterwards that easily...

    ss97Author
    Participating Frequently
    August 27, 2023

    Thank you so much. This works perfect, except there are certain fields in my form that are set as "Read Only" and once the submit form button is pressed those read only fields turn to visible. Is there a way to stop this from occuring? Also, is there a way to add in 2 CC e-mails + a subject line into this formula? Really appreciate your help.

    try67
    Community Expert
    Community Expert
    August 28, 2023

    - Is it always the same fields, or is their visibility setting dynamic?

    - Sure.

    this.mailDoc({cTo: "me@server.com", cCc: "ccaddress1@server.com;ccaddress2@server.com", cSubject: "Email subject line"});

    kglad
    Community Expert
    Community Expert
    August 26, 2023

    in the future, to find the best place to post your message, use the list here, https://community.adobe.com/

    p.s. i don't think the adobe website, and forums in particular, are easy to navigate, so don't spend a lot of time searching that forum list. do your best and we'll move the post if it helps you get responses.



    <"moved from using the community">
    ss97Author
    Participating Frequently
    August 27, 2023

    My apologies, I didn't realise I had posted in the wrong place. Thank you for letting me know.