2
votes

Is it possible to repeat table header if part of a table is forwarded to the next page in itext. Xml workerhelper used for create pdf from html string.Some times my html string have large table of content the content forwarded to next page. the i need to add table header in the nextpage and continue to table of content.please see this image for more clarity.

current and expected result

Now following code used for creating pdf.

                    document.open();
                    try{

                      XMLWorkerHelper.getInstance().parseXHtml(writer,
                            document, new ByteArrayInputStream(parserXHtml(page.getPageContent()).getBytes()));
                    writer.setPageEvent(orientation);
                    }catch(Exception e){
                        logger.error("Error:invalid  html content detected!!");

                    }
                    document.close();

Is it possible in itextpdf Api-5.5.11. If we are using table we can repeat table like this.

 PdfPTable table = new PdfPTable(2);
            // header row:
            table.addCell("Header");
            table.addCell("Header Value");
            table.setHeaderRows(1);
            // many data rows:
            for (int i = 1; i < 51; i++) {
                table.addCell("key: " + i);
                table.addCell("value: " + i);
            }

I need to know it is possible in xmlworkerhelper.

1

1 Answers

2
votes

Just set style="repeat-header: yes; repeat-footer: yes;" for your table. Then it will repeat header and footer for all pages until the table end.