Package com.snowtide.pdf.util
Class TableUtils
- java.lang.Object
-
- com.snowtide.pdf.util.TableUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String[]
convertTablesToCSV(Page p, char delim)
CallsconvertTablesToCSV(Page, char, String)
with the specified page, cell delimiter, and a single linefeed (\n) as a linebreak sequence.static String[]
convertTablesToCSV(Page p, char delim, String linebreak)
Returns an array of CSV-formattedString
s, one for eachTable
found in the given page, using the specified character as a cell delimiter and the specified String as a linebreak sequence.static String
convertToCSV(Table table, char delim)
CallsconvertToCSV(Table, char, String)
with the specifiedTable
, cell delimiter, and a single linefeed (\n) as a linebreak sequence.static String
convertToCSV(Table table, char delim, String linebreak)
Returns a CSV-formatted String based on the contents of the givenTable
, using the specified character as a cell delimiter and the specified String as a linebreak sequence.static List<Table>
getAllTables(Page p)
static String[][]
tableToStrings(Table table)
Returns a two-dimensional array of Strings carrying the contents of the givenTable
in row/cell order.
-
-
-
Method Detail
-
convertToCSV
public static String convertToCSV(Table table, char delim) throws IOException
CallsconvertToCSV(Table, char, String)
with the specifiedTable
, cell delimiter, and a single linefeed (\n) as a linebreak sequence.- Throws:
IOException
-
convertToCSV
public static String convertToCSV(Table table, char delim, String linebreak) throws IOException
Returns a CSV-formatted String based on the contents of the givenTable
, using the specified character as a cell delimiter and the specified String as a linebreak sequence.- Throws:
IOException
- if an error occurs generating the CSV conversion
-
tableToStrings
public static String[][] tableToStrings(Table table) throws IOException
Returns a two-dimensional array of Strings carrying the contents of the givenTable
in row/cell order. For example, this:String[][] tableText = TableUtils.tableToStrings(pdfxstreamTable); String cell = tableText[0][2];
Obtains the textual content of thepdfxstreamTable
Table
, and singles out the text of the third cell in the first row of that table.- Throws:
IOException
- if an error occurs extracting any of the table's text
-
convertTablesToCSV
public static String[] convertTablesToCSV(Page p, char delim, String linebreak) throws IOException
Returns an array of CSV-formattedString
s, one for eachTable
found in the given page, using the specified character as a cell delimiter and the specified String as a linebreak sequence. This is simply a shortcut to applyingconvertToCSV(Table, char, String)
to eachTable
in the givenPage
manually.- Throws:
IOException
- if an error occurs generating the CSV conversion
-
convertTablesToCSV
public static String[] convertTablesToCSV(Page p, char delim) throws IOException
CallsconvertTablesToCSV(Page, char, String)
with the specified page, cell delimiter, and a single linefeed (\n) as a linebreak sequence.- Throws:
IOException
-
-