Is there a way to change button text on a form field?

I have a button in a form field (type e_button) and I can set the name, but this is different from the text on the actual button. Is there a way to programmatically change that text?

Thanks,

Ferrol

Hi, you want to call the function Widget.SetStaticCaptionText
http://www.pdftron.com/pdfnet/docs/PDFNet/?topic=html/M_pdftron_PDF_Annots_Widget_SetStaticCaptionText.htm

Hey Ryan,

Thanks for this. Is there some sample code showing how to get to the Widget associated with an e_button field?

Thanks again,

Ferrol

Hi Ryan,

I made this code and it shows the caption and you can see where I’m setting it. However the text is not updated in the form even though I call setDoc on PDFViewCtrl afterwards. Is there some sort of commit operation I need to do for this to take effect on the doc?

PageIterator pi = doc.getPageIterator(); if (pi.hasNext()) { Page page = (Page) pi.next(); for (int i = page.getNumAnnots()-1; i>=0; --i) { Annot annot = page.getAnnot(i); if (annot.getType() == Annot.e_Widget) { Widget widget = new Widget(annot); Field field = widget.getField(); if (field.getType() == Field.e_button && field.getName().toUpperCase().contains("SUBMIT")) { String caption = widget.getStaticCaptionText(); widget.setStaticCaptionText(""); } } } }

Thanks,

Ferrol

Probably the Widget annotation already as an Appearance stream, which means no PDF reader will look at the static caption text.

After calling setStaticCaptionText, either call Annot.removeAppearance or Annot.refreshAppearance and the new caption should appear.