pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: Setting one radio button on by default
Date Wed, 19 Jul 2017 05:58:18 GMT
Yes. If you don't need appearance streams. If you want appearance 
streams it's even worse.

Tilman

Am 19.07.2017 um 00:25 schrieb Gary Grosso:
> Should I infer from the lack of any response whatsoever that https://www.mail-archive.com/users@pdfbox.apache.org/msg08490.html
is the state of the art?
>
> Best regards,
> Gary
>
>
> -----Original Message-----
> From: Gary Grosso [mailto:gary.grosso@oberontech.com]
> Sent: Monday, July 17, 2017 4:00 PM
> To: users@pdfbox.apache.org
> Subject: Setting one radio button on by default
>
> I know this has been answered before, but when I look at the answers, I have to wonder
if there is now an easier way.
>
> Below is my code which is all I need to display working radio buttons.
>
> What is the minimum I need to do to set one of a group of buttons on by default? I'm
hoping it's easier than all of https://www.mail-archive.com/users@pdfbox.apache.org/msg08490.html
but if that's really all necessary, so be it...
>
> Thanks,
> Gary
>
>          private static void addRadiobuttonAtRect(PDPage page, PDAcroForm acroForm, String
name,
>                          Map<String, String> optionMap, PDRectangle rect) {
>          PDRadioButton radioButton = new PDRadioButton(acroForm);
>
>          String grp = Utils.unescapeChar(optionMap.get("grp"));
>          radioButton.setPartialName(grp);
>
>          acroForm.getFields().add(radioButton);
>
>          // Specify the annotation associated with the field and its location.
>          PDAnnotationWidget widget = radioButton.getWidgets().get(0);
>          widget.setRectangle(rect);
>          rect.setLowerLeftX((float) (rect.getLowerLeftX() - 18));
>          rect.setUpperRightX((float) (rect.getLowerLeftX() + 10));
>
>          widget.setPage(page);
>
>          PDAppearanceCharacteristicsDictionary fieldAppearance
>                  = new PDAppearanceCharacteristicsDictionary(new COSDictionary());
>                  fieldAppearance.setBorderColour(Utils.hexToPDColor(optionMap.get("brdclr")));
>                  fieldAppearance.setBackground(Utils.hexToPDColor(optionMap.get("bclr")));
>          widget.setAppearanceCharacteristics(fieldAppearance);
>
>          // make sure the annotation is visible on screen and paper
>          widget.setPrinted(true);
>
>          // Add the annotation to the page
>          try {
>                          page.getAnnotations().add(widget);
>                  } catch (IOException e) {
>                          e.printStackTrace();
>                  }
>          }
>
>
>
> ---------------------------------------------------------------------
> 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