void outlineTree ( PdfOutline outline ) throws IOException { outline . setIndirectReference ( writer . getPdfIndirectReference ( ) ) ; if ( outline . parent ( ) != null ) outline . put ( PdfName . PARENT , outline . parent ( ) . indirectReference ( ) ) ; ArrayList kids = outline . getKids ( ) ; int size = kids . size ( ) ; for ( int k = 0 ; k < size ; ++ k ) outlineTree ( ( PdfOutline ) kids . get ( k ) ) ; for ( int k = 0 ; k < size ; ++ k ) { if ( k > 0 ) ( ( PdfOutline ) kids . get ( k ) ) . put ( PdfName . PREV , ( ( PdfOutline ) kids . get ( k - 1 ) ) . indirectReference ( ) ) ; if ( k < size - 1 ) ( ( PdfOutline ) kids . get ( k ) ) . put ( PdfName . NEXT , ( ( PdfOutline ) kids . get ( k + 1 ) ) . indirectReference ( ) ) ; } if ( size > 0 ) { outline . put ( PdfName . FIRST , ( ( PdfOutline ) kids . get ( 0 ) ) . indirectReference ( ) ) ; outline . put ( PdfName . LAST , ( ( PdfOutline ) kids . get ( size - 1 ) ) . indirectReference ( ) ) ; } for ( int k = 0 ; k < size ; ++ k ) { PdfOutline kid = ( PdfOutline ) kids . get ( k ) ; writer . addToBody ( kid , kid . indirectReference ( ) ) ; } }
Recursive method used to write outlines .