Class PDFTable

java.lang.Object
com.moebiusgames.pdfbox.table.PDFTable

public class PDFTable extends Object
A simple PDFTable implementation for PDFBox
  • Field Details

    • NOT_SET

      public static int NOT_SET
    • AUTO_DETERMINE_COLUMN_WIDTH

      public static final float AUTO_DETERMINE_COLUMN_WIDTH
      See Also:
    • NOT_SET_COLOR

      public static Color NOT_SET_COLOR
  • Constructor Details

    • PDFTable

      public PDFTable(float... columnWidths)
  • Method Details

    • getPageSettings

      public PDFTable.PageSettings getPageSettings()
      returns the settings that are used as templates for every new page
      Returns:
      returns the page settings
    • getColumnHeadersMode

      public PDFTable.ColumnHeadersMode getColumnHeadersMode()
    • setColumnHeadersMode

      public void setColumnHeadersMode(PDFTable.ColumnHeadersMode columnHeadersMode)
    • getColumn

      public PDFTableColumn getColumn(int index)
    • getColumns

      public int getColumns()
    • addRow

      public PDFTableRow addRow()
    • getRows

      public int getRows()
    • getRow

      public PDFTableRow getRow(int index)
    • render

      public void render(PDFRenderContext renderContext, float x) throws IOException
      renders this table to the given document and starts at the last page directly under the last rendered element
      Parameters:
      renderContext - the render context that collects all pages
      x - the x position to render the table
      Throws:
      IOException
    • render

      public void render(PDFRenderContext renderContext, float x, float y) throws IOException
      renders this table to the given document and starts at the last page
      Parameters:
      renderContext - the render context that collects all pages
      x - the x position to render the table
      y - the y position to render the table
      Throws:
      IOException
    • render

      public void render(PDFRenderContext renderContext, PDFPageWithStream page, float x, float y) throws IOException
      renders this table to the given document and starts at the given page at the given coordinates.
      Parameters:
      renderContext - the render context that collects all pages
      page - the page to render the table to (not necessarily the last page)
      x - the x position to render the table
      y - the y position to render the table
      Throws:
      IOException
    • getHeight

      public float getHeight() throws IOException
      calculates the height of the table with the current content (without and top or bottom paddings added). If this exceeds the height of a page, then the table will be wrapped. Note that multiple headings are not accounted for.
      Returns:
      returns the height of the table
      Throws:
      IOException
    • createByRelativeColumnWidth

      public static PDFTable createByRelativeColumnWidth(float tableWidth, float... columnWidthPercent)
      creates a table according to a given total width of the table and sets the column's with as a pecentage of that width
      Parameters:
      tableWidth - the total table width
      columnWidthPercent - the percentages for the columns
      Returns:
      returns a new PDFTable object
    • createWithSomeFixedColumnWidths

      public static PDFTable createWithSomeFixedColumnWidths(float tableWidth, float... columnWidths)
      Creates a table with the given total width and fixed widths for the column specified. The remainder of the space is split up between the columns that have the value of constant AUTO_DETERMINE_COLUMN_WIDTH.
      Parameters:
      tableWidth - the total width
      columnWidths - the fixed widths for the columns
      Returns:
      returns a new PDFTable object