Skip to content

Commit dc601c1

Browse files
author
Samuel Huylebroeck
committed
Catch NPE error and use a default value for a Pushbutton
DEVSIX-2526
1 parent a019509 commit dc601c1

File tree

4 files changed

+9
-0
lines changed

4 files changed

+9
-0
lines changed

forms/src/main/java/com/itextpdf/forms/fields/PdfFormField.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3222,6 +3222,9 @@ protected void drawButton(PdfCanvas canvas, float x, float y, float width, float
32223222
if (color == null) {
32233223
color = ColorConstants.BLACK;
32243224
}
3225+
if(text == null){
3226+
text="";
3227+
}
32253228

32263229
Paragraph paragraph = new Paragraph(text).setFont(font).setFontSize(fontSize).setMargin(0).setMultipliedLeading(1).
32273230
setVerticalAlignment(VerticalAlignment.MIDDLE);

forms/src/test/java/com/itextpdf/forms/FormFieldFlatteningTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,10 @@ public void flattenReadOnly() throws IOException{
230230
pdfDoc.close();
231231
Assert.assertFalse(isReadOnly);
232232
}
233+
234+
@Test
235+
public void fieldsRegeneratePushButtonWithoutCaption() throws IOException, InterruptedException {
236+
fillTextFieldsThenFlattenThenCompare("pushbutton_without_caption");
237+
}
238+
233239
}

0 commit comments

Comments
 (0)