In Method: | drawCheckBoxAppearences(PdfFormField, String, float, float, float, float) |
Code with Finding: |
class PdfAcroForm {
/**
* @param field
* @param value
* @param llx
* @param lly
* @param urx
* @param ury
*/
public void drawCheckBoxAppearences(PdfFormField field, String value, float llx, float lly, float urx, float ury) {
BaseFont font = null;
try {
font = BaseFont.createFont(BaseFont.ZAPFDINGBATS, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
}
catch(Exception e) {
throw new ExceptionConverter(e);
}
float size = ury - lly;
PdfAppearance tpOn = PdfAppearance.createAppearance(writer, urx - llx, ury - lly);
PdfAppearance tp2 = (PdfAppearance)tpOn.getDuplicate();
tp2.setFontAndSize(font, size);
tp2.resetRGBColorFill();
field.setDefaultAppearanceString(tp2);
tpOn.drawTextField(0f, 0f, urx - llx, ury - lly);
tpOn.saveState();
tpOn.resetRGBColorFill();
tpOn.beginText();
tpOn.setFontAndSize(font, size);
tpOn.showTextAligned(PdfContentByte.ALIGN_CENTER, "4", (urx - llx) / 2, (ury - lly) / 2 - size * 0.3f, 0);
tpOn.endText();
tpOn.restoreState();
field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, value, tpOn);
PdfAppearance tpOff = PdfAppearance.createAppearance(writer, urx - llx, ury - lly);
tpOff.drawTextField(0f, 0f, urx - llx, ury - lly);
field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", tpOff);
}
}
|