Am 29.06.2015 um 11:43 schrieb Roberto Nibali:
Hello
else if (f instanceof PDCheckbox)
{
fieldValue = fieldValues.get(fieldName);
How is this supposed to work? The value one gets via getValue() from the
PDField is always null for PDCheckboxes.
that part is not from PDFBox, this is the map that is set in the main()
method, in this case "m.put("Check Box1", "true");".
Yep, that part I understood, nevertheless, the original map was filled most
probably using the .getValue() method, since the map definition is only
<string,string>, whereas I defined my map as map<string,PDfield>, to make
sure that at a later stage I can differentiate between the field types when
filling up the template PDF fields.
No, in that code the map was set manually, e.g. "m.put("Check Box1",
"true");".
My question is: is a standard PDCheckbox field type supposed to have a
getValue() != null? If not, how could I set the checkbox otherwise, using
the PDCheckbox specific enhancements in the type class?
I have no idea; but in the code I attached yesterday, it was possible to
set the checkbox with check() or uncheck().
But if I understand you correctly, that method didn't work for you; the
answer by Maruan suggests that the appearance must be set as well in
some PDFs. (The appearance stream is a sequence of PDF operators that
draws "what you see") And that is the moment where one would have to
look at the PDFs themselves in an editor to see what's inside.
I looked in the jmactest.pdf file, that one has appearance streams for
both states, this can be seen at Root/AcroForm/Fields/[1]/AP/N in
the PDFDebugger. (Use the 2.0 version jar to jump directly with the path
I mentioned, get it here:
https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/2.0.0-SNAPSHOT/
)
So you would have to see what's in the file that you generate, or what's
in the template you use.
Re skype etc, I don't even have skype or a headset, and I'm not really
the best choice anyway. And sooner or later one would have to look at
the PDF too, and thus likely see the name of your contact partner, thus
breaking the NDA :-(
I see that the jmactest file is compressed so you won't see much in the
editor, so I used WriteDecodedDoc utility to decompress it, and here's
the relevant part for the chekcbox: (it looks less messy if you use
PDFDebugger!):
23 0 obj
<<
/AP <<
/D <<
/Off 39 0 R
/Yes 40 0 R
>>
/N <<
/Off 41 0 R
/Yes 42 0 R
>>
>>
/AS /Off
/F 4
/FT /Btn
/MK <<
/BC [0.0]
/BG [1.0]
/CA (4)
>>
/P 30 0 R
/Rect [151.479 648.203 169.479 666.203]
/Subtype /Widget
/T (Check Box1)
/Type /Annot
>>
endobj
39 0 obj
<<
/BBox [0.0 0.0 18.0 18.0]
/FormType 1
/Length 44
/Matrix [1.0 0.0 0.0 1.0 0.0 0.0]
/Resources <<
/ProcSet [/PDF]
>>
/Subtype /Form
/Type /XObject
>>
stream
0.75293 g
0 0 18 18 re
f
0.5 0.5 17 17 re
s
endstream
endobj
40 0 obj
<<
/BBox [0.0 0.0 18.0 18.0]
/FormType 1
/Length 124
/Matrix [1.0 0.0 0.0 1.0 0.0 0.0]
/Resources <<
/Font <<
/ZaDb 72 0 R
>>
/ProcSet [/PDF /Text]
>>
/Subtype /Form
/Type /XObject
>>
stream
0.75293 g
0 0 18 18 re
f
0.5 0.5 17 17 re
s
q
1 1 16 16 re
W
n
0 g
BT
/ZaDb 14.532 Tf
2.853 4.081 Td
13.9943 TL
(4) Tj
ET
Q
endstream
endobj
41 0 obj
<<
/BBox [0.0 0.0 18.0 18.0]
/FormType 1
/Length 38
/Matrix [1.0 0.0 0.0 1.0 0.0 0.0]
/Resources <<
/ProcSet [/PDF]
>>
/Subtype /Form
/Type /XObject
>>
stream
1 g
0 0 18 18 re
f
0.5 0.5 17 17 re
s
endstream
endobj
42 0 obj
<<
/BBox [0.0 0.0 18.0 18.0]
/FormType 1
/Length 118
/Matrix [1.0 0.0 0.0 1.0 0.0 0.0]
/Resources <<
/Font <<
/ZaDb 72 0 R
>>
/ProcSet [/PDF /Text]
>>
/Subtype /Form
/Type /XObject
>>
stream
1 g
0 0 18 18 re
f
0.5 0.5 17 17 re
s
q
1 1 16 16 re
W
n
0 g
BT
/ZaDb 14.532 Tf
2.853 4.081 Td
13.9943 TL
(4) Tj
ET
Q
endstream
endobj
Tilman
Adobe Acrobat seems to handle it just fine, albeit that's an easy thing to
say. Preview under MacOSX also cannot properly handle those PDFs, btw.
Haven't tried any Linux tools yet, but my time is extremely limited.
Best regards
Roberto
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]