OpenPDF
OpenPDF copied to clipboard
KeepTogether on ListItem not implemented
The value keeptogether on a ListItem is ignored
ListItem listItem = new ListItem("multiline text...", font);
listItem.setKeepTogether(true);
expected result
The flag has the same behavior as by Paragraph.
Pull requests welcome.
OK, method getKeepTogether() is used in PdfDocument.add(Element) if the element is Paragraph, but not if it is ListItem, although ListItem extends Paragraph ...
public boolean add(Element element) throws DocumentException {
...
try {
switch(element.type()) {
...
case Element.PARAGRAPH: {
...
// if a paragraph has to be kept together, we wrap it in a table object
if (paragraph.getKeepTogether()) {
...
case Element.LISTITEM: {
...
does it need to be encapsulated in a table just like paragraph? as that is causing it to fail when using list item in a list component
Pull requests are still welcome.