You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Akshay Rawat <pr...@akshay.cc> on 2013/11/28 11:07:46 UTC

Overriding the font of a PDField

I am working with an acroform which has fields. These fields specify their own fonts to use when a value is set (using `setValue`).

Is there a way to override this font of the PDField, such that `setValue` text appears in a different font.

I’ve asked this question here too.


Thanks.


Akshay Rawat

Skype: akshayrawat
Mobile: +91 9538780000
http://www.akshay.cc




Re: Overriding the font of a PDField

Posted by Akshay Rawat <pr...@akshay.cc>.
Thank you for your awesome explanation, that worked.


On Nov 28, 2013, at 4:13 PM, Gilad Denneboom <gi...@gmail.com> wrote:

> It's a String, so you can actually use
> getDictionary().getString(COSName.DA) ... If you want to change the font
> used you'll need to find the correct font name. The best way would be to
> manually set a field to the properties you want to use, run the code and
> then use that string to set the DA property in your app.
> 
> Keep in mind that this action will not embed the font in the file. So if
> you're using non-standard fonts they will not be available for someone who
> doesn't have them installed on their computer.
> 
> 
> On Thu, Nov 28, 2013 at 11:39 AM, Akshay Rawat <pr...@akshay.cc> wrote:
> 
>> Thanks for that.
>> 
>> 
>> In PDFBox is see that
>> 
>>      dap = textbox.getDictionary().getDictionaryObject(COSName.DA)
>> 
>> gets the default appearance, which is a COSString. How do I use that to
>> change the font for the particular field.
>> 
>> 
>> 
>> 
>> On Nov 28, 2013, at 3:55 PM, Gilad Denneboom <gi...@gmail.com>
>> wrote:
>> 
>>> The font used has nothing to do with the value of the field. This
>>> information is encoded in the DA attribute of the field, which you can
>> read
>>> and write using via the field's COSDictionary object. AFAIK, there are no
>>> direct getters or setters for this property.
>>> 
>>> 
>>> On Thu, Nov 28, 2013 at 11:07 AM, Akshay Rawat <pr...@akshay.cc>
>> wrote:
>>> 
>>>> I am working with an acroform which has fields. These fields specify
>> their
>>>> own fonts to use when a value is set (using `setValue`).
>>>> 
>>>> Is there a way to override this font of the PDField, such that
>> `setValue`
>>>> text appears in a different font.
>>>> 
>>>> I’ve asked this question here too.
>>>> 
>>>> 
>>>> Thanks.
>>>> 
>>>> 
>>>> Akshay Rawat
>>>> 
>>>> Skype: akshayrawat
>>>> Mobile: +91 9538780000
>>>> http://www.akshay.cc
>>>> 
>>>> 
>>>> 
>>>> 
>> 
>> 


Re: Overriding the font of a PDField

Posted by Gilad Denneboom <gi...@gmail.com>.
It's a String, so you can actually use
getDictionary().getString(COSName.DA) ... If you want to change the font
used you'll need to find the correct font name. The best way would be to
manually set a field to the properties you want to use, run the code and
then use that string to set the DA property in your app.

Keep in mind that this action will not embed the font in the file. So if
you're using non-standard fonts they will not be available for someone who
doesn't have them installed on their computer.


On Thu, Nov 28, 2013 at 11:39 AM, Akshay Rawat <pr...@akshay.cc> wrote:

> Thanks for that.
>
>
> In PDFBox is see that
>
>       dap = textbox.getDictionary().getDictionaryObject(COSName.DA)
>
> gets the default appearance, which is a COSString. How do I use that to
> change the font for the particular field.
>
>
>
>
> On Nov 28, 2013, at 3:55 PM, Gilad Denneboom <gi...@gmail.com>
> wrote:
>
> > The font used has nothing to do with the value of the field. This
> > information is encoded in the DA attribute of the field, which you can
> read
> > and write using via the field's COSDictionary object. AFAIK, there are no
> > direct getters or setters for this property.
> >
> >
> > On Thu, Nov 28, 2013 at 11:07 AM, Akshay Rawat <pr...@akshay.cc>
> wrote:
> >
> >> I am working with an acroform which has fields. These fields specify
> their
> >> own fonts to use when a value is set (using `setValue`).
> >>
> >> Is there a way to override this font of the PDField, such that
> `setValue`
> >> text appears in a different font.
> >>
> >> I’ve asked this question here too.
> >>
> >>
> >> Thanks.
> >>
> >>
> >> Akshay Rawat
> >>
> >> Skype: akshayrawat
> >> Mobile: +91 9538780000
> >> http://www.akshay.cc
> >>
> >>
> >>
> >>
>
>

Re: Overriding the font of a PDField

Posted by Akshay Rawat <pr...@akshay.cc>.
Thanks for that.


In PDFBox is see that 

      dap = textbox.getDictionary().getDictionaryObject(COSName.DA)

gets the default appearance, which is a COSString. How do I use that to change the font for the particular field.




On Nov 28, 2013, at 3:55 PM, Gilad Denneboom <gi...@gmail.com> wrote:

> The font used has nothing to do with the value of the field. This
> information is encoded in the DA attribute of the field, which you can read
> and write using via the field's COSDictionary object. AFAIK, there are no
> direct getters or setters for this property.
> 
> 
> On Thu, Nov 28, 2013 at 11:07 AM, Akshay Rawat <pr...@akshay.cc> wrote:
> 
>> I am working with an acroform which has fields. These fields specify their
>> own fonts to use when a value is set (using `setValue`).
>> 
>> Is there a way to override this font of the PDField, such that `setValue`
>> text appears in a different font.
>> 
>> I’ve asked this question here too.
>> 
>> 
>> Thanks.
>> 
>> 
>> Akshay Rawat
>> 
>> Skype: akshayrawat
>> Mobile: +91 9538780000
>> http://www.akshay.cc
>> 
>> 
>> 
>> 


Re: Overriding the font of a PDField

Posted by Gilad Denneboom <gi...@gmail.com>.
The font used has nothing to do with the value of the field. This
information is encoded in the DA attribute of the field, which you can read
and write using via the field's COSDictionary object. AFAIK, there are no
direct getters or setters for this property.


On Thu, Nov 28, 2013 at 11:07 AM, Akshay Rawat <pr...@akshay.cc> wrote:

> I am working with an acroform which has fields. These fields specify their
> own fonts to use when a value is set (using `setValue`).
>
> Is there a way to override this font of the PDField, such that `setValue`
> text appears in a different font.
>
> I’ve asked this question here too.
>
>
> Thanks.
>
>
> Akshay Rawat
>
> Skype: akshayrawat
> Mobile: +91 9538780000
> http://www.akshay.cc
>
>
>
>