OpenPDF
OpenPDF copied to clipboard
rowspan-attribute gets ignored when converting from html to (pdf-)document
Describe the bug When cells in a http-table use the attribute "rowspan" it gets ignored when converting into a document. The following rows will start in the wrong column. Result: testOut.pdf
To Reproduce Code to reproduce the issue You can test it by using the following code:
Document doc = new Document(PageSize.A4); PdfWriter writer = null; try { File out = new File("testOut.pdf"); writer = PdfWriter.getInstance(doc, new FileOutputStream(out)); doc.open(); InputStream stream = Main.class.getResourceAsStream("test.html"); HTMLWorker worker = new HTMLWorker(doc); worker.parse(new InputStreamReader(stream)); } catch (IOException e) { e.printStackTrace(); } finally { doc.close(); if (writer != null) { writer.close(); } }
and this html-File:
<html>
<head>
<title>Test</title>
</head>
<body>
<b>Test</b>
<br/>
<table>
<tr>
<td rowspan="4" valign="top" align="right">line 1</td>
<td rowspan="4" valign="top" align="right">line 2</td>
<td valign="top" align="right">line 3</td>
<td valign="top" align="right">line 4</td>
<td valign="top" align="right">line 5</td>
<td valign="top" align="right">line 6</td>
<td valign="top" align="right">line 7</td>
<td valign="top" align="right">line 8</td>
</tr>
<tr>
<td valign="top" align="right">line 3</td>
<td valign="top" align="right">line 4</td>
<td valign="top" align="right">line 5</td>
<td valign="top" align="right">line 6</td>
<td valign="top" align="right">line 7</td>
<td valign="top" align="right">line 8</td>
</tr>
<tr>
<td valign="top" align="right">line 3</td>
<td valign="top" align="right">line 4</td>
<td valign="top" align="right">line 5</td>
<td valign="top" align="right">line 6</td>
<td valign="top" align="right">line 7</td>
<td valign="top" align="right">line 8</td>
</tr>
<tr>
<td valign="top" align="right">line 3</td>
<td valign="top" align="right">line 4</td>
<td valign="top" align="right">line 5</td>
<td valign="top" align="right">line 6</td>
<td valign="top" align="right">line 7</td>
<td valign="top" align="right">line 8</td>
</tr>
</table>
</body>
</html>
Expected behavior Rows 2-4 should start from the 3rd column, not the 1st.
Additional context The solution should actually be pretty simple. Just like the colspan the rowspan needs to be set on the cell when converting from html. So just add the following line of code into the constructor of the class IncCell: props.findProperty("rowspan").flatMap(NumberUtilities::parseInt).ifPresent(cell::setRowspan);
Hi, I am interested in this issue, can I work on this?
Solved with #750