You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by eli colner <ec...@yahoo.com> on 2014/03/05 23:08:41 UTC

Changing font of PDTextbox

How is it possible to change the font of a textbox?

I tried 

PDDocument pdf = PDDocument.load(originalPdf);
PDDocumentCatalog docCatalog = pdf.getDocumentCatalog();
PDAcroForm acroForm = docCatalog.getAcroForm();
PDField field = acroForm.getField( "topmostSubform[0].Page1[0].Entity[0].p1-t4[0]" );
field.getDictionary().setString(COSName.DA, PDType1Font.COURIER.getBaseFont());
field.setValue("Testing font change");

I also searched for the answer to this and couldn't figure it out.
https://www.google.com/search?as_q=textbox+font&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fpdfbox-users%2F&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=


Any help would be much appreciated.

Re: Changing font of PDTextbox

Posted by eli colner <ec...@yahoo.com>.
OK, so it appears that creating a new field instance solved this.

I used this thread as a reference for anybody facing similar challenge:
http://stackoverflow.com/questions/22073137/how-to-set-the-text-of-a-pdtextbox-to-a-color




________________________________
 From: eli colner <ec...@yahoo.com>
To: "users@pdfbox.apache.org" <us...@pdfbox.apache.org> 
Sent: Wednesday, March 5, 2014 2:08 PM
Subject: Changing font of PDTextbox
 

How is it possible to change the font of a textbox?

I tried 

PDDocument pdf = PDDocument.load(originalPdf);
PDDocumentCatalog docCatalog = pdf.getDocumentCatalog();
PDAcroForm acroForm = docCatalog.getAcroForm();
PDField field = acroForm.getField( "topmostSubform[0].Page1[0].Entity[0].p1-t4[0]" );
field.getDictionary().setString(COSName.DA, PDType1Font.COURIER.getBaseFont());
field.setValue("Testing font change");

I also searched for the answer to this and couldn't figure it out.
https://www.google.com/search?as_q=textbox+font&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Fmail-archives.apache.org%2Fmod_mbox%2Fpdfbox-users%2F&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=


Any help would be much appreciated.