Thank you, that put me on the right track. I had no idea about the inner
workings of appearances, and your explanation taught me enough about it to
substitute something in case a field has a weird one - kudos!

I'm guessing the form is mostly printed out, and filled in by hand, so that
this issue hasn't surfaced before.

Cheers!
Ulf

On Tue, Jun 3, 2025 at 10:27 PM sahy...@fileaffairs.de <
sahy...@fileaffairs.de> wrote:

> Hello Ulf,
>
> a typical default appearance string looks like this
>
> /Helv 12 Tf 0 g
>
> There are two operators Tf, to set the font, and g to set the color
> with the arguments for the operators being supplied before.
>
> Helv 12 being the arguments for Tf and
> 0  being the argument for g
>
> Your form has / 13 0 g
>
> So 13 0 are being treated as arguments for the g operator. But there
> are no colors with 2 arguments. It's either 1 (Greyscale) , 3 (RGB) or
> 4 (CMYK) arguments.
>
> So IMHO the default apperace string is wrong.
>
> It's also very unusual that it doesn't set a font.
>
> Workaround would be to set the default apperance string similar to the
> first sample above.
>
> BR
> Maruan
>
>
>
>
>
> Am Dienstag, dem 03.06.2025 um 21:36 +0200 schrieb
> sahy...@fileaffairs.de:
> > Hello
> >
> >
> > Am Dienstag, dem 03.06.2025 um 17:47 +0200 schrieb Ulf Dittmer:
> > > Hello-
> > >
> > > When trying to fill in values into a form, I'm encountering the
> > > error
> > > shown
> > > below, which means nothing to me. It's not just for the first field
> > > it
> > > encounters - if I comment that out, it happens for the next field.
> > >
> > > The form (an official government PDF) doesn't seem different from
> > > any
> > > number of other ones we are successfully filling out; it can be
> > > found
> > > at
> > > https://ulfdittmer.com/pdfbox/Guide_BW.pdf
> >
> > is that the original form or after setting the font?
> >
> > BR
> > Maruan
> >
> > >
> > > The source code is also similar to other codes we use for other
> > > forms:
> > > https://ulfdittmer.com/pdfbox/StreamQRApplForm.java
> > >
> > > It uses the following font, which is also standard
> > > https://ulfdittmer.com/pdfbox/Arial.ttf
> > >
> > > Are we doing something wrong? Is the PDF weird? Is there a way
> > > around
> > > this
> > > issue?
> > >
> > > Many thanks in advance for any help you can supply.
> > >
> > > Ulf
> > >
> > > Jun 03, 2025 5:21:00 PM org.apache.pdfbox.pdfparser.BaseParser
> > > parseCOSDictionaryNameValuePair
> > > WARNING: Empty COSName at offset 940
> > > Exception in thread "main" java.io.IOException: Could not process
> > > default
> > > appearance string ' 13 0 g' for field 'Name ggf Geburtsname':
> > > Missing
> > > operands for set non stroking color operator [COSInt{13},
> > > COSInt{0}]
> > > at
> > > org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelpe
> > > r.
> > > <init>(AppearanceGeneratorHelper.java:123)
> > > at
> > > org.apache.pdfbox.pdmodel.interactive.form.PDTextField.constructApp
> > > ea
> > > rances(PDTextField.java:261)
> > > at
> > > org.apache.pdfbox.pdmodel.interactive.form.PDTerminalField.applyCha
> > > ng
> > > e(PDTerminalField.java:209)
> > > at
> > > org.apache.pdfbox.pdmodel.interactive.form.PDTextField.setValue(PDT
> > > ex
> > > tField.java:218)
> > > at StreamQRApplForm.setField(StreamQRApplForm.java:67)
> > > at StreamQRApplForm.main(StreamQRApplForm.java:28)
> > > Caused by: java.io.IOException: Missing operands for set non
> > > stroking
> > > color
> > > operator [COSInt{13}, COSInt{0}]
> > > at
> > > org.apache.pdfbox.pdmodel.interactive.form.PDDefaultAppearanceStrin
> > > g.
> > > processSetFontColor(PDDefaultAppearanceString.java:202)
> > > at
> > > org.apache.pdfbox.pdmodel.interactive.form.PDDefaultAppearanceStrin
> > > g.
> > > processOperator(PDDefaultAppearanceString.java:133)
> > > at
> > > org.apache.pdfbox.pdmodel.interactive.form.PDDefaultAppearanceStrin
> > > g.
> > > processAppearanceStringOperators(PDDefaultAppearanceString.java:105
> > > )
> > > at
> > > org.apache.pdfbox.pdmodel.interactive.form.PDDefaultAppearanceStrin
> > > g.
> > > <init>(PDDefaultAppearanceString.java:87)
> > > at
> > > org.apache.pdfbox.pdmodel.interactive.form.PDVariableText.getDefaul
> > > tA
> > > ppearanceString(PDVariableText.java:105)
> > > at
> > > org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelpe
> > > r.
> > > <init>(AppearanceGeneratorHelper.java:117)
> > > ... 5 more
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> > For additional commands, e-mail: users-h...@pdfbox.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> For additional commands, e-mail: users-h...@pdfbox.apache.org
>
>

Reply via email to