Skip to Content

Dynamic font setting for adobe forms

Changing font at runtime for all controls (fileds) in adobe form is quite painful, because till now there is no provision is given by adobe. I have done some RND on how to change fonts in our adobe forms dynamically. This will change font of whole pdf.

Requirement: Want to change font of whole pdf (all pages, master pages).


First go through Loop through all controls (fields) in adobe forms blog for more information.

Below all listed controls (fileds) are effected,

  • Button, Check Box, Date/Time Field, Drop-down List, Signature Field, Image Field, List Box, Numeric Field, Password Field, Radio Button, and Text Field.
  • Circle, Line, Rectangle, Static Image, and Static Text.


Use below script on data node.

data::ready:layout - (JavaScript, client)
var totalPages = xfa.layout.pageCount();
var i = 0;

for (i = 0; i < totalPages; i++) {
  setFont("field", 0);
  setFont("draw", 0);
  setFont("field", 1);
  setFont("draw", 1);

function setFont(type, page) {
  var oField = xfa.layout.pageContent(i, type, page);
  var n = oField.length;
  var j = 0;

  for (j = 0; j < n; j++) {
    oField.item(j).font.typeface = "Courier"; //any valid font name

Hope this helps.

You must be Logged on to comment or reply to a post.
    • Same is going to work for dynamic text is well. please explain your issue in detail, if possible ask same with example in Q&A section.

      Hope this helps. 

      • Hi Prajesh,

        I have a requirement , i should reduce the font size of the label for particular company code in order fit the text in the label window. As i am new to this adobe especially the Java scripting.Please guide me, how to achieve this.




        • Kindly answer to the below question created :