You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Oliver Degener <ol...@monday-consulting.com> on 2021/08/16 16:10:02 UTC

Setting the value of a single-select PDChoice field

Hi,

I'm using PDFBox to automatically fill in all kinds of PDF documents. Recently, I was seeing the following error message with a new PDF:
'The list box does not allow multiple selections.'

I saw in the code that the PDChoice field can be single-select or multi-select. With single-select fields, the setter that takes a list of choices [0] throws an exception whenever the given list is not empty. Therefore I now have to use the general setter from PDField [1] which does not check whether the provided option is valid (selectable).

It would be great if the setter from [0] would also work for single-select choices and would only throw an exception if the list's size is greater than 1.

Any thoughts on this?

Thanks & Regards
Oliver

[0] https://pdfbox.apache.org/docs/2.0.3/javadocs/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.html#setValue(java.util.List)
[1] https://pdfbox.apache.org/docs/2.0.3/javadocs/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.html#setValue(java.lang.String)

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


Re: Setting the value of a single-select PDChoice field

Posted by Oliver Degener <ol...@monday-consulting.com>.
@Tilman I agree that setting an illegal option is the only bug here.

The other issue is more a matter of convenience. In my case I'm mapping HTML form data to PDFs, to be precise: input from <select> fields to PDChoice / PDComboBox fields. Both fields can be single or multi-valued. Ideally, I would work transparently with lists here and only expect errors when I try to set more than one entry on a single-valued PDChoice.

@Maruan You're correct, that's what I was trying to ask.

On 2021/08/17 06:05:18, "sahyoun@fileaffairs.de" <sa...@fileaffairs.de> wrote: 
> If I understand the question correctly it's about being able to use the
> List based setter with a single select option field if the List has a
> single entry. If the List has more than one entry still throw the
> exception.
> 
> Is that correct?
> 
> BR
> Maruan
> 
> Am Dienstag, dem 17.08.2021 um 04:47 +0200 schrieb Tilman Hausherr:
> > IMHO the only bug is that a setter can set an illegal option.
> > 
> > The rest looks fine to me, a user should know what field they are
> > filling.
> > 
> > Tilman
> > 
> > 
> > Am 16.08.2021 um 18:10 schrieb Oliver Degener:
> > > Hi,
> > > 
> > > I'm using PDFBox to automatically fill in all kinds of PDF
> > > documents. Recently, I was seeing the following error message with
> > > a new PDF:
> > > 'The list box does not allow multiple selections.'
> > > 
> > > I saw in the code that the PDChoice field can be single-select or
> > > multi-select. With single-select fields, the setter that takes a
> > > list of choices [0] throws an exception whenever the given list is
> > > not empty. Therefore I now have to use the general setter from
> > > PDField [1] which does not check whether the provided option is
> > > valid (selectable).
> > > 
> > > It would be great if the setter from [0] would also work for
> > > single-select choices and would only throw an exception if the
> > > list's size is greater than 1.
> > > 
> > > Any thoughts on this?
> > > 
> > > Thanks & Regards
> > > Oliver
> > > 
> > > [0]
> > > https://pdfbox.apache.org/docs/2.0.3/javadocs/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.html#setValue(java.util.List)
> > > [1]
> > > https://pdfbox.apache.org/docs/2.0.3/javadocs/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.html#setValue(java.lang.String)
> > > 
> > > -------------------------------------------------------------------
> > > --
> > > 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
> > 
> 
> -- 
> -- 
> Maruan Sahyoun
> 
> FileAffairs GmbH
> Josef-Schappe-Straße 21
> 40882 Ratingen
> 
> Tel: +49 (2102) 89497 88
> Fax: +49 (2102) 89497 91
> sahyoun@fileaffairs.de
> www.fileaffairs.de
> 
> Geschäftsführer: Maruan Sahyoun
> Handelsregister: AG Düsseldorf, HRB 53837
> UST.-ID: DE248275827
> 
> 
> ---------------------------------------------------------------------
> 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


Re: Setting the value of a single-select PDChoice field

Posted by "sahyoun@fileaffairs.de" <sa...@fileaffairs.de>.
If I understand the question correctly it's about being able to use the
List based setter with a single select option field if the List has a
single entry. If the List has more than one entry still throw the
exception.

Is that correct?

BR
Maruan

Am Dienstag, dem 17.08.2021 um 04:47 +0200 schrieb Tilman Hausherr:
> IMHO the only bug is that a setter can set an illegal option.
> 
> The rest looks fine to me, a user should know what field they are
> filling.
> 
> Tilman
> 
> 
> Am 16.08.2021 um 18:10 schrieb Oliver Degener:
> > Hi,
> > 
> > I'm using PDFBox to automatically fill in all kinds of PDF
> > documents. Recently, I was seeing the following error message with
> > a new PDF:
> > 'The list box does not allow multiple selections.'
> > 
> > I saw in the code that the PDChoice field can be single-select or
> > multi-select. With single-select fields, the setter that takes a
> > list of choices [0] throws an exception whenever the given list is
> > not empty. Therefore I now have to use the general setter from
> > PDField [1] which does not check whether the provided option is
> > valid (selectable).
> > 
> > It would be great if the setter from [0] would also work for
> > single-select choices and would only throw an exception if the
> > list's size is greater than 1.
> > 
> > Any thoughts on this?
> > 
> > Thanks & Regards
> > Oliver
> > 
> > [0]
> > https://pdfbox.apache.org/docs/2.0.3/javadocs/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.html#setValue(java.util.List)
> > [1]
> > https://pdfbox.apache.org/docs/2.0.3/javadocs/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.html#setValue(java.lang.String)
> > 
> > -------------------------------------------------------------------
> > --
> > 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
> 

-- 
-- 
Maruan Sahyoun

FileAffairs GmbH
Josef-Schappe-Straße 21
40882 Ratingen

Tel: +49 (2102) 89497 88
Fax: +49 (2102) 89497 91
sahyoun@fileaffairs.de
www.fileaffairs.de

Geschäftsführer: Maruan Sahyoun
Handelsregister: AG Düsseldorf, HRB 53837
UST.-ID: DE248275827


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


Re: Setting the value of a single-select PDChoice field

Posted by Tilman Hausherr <TH...@t-online.de>.
IMHO the only bug is that a setter can set an illegal option.

The rest looks fine to me, a user should know what field they are filling.

Tilman


Am 16.08.2021 um 18:10 schrieb Oliver Degener:
> Hi,
>
> I'm using PDFBox to automatically fill in all kinds of PDF documents. Recently, I was seeing the following error message with a new PDF:
> 'The list box does not allow multiple selections.'
>
> I saw in the code that the PDChoice field can be single-select or multi-select. With single-select fields, the setter that takes a list of choices [0] throws an exception whenever the given list is not empty. Therefore I now have to use the general setter from PDField [1] which does not check whether the provided option is valid (selectable).
>
> It would be great if the setter from [0] would also work for single-select choices and would only throw an exception if the list's size is greater than 1.
>
> Any thoughts on this?
>
> Thanks & Regards
> Oliver
>
> [0] https://pdfbox.apache.org/docs/2.0.3/javadocs/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.html#setValue(java.util.List)
> [1] https://pdfbox.apache.org/docs/2.0.3/javadocs/org/apache/pdfbox/pdmodel/interactive/form/PDChoice.html#setValue(java.lang.String)
>
> ---------------------------------------------------------------------
> 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