How do I lock PDF before e-mailing so that it cannot be altered by the recipient?

Avatar

Avatar

Steve_Coxon

Avatar

Steve_Coxon

Steve_Coxon

12-10-2011

[Thread Edited By Adobe]

/*Don’t forget to meet and greet your fellow peers virtually by telling them about yourself here

Go ahead and to it now: https://adobe.ly/3eDnB4v */

 

Actual Question:

I've created a form in LiveCycle which will be seen and filled by users who only have Reader.

 

Once the form is completed, the user has to click three buttons: one prints the page (for a specific paper-based usage required by the filler of the form). The same button  sends the entire form to one e-mail address.

 

The second button prepares the form for submission to a second e-mail recipient. This recipient must not be able to see some of the filled fields on the form. As well as setting these fields to invisible, the second button also hides key fields behind a text message, telling the second recipient where to find the information that is most useful to them on the form. Again, this recipient will be using only Acrobat Reader.

 

Everything works fine, apart from when it comes to e-mailing the form to the second recipient. I've used various scripts I've found on this forum and elsewhere to lock fields before sending and I've extended Reader rights in Acrobat. But, whatever I do, the form received by the recipients is STILL editable, the "invisible" fields are visible again and also editable,  and the test box that obscured key fields has become invisible again.

 

I've already tried using a range of scripts that I've found both on this forum and elsewhere (including Paul Guerrett's 'Lock All Fields' and 'Lock All Fields Not Buttons' scripts. I've also tried using the scripts in different 'events' - mouse up, mouse down, click etc.

 

What am I doing wrong? I've spent days trying to figure this out and I'm getting nowhere.

 

I am  a JavaScript novice, by the way. So please keep it simple and (better still) provide working script! Thanks to anyone who can help

Accepted Solutions (0)

Answers (13)

Answers (13)

Avatar

Avatar

George_Florenti

Avatar

George_Florenti

George_Florenti

22-05-2013

This is the system that I use and it workes perfectly:

/**
* Loop through all elements of eForm, except button named "view", and set the access to "protected"
*/
function LockForm() {
     // Get the field containers from each page.
     for (var nPageCount = 0; nPageCount < xfa.layout.pageCount(); nPageCount++) {
          var oFields = xfa.layout.pageContent(nPageCount, "field");
          var nNodesLength = oFields.length;

          // Set the field property.
          for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {
               if (!(oFields.item(nNodeCount).ui.oneOfChild.className == "button" && oFields.item(nNodeCount).name == "view")) {
                    oFields.item(nNodeCount).access = "protected";
               }
          }
     }
}

function unLockForm() {
     // Get the field containers from each page.
     for (var nPageCount = 0; nPageCount < xfa.layout.pageCount(); nPageCount++) {
          var oFields = xfa.layout.pageContent(nPageCount, "field");
          var nNodesLength = oFields.length;

          // Set the field property.
          for (var nNodeCount = 0; nNodeCount < nNodesLength; nNodeCount++) {
               oFields.item(nNodeCount).access = "open";
          }
     }
}

Avatar

Avatar

kevinmortimer11

Avatar

kevinmortimer11

kevinmortimer11

26-10-2011

Hi Steve,

I can see 2 possible options for you to investigate,

1) Submit the form to a LiveCycle process and let LiveCycle Output turn the PDF into a PDFA and then email the second recipient.

if you don't have a LiveCycle Output server

2) Remove the second submit button and add a signature field which can lock the entire PDF.. once signed the PDF can be email directly from Reader/Acrobat using the File>Attach To Email

One thing to remember is that anything that can achieved through script can also be undone through script written into the javascript console, so if you a working with sensitive data you should use one of the options above.

Kind Regards

Kev

Solutions Architect

Avoka

www.avoka.com

Avatar

Avatar

past-tense

Avatar

past-tense

past-tense

19-10-2011

Hey everyone,

I know that this solution isn't a simple button press, but it's what i do when I don't want users to be able to edit a completed form.

I use a virtual printer ('Adobe PDF' or 'CutePDF') to "print" the form to a new flattened pdf document. All scripts are lost, and all fields are made 100% uneditable. No fancy code required, and you can make use of '.relevant = "-print"' in the initialize event of fields that you don't want to include in the printed version. You can then email this printed version the the client.

I've tried a handful of scripts to lock down forms, and I've even written my own. None of them have been perfect, and while this solution does have a manual aspect, it just feels so much cleaner to me.

Just my two cents,

- Scott

Avatar

Avatar

ditto9888

Avatar

ditto9888

ditto9888

19-10-2011

Have you gotten the solution yet?  Would you share it in here?

Because I have similar problems.  The locking script did lock most of the fields, but not the ones on the Master Page.

Most troubleing is that it alters the behavior of the Email PDF Form button... the email body text used to say that it's sending a PDF form; but once I used the locking script, the email body text got changed as if it's sending the XDP form data, even though the attachment is still a PDF.  It's very weird.

Avatar

Avatar

Steve_Coxon

Avatar

Steve_Coxon

Steve_Coxon

19-10-2011

Thanks for this David. In the meantime, I've sent the form to Paul Guerett. From his previous posts, I reckon he's probably a genius - so I have high hopes. I'm also going to experiment on a copy of te form with your code, which - to me, a JavaScript newbie - is incredibly impressive.

Steve

Avatar

Avatar

David_James_Hol

Avatar

David_James_Hol

David_James_Hol

17-10-2011

This is the script I use for the Payroll radio button:

10-17-2011 10-20-03 AM.png

Avatar

Avatar

David_James_Hol

Avatar

David_James_Hol

David_James_Hol

17-10-2011

Steve, I've designed a similiar HR form with radio buttons that send custom data via email to the respective departments. For example, if I select the Payroll RB, the form will pull the data that Payroll will need to setup the EE. Each script under the respective rbs is different, so I never have to worry about sending data to the wrong department.

10-17-2011 9-48-45 AM.png

Avatar

Avatar

pguerett

Avatar

pguerett

pguerett

17-10-2011

That should do the trick .....at this point I will have to see the form to determne what the issue is. Can you email it to me at LiveCycle8@gmail.com and I will have a look. Include a description of the issue in the email please.

Paul

Avatar

Avatar

Steve_Coxon

Avatar

Steve_Coxon

Steve_Coxon

16-10-2011

Hi Dhiyane,

The forms are used to create an HR record for new employees and - at the same time - inform the IT department what IT requirements the employee has. The IT requirements are filled automatically, depending on the job role.

The form is stored on a shared drive which can be accessed by the HR person at 27 different sites. They will open it from there using Reader on their local machine.

Once they have completed the form they click on one button which prints the form (the new team member has to confirm some details by physically signing it). The same button performs and execEvent (click) on an invisible e-mail submit button that sends the form to the Payroll department. Payroll uses this to set up a basic employee record. They need to see the completed PDF form, not XML data and the form needs to be uneditable.

A second button prepares the form for sending to the IT department. It is important that this hides all payroll and personal team member information. I have set up the button to do this by making the relevant fields invisible and making a text box visible that tells IT that the information they need is on page 2 of the form. This second button also performs an execEvent. (click) on a second e-mail submit button, which sends the form to IT. The second button also locks all fields.

My problem is that the first button prints the form and launchesthe e-mail programme and the second button makes the correct fields invsible. BUT when the form is e-mailed, the fields that should be invisible are visible again (complete with all personal data) and the form is editable again.

I've tried various scripts, including Paul Guerrett's 'Lock All Fields Not Buttons' script - as well as a few others I've found elsewhere - but the problem remains. I also made sure that the "preserve scripting changes" button described by Niall (above) was checked. It was.

Any ideas gratefully received!

Avatar

Avatar

Dhiyane

Avatar

Dhiyane

Dhiyane

16-10-2011

Hi Steve,

How you are sending the form to recipients ? Is it like calling separate service to send mail to users ? please specify in details.

Dhiyane.

Avatar

Avatar

Steve_Coxon

Avatar

Steve_Coxon

Steve_Coxon

12-10-2011

Hi Niall,

I checked and "Preserve Scripting Changes" was already set to Automatically.

Markerline, thanks for the suggestion. I'm not sure if it's exactly what I need, but I'll take a closer look.

In the meantime, any other ideas anyone?

Steve

Avatar

Avatar

Niall_O_Donovan

Avatar

Niall_O_Donovan

Niall_O_Donovan

12-10-2011

Hi,

If you open the form in Designer, go to the File > Form Properties > Defaults. Make sure that the "Preserve script changes" is set to Automatic.

Preserve script changes.png

That should help,

Niall

Avatar

Avatar

markerline

Avatar

markerline

markerline

12-10-2011

I couldn't read everything you wrote but from the gist of your topic have you tried this?:

http://www.adobe.com/products/acrobatpro/features.html#categorylens_featureset_5

click on "Passwords and Permissions" on that page to get an iFrame popup that details how you can protect your document.