Dynamic Font Changes in Word Template

Mike Mackinnon

Mike Mackinnon

Well Known Member
I am not an XML programmer so I am not sure of the syntax or even if this can be done but I am trying to resize a BI Publisher property dynamically according to a condition of another field. This is somewhat related to my other issue I had with trying to fit an attachment into a single page report.

My situation:
- I have a report that MUST fit onto one page
- I have an attachment (media object) that is printing on the report. I do not know the length of this attachment.

My thoughts:
1.) I can find out the number of lines on the attachment from JDE E1 using a couple business functions.
2.) I can then change the font size using XML code in RTF document (BI Publisher Properties) based upon the number of lines in attachment.
3.) so I can say if > 10 lines set font size to "7"; if > 15 set font size to "6"; if > 20 set font size to "5"; etc.

My problem is I cannot anywhere an example of how to 'programmatically' do this...maybe there is no way?
See attachment for screen shot of what I am talking about.



  • RTF Document - Dynamic Font.pdf
    32.6 KB · Views: 69
Hi Mike

Try something like this in your form field:

<!-- For Descriptions longer than 25, then reduce the font size -->
  <xsl:when test="string-length(./NameRemark_ID7)>25">
    <fo:block font-size="7pt">
      <xsl:value-of select="./NameRemark_ID7"/>
    <fo:block font-size="10pt">
      <xsl:value-of select="./NameRemark_ID7"/>

Last edited:
I have tried using something like this for font (will need to add conditional IF later):

<fo:inline font-size="8">

However, I am finding that the formatting is not quite working for me. I am still getting the same "fill" on the template...so even though the font is shrinking/changing the field still takes up the same amount of space.
It *may* be related to the data that I am processing as I am trying to format the text attachment (media object) from JDE and am running into problems where the text is changing font size but the spacing is not different??

See the examples attached for what I am looking at.
Maybe it is a setting in my RTF document??



  • RTF - Font Size Set to 5.pdf
    70.3 KB · Views: 33
  • RTF - Font Size Set to 8.pdf
    77.8 KB · Views: 40
After some more testing...maybe it is working.

I guess I was just expecting a more dramatic effect on the size of the field.
I may need to use some even smaller fonts!!

Depending on your configuration, that text attachment may be HTML. If that's the case, then the break between each line is a paragraph. I'd recommend highlighting the row that your text attachment field is on and right-click then choose Paragraph from the context menu. You may be able to adjust that spacing using the Paragraph dialog options.



  • Paragraph Settings.jpg
    Paragraph Settings.jpg
    12.2 KB · Views: 36
Thank you all for your replies!!!

I think I have figured out my solution (spacing done for readability purposes). I am using a choose statement and am using the following code with the BI Properties of RTF field. I will be swapping the conditional variable for something else to determine whether or not to resize the font but I think it is what I was looking for:

<?when:Contract_ID59 = ”*W8485-3-B008/001/BQ”?>
<fo:inline font-size="5">
<?end when?>
<?otherwise:?> <?Description___F00165_Attachmen_ID32?>
<?end otherwise?>
<?end choose?>

Justin: I think I am stuck with the line spacing as I am working with the "JDE media object blob data" so I might be stuck with what I am getting...that is ok. I am now getting my conditional output working although I ahve not testing on server as I am only using the PDF generate button within Word for testing. Also: I may or may not have stolen your choose statement from another thread :)
Also: Another note (maybe not for XML programmers), but there is a difference in display of text attachment when using the following two statements:

<fo:block font-size="5pt"><?XML_Tag?></fo:block>
<fo:inline font-size="5"><?XML_Tag?></fo:inline>

I went with the first one since it seemed to "resize" the text better.
The spacing between the lines in the attachment were sized as per font in the 'block of data'.