FOP Dynamic Heading Size?

D

Devon

Hi All,
I'm generating a pdf document using FOP .25 from Apache. I've created
running dynamic headings (e.g. chapter titles) that change as dictated
by the XML source I'm converting to PDF. Now thats fine. My clients
wish to include a variable length note as well in this page region.
Trouble is I've only been able to do this by statically sizing the
region to house this data. If no data (e.g. the note) exists for a
given heading - just white space is shown. The clients hate it and
apparently this is a show-stopping issue. A mustfix.

Is there a way to have the fo-region-before shrink / grow dynamically
based on the data display within that region?
 
M

Mike Partridge

The size of a static-content region can't be dynamic, but you can calc
the size based on the size of your note. Ex:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:template match="/">
<fo:root>
<fo:layout-master-set>

<xsl:variable name="size" select="string-length(/xml/note/text()) div
50"/>

<fo:simple-page-master master-name="report_page_master"
page-height="11in" page-width="8.5in">
<fo:region-body region-name="xsl-region-body" margin=".5in"
margin-top="{$size}in"/>

....

This counts the number of chars making up the note node to calc the
size. You'll probaly want to figure out your own magic number instead
of 50, but you'll want to use that variable in the margin-top of
region-body and the extent of region-before.

Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top