@ Override protected DocWriter createWriter ( final MBasicTable table , final Document document , final OutputStream out ) { final RtfWriter2 writer = RtfWriter2 . getInstance ( document , out ) ; // title final String title = buildTitle ( table ) ; if ( title != null ) { final HeaderFooter header = new RtfHeaderFooter ( new Paragraph ( title ) ) ; header . setAlignment ( Element . ALIGN_LEFT ) ; header . setBorder ( Rectangle . NO_BORDER ) ; document . setHeader ( header ) ; document . addTitle ( title ) ; } // advanced page numbers : x/y final Paragraph footerParagraph = new Paragraph ( ) ; final Font font = FontFactory . getFont ( FontFactory . TIMES_ROMAN , 12 , Font . NORMAL ) ; footerParagraph . add ( new RtfPageNumber ( font ) ) ; footerParagraph . add ( new Phrase ( " / " , font ) ) ; footerParagraph . add ( new RtfTotalPageNumber ( font ) ) ; footerParagraph . setAlignment ( Element . ALIGN_CENTER ) ; final HeaderFooter footer = new RtfHeaderFooter ( footerParagraph ) ; footer . setBorder ( Rectangle . TOP ) ; document . setFooter ( footer ) ; return writer ; }
We create a writer that listens to the document and directs a RTF - stream to out