2

How can you change styles like border width, border color, text alignment, etc. of an inner table created with boxable?

SampleTest10 in the unit tests here creates an inner table by using HTML. The resulting table has default styles. How can you access and change them?

Bobface
  • 2,782
  • 4
  • 24
  • 61

1 Answers1

0

Table Class

I had a look at the boxable class for Table. It looks as if these are the only styling options you have ( atleast according to this class ) :

public Table(float yStartNewPage, float pageTopMargin, float pageBottomMargin, float width, float margin,
            PDDocument document, boolean drawLines, boolean drawContent, PageProvider<T> pageProvider)

See: https://github.com/dhorions/boxable/blob/master/src/main/java/be/quodlibet/boxable/Table.java

I see though that also HTML can be included, so maybe you should try using html formatting such as: e.g. <table bordercolor=”red”>

Cell Class

Cell class seems to have a LineStyle . So it would make sense that in the following code (taken from unit test), you would be able to do additional actions.

Cell<PDPage> cell = headerRow.createCell(100, "Awesome Facts About Belgium");
        cell.setFont(PDType1Font.HELVETICA_BOLD);
        cell.setFillColor(Color.BLACK);
        cell.setTextColor(Color.WHITE);

cell.setBottomBorderStyle(new LineStyle(Color.RED, 2));

        table.addHeaderRow(headerRow);
Menelaos
  • 23,508
  • 18
  • 90
  • 155
  • Thanks for your answer. Unfortunately, an inner table is a `TableCell`, not an `Table`. So the styling options of `TableCell` are not the same as `Table`. I also tried to use HTML styling like `style="..."` and `bordercolor` but it does not work. – Bobface Sep 10 '18 at 11:18
  • @Thesys, I noticed that Cell seems to have a LineStyle . https://github.com/dhorions/boxable/blob/master/src/main/java/be/quodlibet/boxable/Cell.java – Menelaos Sep 10 '18 at 11:23
  • Yes that is correct. But I am talking about an *inner* table. An inner table is a table which is *inside* a cell. Changing the style of the cell does not affect the table which is inside the cell. – Bobface Sep 10 '18 at 11:28
  • 1
    An inner table is constructed like this (taken from SampleTest10)): `Cell cell3 = row2.createTableCell((100 / 3f), "
    Hello Hello Hello Hello Hello Hello Hello it's meb1
    a1b1
    a1b1 b1 b1 b1 b1 b1 b1 b1
    a1b1
    a1b1
    a1b1
    a1b1
    a1b1
    a1b1
    ", doc, page, yStart, pageBottomMargin, margin);` Notice `createTableCell` != `createCell`
    – Bobface Sep 10 '18 at 11:30
  • @Bobface How can I style(background or color) to a ? – user578219 Nov 05 '20 at 15:51