boxable: adding line break inside a column, question about fonts and multiple rows within a cell

Given a cell, like follows: cell = row.createCell(20, "Email: " + bean.getEmail()), how can I put a line break between Email and the variable bean.getEmail()?

I know, for example, that to make the Email word bold, I could do: row.createCell(20, "<b>Email:<b> " + bean.getEmail()) but I haven’t been able to figure out how to make a line break.

Also, do I have other font options besides the one available in the class PDType1Font?

In the attached image I present an example of what I am trying to do when it comes to having multiple rows within a cell. Please see what the red arrows is pointing to. Can I accomplish that using Boxable?

multiple_rows_within_cell

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Hi Erick,

I did not look into your code, but you can use Table.getCurrentPage() to retrieve the page. Hope this already helps.

Markus

Good catch, my brain auto-corrected it to a closing tag 😄

Just a quick correction with <b> tag. If you don’t want your email adress also be bold then you need to write:

row.createCell(20, "<b>Email:</b><br> " + bean.getEmail())

because if yout don’t close your bold text in your previous line, it will be carried in your next line.

Other thing, I also think that you will need to apply @dobluth third solution. It’s not so “clean” but hopefully that solves your current problem.

Hi Erick,

to generate a line break, you can use HTML tags, too (<br>):

row.createCell(20, "<b>Email:<b><br> " + bean.getEmail())

You can use another PDFont, just load it, for example:

PDFont font = PDType0Font.load(document, fontFile);

I see three options to generate an output like in your image:

  1. A table within a table (not possible with Boxable)
  2. rowspan (not (yet) possible with Boxable, see #39)
  3. try to fake a rowspan 😉

To fake such a table you would have to generate 3 rows (“Grupo Familiar”, “Adicionales”, “Costo Total”). In the columns “Plan seleccionado” and “Código de Plan” you draw no borders between rows 1/2 and rows 2/3. It gets harder if you have some text in those two columns, as there are still three rows, leading to the question: where do you output it? But as long as there is no text, you should be fine 😉

Markus