pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1809524 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Date Sun, 24 Sep 2017 15:30:06 GMT
Author: msahyoun
Date: Sun Sep 24 15:30:06 2017
New Revision: 1809524

URL: http://svn.apache.org/viewvc?rev=1809524&view=rev
Log:
PDFBOX-3911: ignore line breaking and similar characters in single line text fields

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java?rev=1809524&r1=1809523&r2=1809524&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Sun Sep 24 15:30:06 2017
@@ -148,6 +148,17 @@ class AppearanceGeneratorHelper
     public void setAppearanceValue(String apValue) throws IOException
     {
         value = apValue;
+        
+        // Treat multiline field values in single lines as single lime values.
+        // This is in line with how Adobe Reader behaves when enetring text
+        // interactively but NOT how it behaves when the field value has been
+        // set programmatically and Reader is forced to generate the appearance
+        // using PDAcroForm.setNeedAppearances
+        // see PDFBOX-3911
+        if (field instanceof PDTextField && !((PDTextField) field).isMultiline())
+        {
+            value = apValue.replaceAll("\\u000D\\u000A|[\\u000A\\u000B\\u000C\\u000D\\u0085\\u2028\\u2029]",
" ");
+        }
 
         for (PDAnnotationWidget widget : field.getWidgets())
         {



Mime
View raw message