コード例 #1
0
 public static SectionPdfPTable createLayoutTable(float width, float height) {
   // create one row table which will layout section text
   // if ( style != null )
   // {
   // List<StyleColumnProperties> columnPropertiesList = style.getColumnPropertiesList();
   // StyleColumnsProperties columnsProperties = style.getColumnsProperties();
   // if ( columnPropertiesList != null && !columnPropertiesList.isEmpty() )
   // {
   // // explicit column list
   // return createLayoutTable( width, height, columnPropertiesList );
   // }
   // else if ( columnsProperties != null )
   // {
   // // we have columns properties
   // // make table with columns of equal width
   // columnPropertiesList = new ArrayList<StyleColumnProperties>();
   //
   // Integer columnCount = columnsProperties.getColumnCount();
   // int colCount = columnCount != null ? columnCount : 1;
   //
   // Float columnGap = columnsProperties.getColumnGap();
   // float halfGap = columnGap != null ? columnGap / 2.0f : 0.0f;
   //
   // for ( int i = 0; i < colCount; i++ )
   // {
   // StyleColumnProperties columnProperties = new StyleColumnProperties();
   // columnProperties.setRelWidth( 100 );
   // if ( halfGap > 0.0f )
   // {
   // columnProperties.setStartIndent( i == 0 ? null : halfGap );
   // columnProperties.setEndIndent( i == colCount - 1 ? null : halfGap );
   // }
   // columnPropertiesList.add( columnProperties );
   // }
   // return createLayoutTable( width, height, columnPropertiesList );
   // }
   // }
   // default is one column and no gap
   List<StyleColumnProperties> columnPropertiesList = new ArrayList<StyleColumnProperties>();
   StyleColumnProperties columnProperties = new StyleColumnProperties();
   columnProperties.setRelWidth(100);
   columnPropertiesList.add(columnProperties);
   return createLayoutTable(width, height, columnPropertiesList);
 }
コード例 #2
0
 public static SectionPdfPTable createLayoutTable(
     float width, float height, List<StyleColumnProperties> columnPropertiesList) {
   // create one row table which will layout section text
   int colCount = columnPropertiesList.size();
   int relativeWidths[] = new int[colCount];
   SectionPdfPTable table = new SectionPdfPTable(colCount);
   // add cells
   for (int i = 0; i < colCount; i++) {
     PdfPCell cell = new PdfPCell();
     cell.setBorder(Rectangle.NO_BORDER);
     cell.setPadding(0.0f);
     cell.setColumn(createColumnText());
     cell.setFixedHeight(height >= 0.0f ? height : -1.0f);
     // apply styles to cell
     StyleColumnProperties columnProperties = columnPropertiesList.get(i);
     relativeWidths[i] = columnProperties.getRelWidth();
     cell.setPaddingLeft(
         columnProperties.getStartIndent() != null ? columnProperties.getStartIndent() : 0.0f);
     cell.setPaddingRight(
         columnProperties.getEndIndent() != null ? columnProperties.getEndIndent() : 0.0f);
     table.addCell(cell);
   }
   replaceTableCells(table);
   // set width
   try {
     table.setWidths(relativeWidths);
   } catch (DocumentException e) {
     throw new XWPFConverterException(e);
   }
   table.setTotalWidth(width);
   table.setLockedWidth(true);
   return table;
 }