Python 3: Bad table formatting with empty columns
See original GitHub issueContent of the columns are overlapped if there’s an empty cells.
Here is code for reproducing:
# -*- encoding: utf-8 -*-
from xhtml2pdf import pisa
import sys
py_version = '{0}.{1}'.format(sys.version_info[0], sys.version_info[1])
outputFilename = "bad_table_" + py_version + ".pdf"
source_html = '<html><body>' \
'<table>' \
'<tr>' \
'<td>Item</td><td>Value 1</td><td>Value2</td><td>Value3</td>' \
'</tr>' \
'<tr>' \
'<td>Item 1</td><td>11</td><td>12</td><td>13</td>' \
'</tr>' \
'<tr>' \
'<td>Item 2</td><td>21</td><td>22</td><td>23</td>' \
'</tr>' \
'<tr>' \
'<td>Item 3</td><td>31</td><td>32</td><td>33</td>' \
'</tr>' \
'<tr>' \
'<td>TOTAL</td><td></td><td></td><td>100</td>' \
'</tr>' \
'</table>' \
'</body></html>'
if __name__ == "__main__":
result_file = open(outputFilename, "w+b")
pisa_status = pisa.CreatePDF(
source_html,
dest=result_file)
result_file.close()
print(pisa_status)
And this is how results are compared.
I’ve used a latest version from develop branch 1.a1
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
How can I stop Tabula from automatically dropping empty ...
UPDATE: The best solution I could find was fiddling with the 'lattice' settings which determined how tables are read in Tabula (you can...
Read more >Data Cleaning with Python and Pandas: Detecting Missing ...
Pandas will recognize both empty cells and “NA” types as missing values. ... case where there's missing values that have different formats.
Read more >asciitable 0.8.0 documentation
An extensible ASCII table reader and writer for Python 2 and 3. Asciitable can read and write a wide range of ASCII table...
Read more >Built-in Exceptions — Python 3.11.1 documentation
If str() is called on an instance of this class, the representation of the argument(s) to the instance are returned, or the empty...
Read more >Reading tables — Astropy v0.4.2
Guess table format¶ · At least two table columns · No column names are a float or int number · No column names...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, the problem appears only in Python3. I’ve described workaround and I’ll try to propose a fix for that
@arkadicolson The code for Python 2 and 3 is the same, can you state which version of XHTML2PDF you are on, and an example input and output?