You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "Jackie Scholl (NCF)" <ja...@ncf.edu> on 2016/04/22 17:56:32 UTC

Click PDPushButton to Print Filled Form

Hey there,

Firstly, I'd like to apologize if I'm doing something wrong. I don't really
understand this mailing list software or the etiquette for this mailing
list, and I'm happy to be corrected.

I have a PDF document with an Acro Form. The form includes a PDPushButton
that a user can click to print the document once they've filled out the
form. The button just opens up the native OS printing UI to print a version
of the document that does not include the print button. OS X  (and possibly
other operating systems) allows a user who's printing a document to "print"
it to a PDF file. If the user does that with this file, then they get
basically the file with all the fields they filled out but it's no longer
editable and no longer has the print button. Is there a way I can automate
this process?

The reason I ask is because I'm building a webapp that will automatically
fill out the form based on user input and return the filled form to the
user, and ideally I'd like to be able to return a document that can't be
easily edited and doesn't have that print button. Is there a way to do this
with PDFBox?

In case it helps, I've attached three files: the blank, fillable form that
we start out with, a copy of that form filled out by my program with some
sample data, and that results of "printing" that filled form to a PDF.

(Note: despite the name "contract," this is just a form we use at my
college to handle the class registration system.)

Re: Click PDPushButton to Print Filled Form

Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,

> Am 22.04.2016 um 17:56 schrieb Jackie Scholl (NCF) <ja...@ncf.edu>:
> 
> Hey there,
> 
> Firstly, I'd like to apologize if I'm doing something wrong. I don't really understand this mailing list software or the etiquette for this mailing list, and I'm happy to be corrected.
> 
> I have a PDF document with an Acro Form. The form includes a PDPushButton that a user can click to print the document once they've filled out the form. The button just opens up the native OS printing UI to print a version of the document that does not include the print button. OS X  (and possibly other operating systems) allows a user who's printing a document to "print" it to a PDF file. If the user does that with this file, then they get basically the file with all the fields they filled out but it's no longer editable and no longer has the print button. Is there a way I can automate this process?
> 
> The reason I ask is because I'm building a webapp that will automatically fill out the form based on user input and return the filled form to the user, and ideally I'd like to be able to return a document that can't be easily edited and doesn't have that print button. Is there a way to do this with PDFBox?

if you are using PDFBox 2.x you can use PDAcroForm.flatten() after you have filled the form. This will make the form fields content part of the page and the form fields will be removed. For your push button unfortunately there is no immediate solution (see PDFBOX-3262).  What you could do is to either use PDAcroForm.flatten(List<PDField fields, boolean refreshAppearances) and include only the fields you'd like to have in the final PDF or before doing the call remove the push button yourself.

> 
> In case it helps, I've attached three files: the blank, fillable form that we start out with, a copy of that form filled out by my program with some sample data, and that results of "printing" that filled form to a PDF.
> 

The attachments were removed as these are not allowed in the mailing list. Please upload them to a public location if there are further questions.

BR
Maruan

> (Note: despite the name "contract," this is just a form we use at my college to handle the class registration system.)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org