We need to create a PDF dynamically that is fillable.
I would like to add a button to the form that says Submit. When the user clicks on the button, all the form fields should be collected and a JS fetch call should send it to a server.
Is this possible using borb?
Here's an example:
layout.add(
FixedColumnWidthTable(number_of_columns=2, number_of_rows=4)
.add(
JavaScriptPushButton(
text="Submit Data",
javascript="// GET THE FIELDS AND CALL FETCH USING POST VERB HERE.",
horizontal_alignment=Alignment.RIGHT,
)
)
)
There is no need for Javascript the forms submission is built into Acrobat and other (NOT All) PDF readers.
Here is a button that sends whatever the user enters to replace
Hello world!Note the deliberate Mistake so if I change that to `Hello World! or my name then that is the data transmitted behind my back to Example.com, without me accepting any insecure JS code.The reply from the server will come back to my incoming folder.
OK this is embarrassing, apparently I shot them a blank PDF on the left, and got an equally reasonable "Thank you for your submission" on the right.
Back to the manual then!*see edit below. However the point is any suitable text in the file will be sent out simply at the push of a button with the correct action, as provided by the text editor.The offending section was this text code. It says send the data to a forms handler at remote
https://www.example.com?incoming.phpSo what you need is a button statement (graphics are supplied by any suitable reader). With a send text action and a website that knows what to do for incoming and outgoing data fields.
CAPS W, before I pressedSubmit. Oddly the Acrobat DC transmittal is older 1.2 format not newer 1.4?So just to confirm the newly assigned "WidGet" object that worked was:
Looking at the Borb code, I am not sure that Joris used an AcroForm URL submit "ACTION" but a JavaScript in his response to https://github.com/jorisschellekens/borb/issues/42#issuecomment-1046043322