Thanks for the links Glenn. I've already read Knuth's paper and I understand
how it works. FOP implementation is also clear to me, more or less...I'm not
trying to reinvent Knuth algorithm neither to modify it, all I want is to
know how to create a layout manager for my <fox:best-fit-block> element. The
latter is too simple, it doesn't have any FO properties and can only contain
a single <fo:block>.

I managed to write the following class but it doesn't generate any content
in the output document:

public class BestFitBlockLayoutManager extends AbstractLayoutManager {

        static Log log = LogFactory.getLog(BestFitBlockLayoutManager.class);
        public BestFitBlockLayoutManager(BestFitBlock node) {
    /** {@inheritDoc} */
    public List getNextKnuthElements(LayoutContext context, int alignment) {
        if (isFinished())
                return null;
        List returnList = null;
        if (getChildLM() != null) {
                returnList = getChildLM().getNextKnuthElements(context, 
            // add a penalty element, representing a forced page break
            returnList.add(new BreakElement(new NonLeafPosition(this, new
                        Constants.EN_PAGE, -KnuthElement.INFINITE, EN_PAGE, 

        return returnList;

View this message in context:
Sent from the FOP - Dev mailing list archive at

Reply via email to