OpenPDF icon indicating copy to clipboard operation
OpenPDF copied to clipboard

HTMLWorker parseToList can not parse table with different tr html String

Open macbookpro2016 opened this issue 1 year ago • 7 comments

Describe the bug

if html String have a table with different rows.cells.size,will miss all row

To Reproduce

at IncCell.class,

line 104, PdfPTable table = new PdfPTable(ncol); ncol is cell number of first table row if i have a row is not such many cells, this row will be miss

  1. Sample Code
  2. Unit-Test

Expected behavior

Not given.

System

Not given

macbookpro2016 avatar Mar 07 '24 06:03 macbookpro2016

at IncTable.class , my fault

macbookpro2016 avatar Mar 07 '24 06:03 macbookpro2016

Normaly in a table, in a row, when you have less cells, than the table expects, you need to declare which cell has a larger colSpan. OpenPDF won't fill missing cells for you.

asturio avatar Mar 08 '24 17:03 asturio

If you have some sample code, that could help finding your problem.

asturio avatar Mar 08 '24 17:03 asturio

Normaly in a table, in a row, when you have less cells, than the table expects, you need to declare which cell has a larger colSpan. OpenPDF won't fill missing cells for you.

how should i do to declare which cell has a small colSpan,thanks

macbookpro2016 avatar Mar 10 '24 01:03 macbookpro2016

Take a look here: https://github.com/LibrePDF/OpenPDF/blob/master/pdf-toolbox/src/test/java/com/lowagie/examples/objects/tables/DefaultCell.java

asturio avatar Mar 10 '24 12:03 asturio

Take a look here: https://github.com/LibrePDF/OpenPDF/blob/master/pdf-toolbox/src/test/java/com/lowagie/examples/objects/tables/DefaultCell.java

Thanks for your reply,in my project,i use method HTMLWorker.parseToList() to parse html String automatically, in this method, it is use first table column number to parse table,is there any method to replace this method or any other ways to make i can parse table with rows(with different column), Or how to use DefaultCell in this method ,thanks again!

macbookpro2016 avatar Mar 11 '24 06:03 macbookpro2016

Take a look at this example, maybe it can help you.

Example

I'm not sure OpenPDF can do exactly what you want.

asturio avatar Mar 16 '24 18:03 asturio