Skip to content
Dries Horions edited this page Feb 13, 2026 · 2 revisions

Frequently Asked Questions (FAQ)

General Questions

What is Boxable?

Boxable is a Java library that simplifies the creation of tables in PDF documents. It's built on top of Apache PDFBox and provides a high-level API for creating professional tables with rich formatting.

What version of Java is required?

Boxable requires Java 8 or higher. The library is compiled with Java 17 but is compatible with Java 8+.

Is Boxable production-ready?

Yes! Boxable is actively maintained and used in production applications. Version 1.8.2 is the current stable release.

Installation and Setup

How do I add Boxable to my project?

Maven:

<dependency>
    <groupId>com.github.dhorions</groupId>
    <artifactId>boxable</artifactId>
    <version>1.8.2</version>
</dependency>

Gradle:

implementation 'com.github.dhorions:boxable:1.8.2'

What dependencies does Boxable have?

Boxable depends on:

  • Apache PDFBox 3.0.6
  • Apache Commons CSV (for CSV import)
  • JSoup (for HTML parsing)

These are automatically included when you add Boxable to your project.

Table Creation

How do I create a simple table?

See the Getting Started guide or Tutorial 01 for a complete example.

Why isn't my table showing up in the PDF?

Make sure you call table.draw() before saving the document:

table.draw();  // Don't forget this!
document.save("output.pdf");

How do I control table width?

The table width is specified when creating the BaseTable:

float tableWidth = page.getMediaBox().getWidth() - (2 * margin);
BaseTable table = new BaseTable(yStart, yStartNewPage, bottomMargin, 
                                tableWidth, margin, document, page, 
                                true, true);

Can I create tables without borders?

Yes! Set drawLines to false when creating the table:

BaseTable table = new BaseTable(yStart, yStartNewPage, bottomMargin, 
                                tableWidth, margin, document, page, 
                                false, true);  // false = no borders

You can also set setOuterBorderStyle() for custom border control.

Content and Formatting

How do I add colors to cells?

Use setFillColor() for background and setTextColor() for text:

Cell<PDPage> cell = row.createCell(50, "Content");
cell.setFillColor(Color.BLUE);
cell.setTextColor(Color.WHITE);

Can I use HTML formatting in cells?

Yes! Boxable supports many HTML tags including <b>, <i>, <u>, <s>, <br/>, <sup>, <sub>, lists, and more. See HTML Tags Reference for details.

How do I add images to cells?

Use createImageCell():

BufferedImage bufferedImage = ImageIO.read(new File("image.png"));
Image image = new Image(bufferedImage);
ImageCell<PDPage> cell = row.createImageCell(50, image);

See Tutorial 05: Images for examples.

How do I rotate text?

Use setTextRotated(true):

Cell<PDPage> cell = row.createCell(10, "VERTICAL");
cell.setTextRotated(true);

Can I change font size?

Yes:

cell.setFontSize(14f);

Multi-Page Tables

Do tables automatically span multiple pages?

Yes! When a table reaches the bottom margin, Boxable automatically creates a new page and continues the table.

How do I make headers repeat on each page?

Use addHeaderRow():

Row<PDPage> headerRow = table.createRow(20f);
// ... create header cells ...
table.addHeaderRow(headerRow);

Headers added this way automatically repeat on each new page.

Can I have multiple header rows?

Yes! Call addHeaderRow() multiple times:

table.addHeaderRow(headerRow1);
table.addHeaderRow(headerRow2);
table.addHeaderRow(headerRow3);

See Tutorial 07: Header Rows.

Data Import

How do I import data from CSV?

Use the DataTable class:

String csvData = "Name;Age\\nJohn;30\\nJane;25";
BaseTable baseTable = new BaseTable(...);
DataTable dataTable = new DataTable(baseTable, page);
dataTable.addCsvToTable(csvData, DataTable.HASHEADER, ';');
baseTable.draw();

Can I import from Java Lists?

Yes:

List<List> data = new ArrayList<>();
data.add(new ArrayList<>(Arrays.asList("Name", "Age")));
data.add(new ArrayList<>(Arrays.asList("John", "30")));

DataTable dataTable = new DataTable(baseTable, page);
dataTable.addListToTable(data, DataTable.HASHEADER);

See Tutorial 08: Data Import.

How do I control column widths when importing?

Pass a list of relative widths:

DataTable dataTable = new DataTable(baseTable, page, 
                                    Arrays.asList(3f, 1f, 1f, 1f));
// First column is 3x wider than others

Performance

How do I handle very large tables?

Boxable handles large tables efficiently. For best performance:

  • Use drawContent = true and drawLines = true only when needed
  • Consider breaking very large tables into multiple tables
  • See Tutorial 09: Multi-Page Tables

Does Boxable use a lot of memory?

Boxable is designed to be memory-efficient. It processes rows as they're added rather than storing everything in memory.

Advanced Features

Can I create nested tables?

Yes! Use HTML <table> tags within cell content:

String nestedTable = "<table>" +
    "<tr><td>Name</td><td>Value</td></tr>" +
    "<tr><td>Item 1</td><td>100</td></tr>" +
    "</table>";
Cell<PDPage> cell = row.createCell(50, nestedTable);

See Tutorial 10: Nested Tables.

What are fixed-height rows?

Fixed-height rows automatically shrink text to fit a specified height:

Row<PDPage> row = table.createRow(12f);
row.setFixedHeight(true);  // Text will shrink to fit 12pt height

See Tutorial 11: Fixed Height Rows.

Can cells span multiple columns?

Yes, in nested tables using colspan:

"<table>
  <tr><td colspan='3'>Spans 3 columns</td></tr>
  <tr><td>Col1</td><td>Col2</td><td>Col3</td></tr>
</table>"

Troubleshooting

My text is cut off

Possible solutions:

  • Increase row height
  • Use fixed-height rows with auto-shrink
  • Add line breaks with <br/> tags
  • Reduce font size

Colors aren't showing

Make sure you set both drawLines and drawContent to true:

BaseTable table = new BaseTable(yStart, yStartNewPage, bottomMargin, 
                                tableWidth, margin, document, page, 
                                true, true);  // both true

Characters are showing as boxes

The default font (Helvetica) doesn't support all Unicode characters. Use:

  • Standard ASCII characters
  • HTML entity references
  • Or load a custom font that supports your characters

Table positioning is wrong

Make sure your yStart calculation accounts for margins:

float yStart = page.getMediaBox().getHeight() - margin;

Getting Help

Where can I find more examples?

Run the built-in tutorials:

mvn test -Dtest=TutorialRunner

This generates 12 PDF examples covering all features.

Where do I report bugs?

Report issues on GitHub: https://github.com/dhorions/boxable/issues

How can I contribute?

Contributions are welcome! See issue #41 for documentation needs.

Is there commercial support?

Boxable is open source. For commercial support inquiries, contact the maintainers through GitHub.

See Also

Clone this wiki locally