Hello, I'm creating
a pdf form with iText and can't figure out how to get a label on a push button.
I've tried showText and all of the setValue methods. Here's the code I hijacked
from somplace on the iText site. it works great except no
label.
Thanks,
David
Mease
PdfFormField pushbutton =
PdfFormField.createPushButton(writer);
cb = writer.getDirectContent();
cb.moveTo(0, 0);
PdfAppearance normal = cb.createAppearance(30, 30);
normal.setColorFill(Color.LIGHT_GRAY);
normal.rectangle(0, 0, 30, 30);
normal.fill();
// normal.setFontAndSize(BFarialn, 9);
// normal.beginText();
// normal.showText("Submit");
// normal.endText();
PdfAppearance rollover = cb.createAppearance(30, 30);
rollover.setColorFill(Color.LIGHT_GRAY);
rollover.rectangle(0, 0, 30, 30);
rollover.fill();
PdfAppearance down = cb.createAppearance(30, 30);
down.setColorFill(Color.GRAY);
down.rectangle(0, 0, 30, 30);
down.fill();
// down.showText("Submit");
pushbutton.setFieldName("Submit");
Object options [] = {"Addendum", "type"};
PdfAction pdfAction = new PdfAction();
pushbutton.setAction(pdfAction.createSubmitForm("http://localhost:8080/test/servlet/parseManagerAccidentReportServlet", options, PdfAction.SUBMIT_HTML_FORMAT));
pushbutton.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, normal);
pushbutton.setAppearance(PdfAnnotation.APPEARANCE_ROLLOVER, rollover);
pushbutton.setAppearance(PdfAnnotation.APPEARANCE_DOWN, down);
pushbutton.setWidget(new Rectangle(290, vertLinePos - 125, 340, vertLinePos - 110), PdfAnnotation.HIGHLIGHT_PUSH);
writer.addAnnotation(pushbutton);
cb = writer.getDirectContent();
cb.moveTo(0, 0);
PdfAppearance normal = cb.createAppearance(30, 30);
normal.setColorFill(Color.LIGHT_GRAY);
normal.rectangle(0, 0, 30, 30);
normal.fill();
// normal.setFontAndSize(BFarialn, 9);
// normal.beginText();
// normal.showText("Submit");
// normal.endText();
PdfAppearance rollover = cb.createAppearance(30, 30);
rollover.setColorFill(Color.LIGHT_GRAY);
rollover.rectangle(0, 0, 30, 30);
rollover.fill();
PdfAppearance down = cb.createAppearance(30, 30);
down.setColorFill(Color.GRAY);
down.rectangle(0, 0, 30, 30);
down.fill();
// down.showText("Submit");
pushbutton.setFieldName("Submit");
Object options [] = {"Addendum", "type"};
PdfAction pdfAction = new PdfAction();
pushbutton.setAction(pdfAction.createSubmitForm("http://localhost:8080/test/servlet/parseManagerAccidentReportServlet", options, PdfAction.SUBMIT_HTML_FORMAT));
pushbutton.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, normal);
pushbutton.setAppearance(PdfAnnotation.APPEARANCE_ROLLOVER, rollover);
pushbutton.setAppearance(PdfAnnotation.APPEARANCE_DOWN, down);
pushbutton.setWidget(new Rectangle(290, vertLinePos - 125, 340, vertLinePos - 110), PdfAnnotation.HIGHLIGHT_PUSH);
writer.addAnnotation(pushbutton);
