re labels - there is nothing like a label as a property for an AcroForm field. Labels are regular and have to be placed similar to other page content.
BR Maruan > Am 11.11.2019 um 23:00 schrieb Dan Forth: > > Hi Tilman > > Sorry about the bad formatting. When I did the copy and paste it looked > > fine and included indentations. > > As for labels? We need to have a label next to an input box indicating > > for the user what information goes into it.We also need to be able add > > paragraphs of text to the form > > We did cerate a new PageContentStream with the true set to put it into > > append mode but nothing appeared oncewe saved the file. > > You need to set the "resetContent" parameter to true. That is the "fifth > parameter" I mentioned. > > re those "labels", what could be done is to see how another PDF does it, > by looking at it with PDFDebugger. > > Tilman > > > > Dan. > > On Monday, November 11, 2019, 01:28:38 PM EST, Tilman Hausherr > > <thaush...@t-online.de> wrote: > > > > Am 11.11.2019 um 19:18 schrieb Dan Forth: > > > Thank you Tilman. Haven't found the > > > CreateSimpleFormWithEmbeddedFont.java example but will search for it. > > > > This is in the source code download, in the examples subproject. > > > > I don't know what you mean with "label". The field name? A popup thing? > > (That one I don't know, probably javascript needed) > > > > Your code is difficult to understand, because the way it looks. I > > suspect your mailwriter is bad or not configured. Or try to use a fixed > > font, or use some formatting for code. > > > > Adding additional text - see the EmbeddedFonts.java program, but create > > a new PDPageContentStream with append mode. Make sure that the fifth > > parameter is used and set to true. > > > > Tilman > > > > > > > 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 > > > > > > > > > > > > --------------------------------------------------------------------- > > 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 > -- Maruan Sahyoun FileAffairs GmbH Josef-Schappe-Straße 21 40882 Ratingen Tel: +49 (2102) 89497 88 Fax: +49 (2102) 89497 91 sahy...@fileaffairs.de www.fileaffairs.de Geschäftsführer: Maruan Sahyoun Handelsregister: AG Düsseldorf, HRB 53837 UST.-ID: DE248275827 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org