public PdfPTable createPdfPTable ( ) throws BadElementException { if ( ! convert2pdfptable ) { throw new BadElementException ( "No error, just an old style table" ) ; } setAutoFillEmptyCells ( true ) ; complete ( ) ; PdfPTable pdfptable = new PdfPTable ( widths ) ; pdfptable . setComplete ( complete ) ; if ( isNotAddedYet ( ) ) pdfptable . setSkipFirstHeader ( true ) ; SimpleTable t_evt = new SimpleTable ( ) ; t_evt . cloneNonPositionParameters ( this ) ; t_evt . setCellspacing ( cellspacing ) ; pdfptable . setTableEvent ( t_evt ) ; pdfptable . setHeaderRows ( lastHeaderRow + 1 ) ; pdfptable . setSplitLate ( cellsFitPage ) ; pdfptable . setKeepTogether ( tableFitsPage ) ; if ( ! Float . isNaN ( offset ) ) { pdfptable . setSpacingBefore ( offset ) ; } pdfptable . setHorizontalAlignment ( alignment ) ; if ( locked ) { pdfptable . setTotalWidth ( width ) ; pdfptable . setLockedWidth ( true ) ; } else { pdfptable . setWidthPercentage ( width ) ; } for ( Row row : this . rows ) { Element cell ; PdfPCell pcell ; for ( int i = 0 ; i < row . getColumns ( ) ; i ++ ) { if ( ( cell = ( Element ) row . getCell ( i ) ) != null ) { if ( cell instanceof Table ) { pcell = new PdfPCell ( ( ( Table ) cell ) . createPdfPTable ( ) ) ; } else if ( cell instanceof Cell ) { pcell = ( ( Cell ) cell ) . createPdfPCell ( ) ; pcell . setPadding ( cellpadding + cellspacing / 2f ) ; SimpleCell c_evt = new SimpleCell ( SimpleCell . CELL ) ; c_evt . cloneNonPositionParameters ( ( Cell ) cell ) ; c_evt . setSpacing ( cellspacing * 2f ) ; pcell . setCellEvent ( c_evt ) ; } else { pcell = new PdfPCell ( ) ; } pdfptable . addCell ( pcell ) ; } } } return pdfptable ; }
Create a PdfPTable based on this Table object .