You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2020/08/19 17:40:38 UTC

svn commit: r1881001 - /pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/CreateSimpleForm.java

Author: tilman
Date: Wed Aug 19 17:40:37 2020
New Revision: 1881001

URL: http://svn.apache.org/viewvc?rev=1881001&view=rev
Log:
PDFBOX-4892: add alignment, inspired by SO question 63486407

Modified:
    pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/CreateSimpleForm.java

Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/CreateSimpleForm.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/CreateSimpleForm.java?rev=1881001&r1=1881000&r2=1881001&view=diff
==============================================================================
--- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/CreateSimpleForm.java (original)
+++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/interactive/form/CreateSimpleForm.java Wed Aug 19 17:40:37 2020
@@ -33,6 +33,7 @@ import org.apache.pdfbox.pdmodel.interac
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceCharacteristicsDictionary;
 import org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm;
 import org.apache.pdfbox.pdmodel.interactive.form.PDTextField;
+import org.apache.pdfbox.pdmodel.interactive.form.PDVariableText;
 
 /**
  * An example of creating an AcroForm and a form field from scratch.
@@ -105,7 +106,10 @@ public final class CreateSimpleForm
         
         // Add the widget annotation to the page
         page.getAnnotations().add(widget);
-        
+
+        // set the alignment ("quadding")
+        textBox.setQ(PDVariableText.QUADDING_CENTERED);
+
         // set the field value
         textBox.setValue("Sample field content");