P
P
parkito2016-10-06 22:07:23
Java
parkito, 2016-10-06 22:07:23

How to format a table?

Hello. Please tell me how to align the table.

String.format("%-20s %-20s %-20s", userDTO.getUserId(), userDTO.getName(), userDTO.getEmail())

UPD
I output this code to the console - everything is fine. But if I try to put it in pdf (via itextpdf) I get a
problem
document.add(new Paragraph(String.format("|%-20s| %-20s| %-20s| %-30s| %-20s|\n\n",
                        userDTO.getUserId(),
                        userDTO.getName(), userDTO.getSecondName(),
                        userDTO.getEmail().trim(), userDTO.getContracts())));

ba5a92753f524931ac4e65bd29bcd6dc.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2016-10-07
@parkito

String.format("%-20s %-20s %-20s", userDTO.getUserId().trim(), userDTO.getName().trim(), userDTO.getEmail().trim())

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question