Skip to main content
Known Participant
December 13, 2023
Beantwortet

Strip PDF form fields but keep content inputted into the fields?

  • December 13, 2023
  • 5 Antworten
  • 5128 Ansichten
Hi. I'm looking for a method to;
 
1) make a PDF form with image, text and checkbox input fields, save.
2) fill in content,
3) Strip the PDF of these input fields but keep the content that has been inputted into the fields. Aka.. a text input field becomes just text.
 
I need this as I'm showing the PDF in 3rd party software that doesn't handle form fields properly. I want to be able to make a lot of PDFs with different content, strip fields, save and then read into this 3rd party software.
 
Any ideas?
Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von JR Boulay

"What I mean is that if I make the checkboxes non-printable, and keep them as fields, and then flatten all text and image input fields."

Otherwise you can select all checkboxes, cut them, flatten the form fields, then paste.

5 Antworten

Participant
December 14, 2023

Creating a PDF form with image, text, and checkbox input fields involves using specialized software or libraries capable of PDF form creation, such as Adobe Acrobat or programming libraries like PyPDF2 or PDFBox. Once the form is created, content can be inputted programmatically into these fields using the chosen tool's functionalities.

The challenge arises when needing to strip the PDF of these input fields while retaining the content within them. This typically involves programmatically removing or flattening the form fields while preserving the inputted content—transforming text input fields into plain text and retaining image content. This step is crucial for compatibility with third-party software that doesn't handle form fields effectively.

JR Boulay
Community Expert
Community Expert
December 13, 2023

There is a flattener among the (free) abracadabraTools:

https://www.abracadabrapdf.net/utilitaires/utilities-in-english/abracadabratools_en/

Acrobate du PDF, InDesigner et Photoshopographe
Known Participant
December 13, 2023

I have now set the checkboxes to "Visible but not printable", and objects I need to flatten to "visible".

I used the "Flatten" feature of abracadabra, and it flattened ALL objects.

I opened the Javascript debugger console and script, and entered this script:

this.flattenPages({bNonPrint: 1});

as suggested above but nothing happened when clicked the green circle button. I tried to run the script all over the javascript editor but I couldn't get the script to run. also tried to remove the "this." prefix.

What is wrong?






try67
Community Expert
Community Expert
December 13, 2023

To run the code select it and press Ctrl+Enter.

JR Boulay
Community Expert
JR BoulayCommunity ExpertAntwort
Community Expert
December 13, 2023

"What I mean is that if I make the checkboxes non-printable, and keep them as fields, and then flatten all text and image input fields."

Otherwise you can select all checkboxes, cut them, flatten the form fields, then paste.

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
Community Expert
December 13, 2023

You can do that using a simple script:

this.flattenPages();

If you want it to not flatten some fields then you would need to set them first as non-printing (ie. either hidden or visible, but doesn't print), then run this command:

this.flattenPages({bNonPrint: 1});

Just be aware this process is NOT reversible, so make sure to save the flattened file under a new name, or to keep a backup of the original somewhere.

try67
Community Expert
Community Expert
December 13, 2023

Also note that if you do this you'll lose all information that's not available on the screen, such as overflowing text in a text field with a scroll-bar.

Nesa Nurani
Community Expert
Community Expert
December 13, 2023

Just print to PDF when you're done filling file.

Known Participant
December 13, 2023

Ah ok I will try that but I need to keep some of the form objects still (checkboxes), but transform the text and image fields to normal text and images.