    protected ExtendedHeaderFooter createExtendedHeaderFooter()
    {
        return new ExtendedHeaderFooter( this )
        {
            @Override
            public void onStartPage( PdfWriter writer, Document doc )
            {
                super.onStartPage( writer, doc );
                StylableDocument.this.onStartPage();
            }
            @Override
            protected float getHeaderY( IMasterPageHeaderFooter header )
            {
                Float headerY = ( (StylableHeaderFooter) header ).getY();
                if ( headerY != null )
                {
                    return document.getPageSize().getHeight() - headerY;
                }
                return super.getHeaderY( header );
            }
            @Override
            protected float getFooterY( IMasterPageHeaderFooter footer )
            {
                Float footerY = ( (StylableHeaderFooter) footer ).getY();
                if ( footerY != null )
                {
                    return ( (StylableHeaderFooter) footer ).getTotalHeight();
                }
                return super.getFooterY( footer );
            }
            @Override
            protected float adjustMargin( float margin, IMasterPageHeaderFooter headerFooter )
            {
                if ( headerFooter.getTotalHeight() > margin )
                {
                    return headerFooter.getTotalHeight();
                }
                return margin;
            }
        };
    }

    protected ExtendedHeaderFooter createExtendedHeaderFooter()
    {
        return new ExtendedHeaderFooter( this )
        {
            @Override
            public void onStartPage( PdfWriter writer, Document doc )
            {
                super.onStartPage( writer, doc );
                StylableDocument.this.onStartPage();
            }
            @Override
            protected float getHeaderY( IMasterPageHeaderFooter header )
            {
                Float headerY = ( (StylableHeaderFooter) header ).getY();
                if ( headerY != null )
                {
                    return document.getPageSize().getHeight() - headerY;
                }
                return super.getHeaderY( header );
            }
            @Override
            protected float getFooterY( IMasterPageHeaderFooter footer )
            {
                Float footerY = ( (StylableHeaderFooter) footer ).getY();
                if ( footerY != null )
                {
                    return ( (StylableHeaderFooter) footer ).getTotalHeight();
                }
                return super.getFooterY( footer );
            }
            @Override
            protected float adjustMargin( float margin, IMasterPageHeaderFooter headerFooter )
            {
                if ( ( (StylableHeaderFooter) headerFooter ).getY() != null )
                {
                    if ( headerFooter.getTotalHeight() > margin )
                    {
                        return headerFooter.getTotalHeight();
                    }
                    return margin;
                }
                return super.adjustMargin( margin, headerFooter );
            }
        };
    }
