Thank you Tilman.  Haven't found the CreateSimpleFormWithEmbeddedFont.java 
example but will search for it.
The next question that follows is there an example on line to add labels to 
form fields created using widgets and text in between the fields?
The code below works to add a text field to page two of a .pdf.   We're looking 
for an example of how to add a label to this fieldand how to add additional 
paragraphs of text to the pages between the fields on any given page.   Thank 
you folks in advance again:


PDTextField textFieldHomePhone = new PDTextField(form); 
textFieldHomePhone.setPartialName("Home Phone");  //set default appearance 
textFieldHomePhone.setDefaultAppearance(defaultAppearance);  
form.getFields().add(textFieldHomePhone);  PDAnnotationWidget widgetHomePhone = 
textFieldHomePhone.getWidgets().get(0); PDRectangle rectHomePhone = new 
PDRectangle(50, 750, 200, 20); widgetHomePhone.setRectangle(rectHomePhone); 
widgetHomePhone.setPage(page2);  PDAppearanceCharacteristicsDictionary 
fieldAppearanceHomePhone = new PDAppearanceCharacteristicsDictionary(new 
COSDictionary()); fieldAppearanceHomePhone.setBorderColour(new PDColor(new 
float[] {2,2,2}, PDDeviceRGB.INSTANCE)); 
fieldAppearanceHomePhone.setBackground(new PDColor(new float[] {1,1,2}, 
PDDeviceRGB.INSTANCE)); 
widgetHomePhone.setAppearanceCharacteristics(fieldAppearanceHomePhone);  
widgetHomePhone.setPrinted(true); try { 
page2.getAnnotations().add(widgetHomePhone); } catch (IOException e1) { // TODO 
Auto-generated catch block e1.printStackTrace(); } try { 
textFieldHomePhone.setValue("(###)-###-####"); } catch (IOException e1) { // 
TODO Auto-generated catch block e1.printStackTrace(); } 
    On Monday, November 11, 2019, 01:11:38 PM EST, Tilman Hausherr 
<thaush...@t-online.de> wrote:  
 
 Hi,

There is an example on how to change the default appearance in existing 
fields
https://stackoverflow.com/questions/47995062/pdfbox-api-how-to-change-font-to-handle-cyrillic-values-in-an-acroform-field

and see also the CreateSimpleFormWithEmbeddedFont.java example. Maybe 
this helps.

Tilman


Am 11.11.2019 um 18:12 schrieb Dan Forth:
>  Thank you for the fast response.   We're currently typing out the defaults 
>as in the code below:
>  PDFont font = PDType1Font.HELVETICA; PDResources resources = new 
>PDResources(); resources.put(COSName.getPDFName("Helv"), font); 
>form.setDefaultResources(resources);
>
>  PDTextField textSSN = new PDTextField(form); textSSN.setPartialName("SSN");  
>String defaultAppearance = "/Helv 12 Tf 0 0 9 rgb"; 
>textSSN.setDefaultAppearance(defaultAppearance);
>
> In some cases we need Helvetica in italics for select fields of text would 
> like to be able to take the four lines and condense theminto a class and be 
> able to change the Helvetica to Helvetica Italic  as a passed parameter.
> And be able to do the same for display setting for selected fields:
>  PDAppearanceCharacteristicsDictionary fieldAppearance = new 
>PDAppearanceCharacteristicsDictionary(new       COSDictionary()); 
>fieldAppearance.setBorderColour(new PDColor(new float[] {2,2,2}, 
>PDDeviceRGB.INSTANCE)); fieldAppearance.setBackground(new PDColor(new float[] 
>{1,1,2}, PDDeviceRGB.INSTANCE)); 
>widget.setAppearanceCharacteristics(fieldAppearance);
> We were hoping there was a shorter way than having to type all the lines for 
> every text field we need to add.
> Thank you again for any insight.    On Monday, November 11, 2019, 11:49:29 AM 
> EST, Maruan Sahyoun <sahy...@fileaffairs.de> wrote:
>  
>  Not sure I understand what you are trying to achieve.
>
> AcroForm itself is not page oriented but the widgets i.e. the visual 
> representation of the form fields are.
>
> It's sufficient to add the default resources to the AcroForm itself and 
> reference these in the form fields default appearance
> string.
>
> Maybe you could show some code of what you are currently doing and we can 
> look at ways to improve that?
>
> BR
> Maruan
>
>    
>> Is there a tutorial on how to create the default resources and default 
>> appearance settings in classes that can be applied when creating acro forms 
>> of multiple pages?  It would be useful to be able to create multiple default 
>> resource or appearance classes and apply them to the acro form fields as 
>> needed rather than type each one out in the long form
>> Thank you in advance for any suggestions you can offer this newb.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
> For additional commands, e-mail: users-h...@pdfbox.apache.org
>
>    



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

  

Reply via email to