Copy link to clipboard
Copied
You folks were so quick answering my previous question... you know what they say, "No good deed goes unpunished". So here's my question, I don't think it's a difficult one, but it involves Java script for which I have zero experience.
I have a form that I would like to have the users submit as a PDF that is static. My thinking is that this is most easily accomplished as a Print to PDF function. I can add a button and assign <File><Print>, but that's as deep as that command works. I don't want to just use <File><Save as PDF> since I want to remove the form functionality and save the entered data.
I'm guessing I need to assign a java script to the button. Anyone have something pre-coded that they can slide my way? Thank you in advance.
Jeremy
Cleveland, Ohio
Use the code I've written, from this reply: Re: Password protected form that reader can edit?
To cause the Save As dialog to open at the end of it add this command:
app.execMenuItem("SaveAs");
Copy link to clipboard
Copied
This is not really a good idea. For starters, all of your users will need to have Acrobat and use Windows for it to work.
A better idea is to flatten the file (also only possible in Acrobat) or set the fields as read-only (possible in both Acrobat and the free Reader). Alternatively, you can add a digital signature field to the file and set it to lock all the fields when it is signed.
Copy link to clipboard
Copied
Can you describe the process to "flatten" a file and could it also be worked into a script that would flatten the file and then call a "save as" function? Our users are notoriously lazy and so, I'm trying to make it as bullet proof as possible.
The original of the questionnaire (5 pgs) will be set to "read only" so the goal is to save a file that as you say is "flat" but, contains all of the respondent information. I'm happy to attach a link to the file if that would be useful. Thanks again,
Jeremy
Copy link to clipboard
Copied
Use the code I've written, from this reply: Re: Password protected form that reader can edit?
To cause the Save As dialog to open at the end of it add this command:
app.execMenuItem("SaveAs");
Copy link to clipboard
Copied
Thank you yet again.
Copy link to clipboard
Copied
I tried the script you included and added the "app.execMenuItem("SaveAs");" statement.
Unfortunately, the added statement is the only portion of the script that seems to function. The saved document still has all the form fields live.
I added the script as a "Mouse Down"/"Run Javascript" function. This is the contents of the script verbatim:
function flattenFields() {
if (app.viewerType=="Reader") {
for (var i=0 ; i<this.numFields ; i++) {
var f = this.getField(this.getNthFieldName(i)) ;
if (f==null) continue;
f.readonly = true;
}
} else {
this.flattenPages();
}
}
app.execMenuItem("SaveAs");
Did I miss something?
Copy link to clipboard
Copied
Yes, the call to the flattenFields method...
On Tue, Sep 26, 2017 at 10:23 PM, jeremyk54602636 <forums_noreply@adobe.com>
Copy link to clipboard
Copied
Told you I know nothing about Java scripting. Guess I just proved it... Thank you. That seems to have done it.