pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Ternes <KTer...@thegeneral.com>
Subject Setting a border color on a PDTextBox
Date Thu, 11 Jun 2015 20:44:06 GMT
I am using PDFBox 1.8.9 to change an existing PDF.
The requirement is to change an existing field so that the text is Helvetica Bold and bordered
with a given color.
A mockup of the desired PDF is here:
   Given PDDocument pdDocument...:

   PDDocumentCatalog catalog = pdDocument.getDocumentCatalog();
   PDAcroForm pdAcroForm = catalog.getAcroForm();
   PDField pdField = pdAcroForm.getField(fieldName);

   COSDictionary pdFieldDictionary = pdField.getDictionary();
   COSString defaultAppearance = (COSString) pdFieldDictionary.getDictionaryObject(COSName.DA);
   if (defaultAppearance != null) {
       pdFieldDictionary.setString(COSName.DA, "/HeBo 9 Tf 0 g");

   PDGamma pdGamma = new PDGamma();
   PDAppearanceCharacteristicsDictionary pdApDict = new PDAppearanceCharacteristicsDictionary(pdFieldDictionary);

   PDTextbox pdTextBox = new PDTextbox(pdAcroForm, pdFieldDictionary);
   PDAppearance pdAppearance = new PDAppearance(pdAcroForm, pdTextBox);

I am getting the Helvetica Bold change but I am missing the colored border.
Can anyone tell me what I am missing or doing wrong?

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

View raw message