[ 
https://issues.apache.org/jira/browse/PDFBOX-5859?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tilman Hausherr updated PDFBOX-5859:
------------------------------------
    Affects Version/s: 3.0.2 PDFBox

> StringIndexOutOfBoundsException in AppearanceGeneratorHelper
> ------------------------------------------------------------
>
>                 Key: PDFBOX-5859
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5859
>             Project: PDFBox
>          Issue Type: Bug
>          Components: AcroForm
>    Affects Versions: 2.0.32, 3.0.2 PDFBox
>            Reporter: Nicola Costantini
>            Priority: Blocker
>
> The bug fix for https://issues.apache.org/jira/browse/PDFBOX-5784 created 
> another issue.
> In AppearanceGeneratorHelper line 676 is assumed, that fields have non-empty 
> values:
>  
> {code:java}
> font.getStringWidth(value.substring(0, 1)){code}
>  
> resulting in this exceptions for empty fields, for example when 
> refreshAppearances is called:
>  
> {code:java}
> java.lang.StringIndexOutOfBoundsException: begin 0, end 1, length 0
>     at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4602)
>     at java.base/java.lang.String.substring(String.java:2705)
>     at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.insertGeneratedCombAppearance(AppearanceGeneratorHelper.java:676)
>     at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.insertGeneratedAppearance(AppearanceGeneratorHelper.java:569)
>     at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceContent(AppearanceGeneratorHelper.java:441)
>     at 
> org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.setAppearanceValue(AppearanceGeneratorHelper.java:248)
>     at 
> org.apache.pdfbox.pdmodel.interactive.form.PDTextField.constructAppearances(PDTextField.java:264)
>     at 
> org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm.refreshAppearances(PDAcroForm.java:361){code}
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to