Javascript Help: Saving user input in PDF file.
Copy link to clipboard
Copied
I am working on a user fillable form that would, when a Submit button is clicked, save the user filled input to a plain text PDF file. My input form looks like attachment.
I want the out to be saved like this:
Email: uniquelikeyou@example.com
Date Requested: 2/10/2025
Title:
First Name: Unique
MI:
Last Name: LikeYou
Suffix:
I was trying to use the following javascript to accomplish this. (Please note that my knowledge of javascript .01 on a scale off 0 to 10).
//Get Input
var sendTo = this.getField(“myEmail”).value;
var dateReq = this.getField(“DateRequested”).value;
var title1 = this.getField(“Title”).value;
var first = this.getField(“FirstName”).value;
var mInit = this.getField(“MI”).value;
var Last = this.getField(“LastName”).value;
var Suf = this.getField(“Suffix”).value;
//Output body
var body = “Email: “ + sendTo + ”\n” +
“Date Requested:” + dateReq + “\n” +
“Name: “ + title1 + “ “ + first + “ “ + mInit + “ “ + Last + “ “ + Suf + “\n” +
Save, body. [????]
[???? - This is where I need help, in case my above code is correct. When user presses Submit button, the system should save the body in a text format in a PDF file, say UserText.PDF]
Copy link to clipboard
Copied
This is not going to work. In Reader it's impossible at all to create a new PDF file, and in Acrobat it requires using a script file that's installed on the local machine of each user.
Copy link to clipboard
Copied
Thanks for pointing tout this limitation.
Copy link to clipboard
Copied
This is how you could do it so you get a similar result with Reader:
1) Page 1 of the document is a mutiline, read-only text field.
2) Page 2 is template page that looks like your screenshot. The page is hidden.
3) When the document is opened it tests whether the multiline text field contains a value. If not, it spawns the template.
4) When the submit button is clicked, it puts the body into the multline text field, deletes the spawned page, and activates the Save As menu.
The next time the save document is opened it won't spawn the template because the text field contains a value.

