pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wojack, Robert (USTP)" <Robert.Woj...@usdoj.gov>
Subject RE: How to bind distinct OnValues for checkbox group?
Date Wed, 23 Mar 2016 17:09:22 GMT
Thanks. However, this code looks like it will find a given checkbox (which I can already do),
but I don't see any instructions that will actually update the binding.



-----Original Message-----
From: Strein, Mark C CIV USARMY TRADOC ANALYSIS CTR (US) [mailto:mark.c.strein.civ@mail.mil]

Sent: Wednesday, March 23, 2016 12:10 PM
To: users@pdfbox.apache.org
Subject: RE: How to bind distinct OnValues for checkbox group?

Sir,

Try this:

       /**
         * Returns the PDCheckbox you want to update or check from the pdFieldList.
         * Note: One of our teams created a PDF form using 'Adobe FormsCentral developer'.
         * after interrogating the forms fields, some inconsistencies arose with checkboxes/radiobuttons.
         * 
         * Here is a name of a radio button found in the form: 
         * "VIP_KUf6k4VfAA83KYq7*XLsiA.null"
         * 
         * When it is interrogated, it will appear twice in the interrogation list as:
         * "VIP_KUf6k4VfAA83KYq7*XLsiA.null = 0"
		 * "VIP_KUf6k4VfAA83KYq7*XLsiA.null = 1"
         * 
         * To determine the state of the radiobutton you would use the form:
         * 
         * pDFFileManager.getPDCheckbox("VIP_KUf6k4VfAA83KYq7*XLsiA.null","0").isChecked()
         * 
         * @param fullyQualifiedName
         * @return - PDCheckbox or null if not found
         */
        public PDCheckbox getPDCheckbox(String fullyQualifiedName, String onValue)
        {
        	PDCheckbox checkbox = null;
            for(int i = 0; i < pdFieldList.size();i++)
            {
                PDField field = pdFieldList.get(i);
            	if(field instanceof PDCheckbox)
            	{
	                try
	                {	                    
	                    if(field.getFullyQualifiedName().equalsIgnoreCase(fullyQualifiedName)
&& ((PDCheckbox)field).getOnValue().equalsIgnoreCase(onValue))
	                    {
	                    	checkbox = (PDCheckbox)field;
	                        break;
	                    }
	                }
	                catch(IOException e)
	                {
	                    e.printStackTrace();
	                }
            	}
            }
            return checkbox;
        }

V/R,
Mark Strein

TRAC-FLVN
Wargaming and Simulations Directorate
Analytic Tools Division - Paving Crew
Keeper of the Codes
913-684-9309



-----Original Message-----
From: Wojack, Robert (USTP) [mailto:Robert.Wojack@usdoj.gov] 
Sent: Wednesday, March 23, 2016 10:52 AM
To: users@pdfbox.apache.org
Subject: [Non-DoD Source] How to bind distinct OnValues for checkbox group?

We have a client that provides us with interactive PDF forms for our app to populate fields
with user data. The problem is the client sometimes provides us forms with typos and mistakes
and is not responsive about fixing them.

In this case, we are given an interactive PDF form that has a pair of Yes/No checkboxes. Unfortunately,
when creating the PDF, the client bound both checkboxes to the same "On" value. As a result,
when a user checks a box, both of them get checked (additionally, when a user unchecks a box,
they both become unchecked).

I can use PDFBox to open the file, find the PDCheckbox object in question and list their On
and Off values, but I can't figure out how to update the bindings to distinct values. Is it
possible to do this in PDFBox? If so, can someone please provide some guidance?

We are using PDFBox 1.8.8. We are not positioned to upgrade to 2.0.0.

Thanks


Bob Wojack
CSRA International, Inc.
Onsite Contractor for the Department of Justice Senior Tech Lead US Trustee Program
Onsite Email Address:     Robert.Wojack@usdoj.gov<mailto:Robert.Wojack@usdoj.gov>
Onsite Phone Number:    TBD
Cell#:                              (301)910-9975


---------------------------------------------------------------------
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


Mime
View raw message