pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maruan Sahyoun <sahy...@fileaffairs.de>
Subject Re: Draw a colored box around a PDField?
Date Thu, 06 Aug 2015 08:50:58 GMT
Hi,

the issue is that, although the definitions for the border have been made, they are not reflected
immediately as they don't become part of the widgets appearance stream. You need to refresh
the field appearance so that the changes become visible. Currently there is no such method
so you'd need to do it yourself.

I've created https://issues.apache.org/jira/browse/PDFBOX-2918 <https://issues.apache.org/jira/browse/PDFBOX-2918>
for that.

BR
Maruan

> Am 05.08.2015 um 21:06 schrieb Kevin Ternes <KTernes@thegeneral.com>:
> 
> That is not what I observe.
> Is there something missing from this code that I already have to color the PDAnnotationWidget
border?:
> 
> public static void highlightTextField3(final PDDocument pdDocument, final String fieldName,
final PDGamma borderPdGamma) throws IOException {
> 
>    PDDocumentCatalog catalog = pdDocument.getDocumentCatalog();
>    PDAcroForm pdAcroForm = catalog.getAcroForm();
> 
>    COSDictionary fieldCOSDictionary = pdField.getDictionary();
>    fieldCOSDictionary.setString(COSName.DA, FONT_TYPE_SIZE_WEIGHT_HIGHLIGHT);
> 
>    PDAppearanceCharacteristicsDictionary fieldPDAppearanceDictionary = new AppearanceCharacteristicsDictionary(new
COSDictionary());
>    fieldPDAppearanceDictionary.setBorderColour(borderPdGamma);
>    PDBorderStyleDictionary fieldPDBorderStyle = new PDBorderStyleDictionary();
>    fieldPDBorderStyle.setStyle(PDBorderStyleDictionary.STYLE_SOLID);
>    fieldPDBorderStyle.setWidth(3f);
> 
>    PDAnnotationWidget fieldPdAnnotationWidget = pdField.getWidget();
>    fieldPdAnnotationWidget.setAppearanceCharacteristics(fieldPDAppearanceDictionary);
>    fieldPdAnnotationWidget.setBorderStyle(fieldPDBorderStyle);
> 
>    fieldPdAnnotationWidget.setHidden(false);
>    fieldPdAnnotationWidget.setInvisible(false);
>    fieldPdAnnotationWidget.setLocked(true);
>    fieldPdAnnotationWidget.setHighlightingMode("P");
> }
> 
> 
> 
> -----Original Message-----
> From: Gilad Denneboom [mailto:gilad.denneboom@gmail.com] 
> Sent: Wednesday, August 05, 2015 1:43 PM
> To: users@pdfbox.apache.org
> Subject: Re: Draw a colored box around a PDField?
> 
> No, that's not true. The field's border color is visible regardless of that setting in
Reader.
> 
> On Wed, Aug 5, 2015 at 8:05 PM, Kevin Ternes <KTernes@thegeneral.com> wrote:
> 
>> Right.  But that works only if the Highlight Existing Fields option on 
>> Adobe Reader is selected.
>> It seems like I could put a colored box around the field that would 
>> appear on the screen independent of the field.
>> 
>> 
>> -----Original Message-----
>> From: Tilman Hausherr [mailto:THausherr@t-online.de]
>> Sent: Wednesday, August 05, 2015 12:20 PM
>> To: users@pdfbox.apache.org
>> Subject: Re: Draw a colored box around a PDField?
>> 
>> Am 05.08.2015 um 18:00 schrieb Kevin Ternes:
>>> For a given document and field name, it seems like a simple matter 
>>> to
>> draw a colored box around the contents of the field.  But I cannot 
>> figure out how to do it.  So far, I have the following.  But where do 
>> I go from here?
>>> 
>>> PDDocumentCatalog catalog = pdDocument.getDocumentCatalog(); 
>>> PDAcroForm pdAcroForm = catalog.getAcroForm(); PDField pdField = 
>>> pdAcroForm.getField(fieldName); COSDictionary pdFieldDictionary = 
>>> pdField.getDictionary();
>>> 
>>> PDAnnotationTextMarkup pdatMarkup = new 
>>> PDAnnotationTextMarkup(PDAnnotationSquareCircle.SUB_TYPE_SQUARE);
>>> pdatMarkup.setColour(borderPdGamma);
>>> 
>> 
>> see the reply here:
>> http://qnalist.com/questions/4842300/form-elements-not-visible
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message