Skip to content

Commit

Permalink
PDFBOX-5859: avoid NPE or StringIndexOutOfBoundsException
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1919633 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
THausherr committed Aug 2, 2024
1 parent d0ca245 commit 5569825
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,10 @@ private boolean shallComb()
private void insertGeneratedCombAppearance(PDAppearanceContentStream contents, PDAppearanceStream appearanceStream,
PDFont font, float fontSize) throws IOException
{
if (value == null || value.isEmpty())
{
return;
}
int maxLen = ((PDTextField) field).getMaxLen();
int quadding = field.getQ();
int numChars = Math.min(value.length(), maxLen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@ void testCombFields() throws IOException
{
PDAcroForm acroForm = document.getDocumentCatalog().getAcroForm();
PDField field = acroForm.getField("PDFBoxCombLeft");
field.setValue("");
field.setValue(TEST_VALUE);
field = acroForm.getField("PDFBoxCombMiddle");
field.setValue("");
field.setValue(TEST_VALUE);
field = acroForm.getField("PDFBoxCombRight");
field.setValue("");
field.setValue(TEST_VALUE);
// compare rendering
File file = new File(OUT_DIR, NAME_OF_PDF);
Expand Down

0 comments on commit 5569825

Please sign in to comment.