OpenPDF icon indicating copy to clipboard operation
OpenPDF copied to clipboard

KeepTogether on ListItem not implemented

Open stonewoodman opened this issue 5 years ago • 4 comments

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.

stonewoodman avatar Jun 18 '20 08:06 stonewoodman

Pull requests welcome.

andreasrosdal avatar Jun 18 '20 08:06 andreasrosdal

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: {
...

arnthom avatar Jun 18 '20 09:06 arnthom

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

mraniketr avatar Feb 25 '24 13:02 mraniketr

Pull requests are still welcome.

asturio avatar Mar 08 '24 19:03 asturio