pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Ternes <KTer...@thegeneral.com>
Subject RE: Setting a border color on a PDTextBox
Date Mon, 15 Jun 2015 16:03:51 GMT
I ran the code using both "Named Insured" and "Medical Payments".

It took me some time to figure out what you meant by saying they have the green border.  
Finally, I open the processed PDF _directly_ using Adobe Acrobat 11.0.11 and I DO SEE the
green borders.

But the problem is apparently in the display via Firefox that automatically opens to view
PDFs processed by the web app I am working on.
It does not display the green borders.
Since Adobe Acrobat has a plug-in installed in my Firefox, I would assume that they should
display the same.

Digging deeper, there is software installed on my workstation called Bullzip PDF Printer that
Firefox is using in lieu of Acrobat.

Problem solved.  Thank you Tilman!


-----Original Message-----
From: Tilman Hausherr [mailto:THausherr@t-online.de] 
Sent: Monday, June 15, 2015 9:50 AM
To: users@pdfbox.apache.org
Subject: Re: Setting a border color on a PDTextBox

Which is the field (fieldname) that you wanted to set with green border? 
I ask because two fields do have a green border, the field below "Insured:" (fieldname "Named
Insured") and the one near "Medical Payments" (field name: "MedicalPayments").

Tilman

Am 15.06.2015 um 15:45 schrieb Kevin Ternes:
> Tilman wrote:
>> From: Tilman Hausherr [mailto:THausherr@t-online.de]
>> Sent: Friday, June 12, 2015 2:41 PM
>> To: users@pdfbox.apache.org
>> Subject: Re: Setting a border color on a PDTextBox
>>
>> Am 12.06.2015 um 18:59 schrieb Kevin Ternes:
>>> Tilman wrote:
>>>> From: Tilman Hausherr [mailto:THausherr@t-online.de]
>>>> Sent: Thursday, June 11, 2015 4:27 PM
>>>> To: users@pdfbox.apache.org
>>>> Subject: Re: Setting a border color on a PDTextBox
>>>>
>>>> Am 11.06.2015 um 22:44 schrieb Kevin Ternes:
>>>>> 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:
>>>>>        
>>>>> https://dl.dropboxusercontent.com/u/3103884/dev/PdfBoxMockupCapture.
>>>>> png
>>>>>
>>>>>       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();
>>>>>       pdGamma.setR(0);
>>>>>       pdGamma.setG(1);
>>>>>       pdGamma.setB(0);
>>>>>       PDAppearanceCharacteristicsDictionary pdApDict = new PDAppearanceCharacteristicsDictionary(pdFieldDictionary);
>>>>>       pdApDict.setBorderColour(pdGamma);
>>>>>
>>>>>       PDTextbox pdTextBox = new PDTextbox(pdAcroForm, pdFieldDictionary);
>>>>>       PDAppearance pdAppearance = new PDAppearance(pdAcroForm, 
>>>>> pdTextBox);
>>>>>       
>>>>> pdAppearance.setAppearanceValue(PDLayoutAttributeObject.BORDER_STY
>>>>> LE
>>>>> _S
>>>>> OLID);
>>>>>
>>>>> 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?
>>>> Try this:
>>>>
>>>> http://qnalist.com/questions/4842300/form-elements-not-visible
>>>> PDAnnotationWidget fieldAnnot = pdTextBox.getWidget(); 
>>>> fieldAnnot.setAppearanceCharacteristics(pdApDict);
>>>>
>>>> Tilman
>>> That is not working for me either.
>>> I stole all the code on the referenced qnalist page (see below) but I still do
not get the solid colored border that I am looking for.
>>>
>>>      PDDocumentCatalog catalog = pdDocument.getDocumentCatalog();
>>>      PDAcroForm pdAcroForm = catalog.getAcroForm();
>>>      PDField pdField = pdAcroForm.getField(fieldName);
>>>      COSDictionary pdFieldDictionary = pdField.getDictionary();
>>>      PDTextbox pdTextBox = new PDTextbox(pdAcroForm, pdFieldDictionary);
>>>      PDAnnotationWidget fieldAnnot = pdTextBox.getWidget();
>>> 	
>>>      PDAppearanceCharacteristicsDictionary fieldAppearance = new PDAppearanceCharacteristicsDictionary(new
COSDictionary());
>>>      PDGamma colourGreen = new PDGamma();
>>>      colourGreen.setR(0);
>>>      colourGreen.setG(1);
>>>      colourGreen.setB(0);
>>>      fieldAppearance.setBorderColour(colourGreen);
>>>      PDBorderStyleDictionary fieldBorderStyle = new PDBorderStyleDictionary();
>>>      fieldBorderStyle.setStyle(PDBorderStyleDictionary.STYLE_SOLID);
>>>      fieldBorderStyle.setWidth(2f);
>>>      fieldAnnot.setAppearanceCharacteristics(fieldAppearance);
>>>      fieldAnnot.setBorderStyle(fieldBorderStyle);
>>>
>>> If anyone can give me another hint, it would be much appreciated.
>> Could you please open the created PDF with an editor like NOTEPAD++ and post the
readable part? What I'm interested is the parts with /MK and with /BC:
>>
>> 5 0 obj
>> <<
>> /FT /Tx
>> /T (SampleField)
>> /Type /Annot
>> /Subtype /Widget
>> /Rect [50.0 750.0 250.0 800.0]
>> /MK 7 0 R   <===========================
>> /V (English form contents)
>> /AP 8 0 R
>> endobj
>> 6 0 obj
>> <<
>> /Font 9 0 R
>> endobj
>> 7 0 obj
>> <<
>> /BC [0.0 1.0 0.0]   <===========================
>> endobj
>>
>> Tilman
>>
> I cut out the part between the /MK right before the field of interest and the first BC
after that.
> Thanks for looking at this for me! The whole PDF is here in case you need it:
>    https://dl.dropboxusercontent.com/u/3103884/dev/PdfBox-Output-1.pdf
>
> /MK 43 0 R
> /P 41 0 R
> /Rect [58.1228 566.0 250.123 583.0]
> /Subtype /Widget
> /T (Named Insured)
> /Type /Annot
> /V (PDFBox User M. Ockup)
> /BS 44 0 R
> endobj
> 10 0 obj
> <<
> /AP <<
> /N 45 0 R
> /DA (/TimesNewRoman 11 Tf 0 g)
> /F 4
> /FT /Tx
> /Ff 4194304
> /MK <<
> /P 41 0 R
> /Rect [58.1228 545.0 250.123 563.0]
> /Subtype /Widget
> /T (Named Insured Address)
> /Type /Annot
> endobj
> 11 0 obj
> <<
> /AP <<
> /N 46 0 R
> /DA (/TimesNewRoman 11 Tf 0 g)
> /F 4
> /FT /Tx
> /Ff 4194304
> /MK <<
> /P 41 0 R
> /Rect [58.1228 525.0 249.123 543.0]
> /Subtype /Widget
> /T (Named Insured City State)
> /Type /Annot
> endobj
> 12 0 obj
> <<
> /AP <<
> /N 47 0 R
> /DA (/TimesNewRoman 11 Tf 0 g)
> /F 4
> /FT /Tx
> /Ff 4194304
> /MK <<
> /P 41 0 R
> /Q 2
> /Rect [266.123 562.0 293.123 580.0]
> /Subtype /Widget
> /T (AddVehicleYear)
> /Type /Annot
> endobj
> 13 0 obj
> <<
> /AP <<
> /N 48 0 R
> /DA (/TimesNewRoman 11 Tf 0 g)
> /F 4
> /FT /Tx
> /Ff 4198400
> /MK <<
> /P 41 0 R
> /Rect [300.123 562.0 532.123 580.0]
> /Subtype /Widget
> /T (AddVehicleMakeModel)
> /Type /Annot
> endobj
> 14 0 obj
> <<
> /AP <<
> /N 49 0 R
> /DA (/TimesNewRoman 11 Tf 0 g)
> /F 4
> /FT /Tx
> /Ff 4194304
> /MK <<
> /P 41 0 R
> /Rect [301.123 540.0 530.123 557.0]
> /Subtype /Widget
> /T (AddVehicleVIN)
> /Type /Annot
> endobj
> 15 0 obj
> <<
> /AA <<
> /F 50 0 R
> /K 51 0 R
> /AP <<
> /N 52 0 R
> /DA (/Arial 11 Tf 0 g)
> /F 4
> /FT /Tx
> /Ff 4194304
> /MK <<
> /P 41 0 R
> /Rect [437.123 407.0 534.123 420.0]
> /Subtype /Widget
> /T (BinderLiabilityLimitPer)
> /Type /Annot
> endobj
> 16 0 obj
> <<
> /AA <<
> /F 53 0 R
> /K 54 0 R
> /AP <<
> /N 55 0 R
> /DA (/Arial 11 Tf 0 g)
> /F 4
> /FT /Tx
> /Ff 4194304
> /MK <<
> /P 41 0 R
> /Rect [437.123 390.0 534.123 404.0]
> /Subtype /Widget
> /T (BinderLiabilityLimitAcc)
> /Type /Annot
> endobj
> 17 0 obj
> <<
> /AA <<
> /F 56 0 R
> /K 57 0 R
> /AP <<
> /N 58 0 R
> /DA (/Arial 11 Tf 0 g)
> /F 4
> /FT /Tx
> /Ff 4194304
> /MK <<
> /P 41 0 R
> /Rect [437.123 373.0 533.123 387.0]
> /Subtype /Widget
> /T (BinderLiabilityLimitPro)
> /Type /Annot
> endobj
> 18 0 obj
> <<
> /AA <<
> /F 59 0 R
> /K 60 0 R
> /AP <<
> /N 61 0 R
> /DA (/TimesNewRoman 9 Tf 0 g)
> /F 4
> /FT /Tx
> /Ff 4194304
> /MK <<
> /P 41 0 R
> /Q 2
> /Rect [133.015 273.323 197.34 286.296] /Subtype /Widget /T (Collded) 
> /Type /Annot endobj
> 19 0 obj
> <<
> /AP <<
> /D <<
> /Off 62 0 R
> /Yes 63 0 R
> /N <<
> /Off 64 0 R
> /Yes 65 0 R
>>>
> /AS /Off
> /BS <<
> /S /I
> /W 1
> /DA (/ZaDb 10 Tf 0 g)
> /F 4
> /FT /Btn
> /MK <<
> /BC [0.0 0.0 0.0]



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


Mime
View raw message