LibrePDF / OpenPDF

OpenPDF is a free Java library for creating and editing PDF files, with a LGPL and MPL open source license. OpenPDF is based on a fork of iText. We welcome contributions from other developers. Please feel free to submit pull-requests and bugreports to this GitHub repository.
Other
3.49k stars 580 forks source link

Handling Row Content Splitting in PdfPTable.writeSelectedRows() #1168

Open HemaSudha1498 opened 3 months ago

HemaSudha1498 commented 3 months ago

Hello,

In PdfPTable, we have support to write tables in two ways:

  1. document.add(table);
  2. table.writeSelectedRows();

In the first approach, if a table row's content is too long to fit on a single page, the content is properly split across multiple pages. However, the same handling is not available in the second approach leading to data loss.

Can someone guide me on how to achieve the similar behavior in the second approach? Or, please navigate me to the respective code logic that handles this behavior in the first approach.

PDF via document.add(table); Screenshot from 2024-05-24 12-57-32

PDF via table.writeSelectedRows(); Screenshot from 2024-05-24 12-57-44

Thank you!

asturio commented 3 months ago

Nice one. And if using Table (not PdfPTable) then you will get an endless loop.

asturio commented 3 months ago

Related to #1163 and #1021

HemaSudha1498 commented 3 months ago

Hi @asturio,

Thank you for your response. However, using Table does not meet my requirements. My use case involves multi-lingual text, images, icons, symbols, and shapes within a table cell. Therefore, I am utilizing PdfPTable.

I am handling large datasets, including hundreds of thousands of rows, which makes it impractical to hold all chunks, phrases, PdfPCells, and rows in the JVM. To manage this, I am using PdfPTable.writeSelectedRows() to write the table row by row.

Additionally, I need to position my table at a specific positionX and start from a particular positionY within a specified width.