<div dir="ltr"><div>Hi Andy, thanks for the report. It is a bug so perhaps this is a rare case as tests did not catch it.</div><div><br></div><div>I have added a fix and another test. They will be in the release.</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Sat, 20 Dec 2025 at 16:52, Andy Hagar <<a href="mailto:atboom33w@gmail.com">atboom33w@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello!<br><br>I recently ran into an issue with table column sizing. Initially, the error message was for:<br>AttributeError: 'float' object has no attribute 'endswith'<br><br>An example setup is below to show the error happening.<br><br>To get to this code path, I happened to have the following in my table using Platypus<br>-At least 1 entry in a row uses Paragraph for formatting<br>-Specifying colWidth with one entry using percentage "%"<br>-Data in columns causing total column width to exceed availableWidth<br><br>The error occurs at line 940 in tables.py:<br>if w.endswith('%'):<br><br>Watching at execution, w is indeed a float.<br>Just changing to using the already existing _endswidth(w,'%') function does allow the pdf to build, but it is ignoring the "X%" specified.<br><br>Changing line 940 and the following has it look at W where the actual "X%" value exists, but also changes the calculation on line 941 to handle the percentage calc (assuming it is meant to be a % out of 100).<br><br>Current:<br>if w.endswith('%'):<br>       W[colNo] = w = availWidth*float(w[:-1])/percentTotal<br><br>Updated:<br>if _endswith(W[colNo], '%'):<br>        W[colNo] = w = availWidth * float(W[colNo][:-1]) / 100<br><br><br>This change works fine to a point. When you specify a large-ish % and have columns that are "wide", other errors start showing up. For the below script, 88 or higher % causes errors elsewhere.<br><br>This error is already called out in <a href="https://groups.google.com/g/reportlab-users/c/k7GS01u3jrU" target="_blank">https://groups.google.com/g/reportlab-users/c/k7GS01u3jrU</a><br>Error:<br>TypeError: '>' not supported between instances of 'NoneType' and 'int'<br><br>Caused by Line 440:<br>tallest = '(tallest row %d)' % int(max(rh))<br><br>Changing to:<br>tallest = '(tallest row %d)' % int(max([i for i in rh if i], default=0))<br><br>Next error:<br>ValueError: <Table@0x20017F3A270 2 rows x 3 cols(tallest row 18)> with cell(0,0) containing<br>'Header 1': flowable given negative availWidth=-0.779770753733942 == width=11.220229246266058 - leftPadding=6 - rightPadding=6<br><br><br>At this point, as I was changing the % for testing and errors started getting out of my depth, I just said "don't use silly %" and went about my business :) <br><br>---<br><br>Example script to hit this code path:<br><br>from reportlab.platypus import SimpleDocTemplate, Table, Paragraph<br>from reportlab.lib.pagesizes import letter<br>from reportlab.lib.styles import getSampleStyleSheet<br><br>styles = getSampleStyleSheet()<br><br>data = [<br>    ['Header 1', 'Header 2', 'Header 3'],<br>    [Paragraph('Row 1, Col 1 wide data wide data wide data wide data', styles['Normal']), 'Row 1, Col 2 wide data wide data wide data', 'Row 1, Col 3 wide data wide data wide data']<br>]<br><br>doc = SimpleDocTemplate("table_endswidth.pdf", pagesize=letter)<br>story = []<br><br>colwidths = [None, "20%", None] <br>table = Table(data, colWidths=colwidths)<br><br>story.append(table)<br>doc.build(story)</div>
</blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Robin Becker<br></div>