raise LayoutError(ident)
reportlab.platypus.doctemplate.LayoutError:
Flowable <Table@0x7FA13491B898 1 rows x 1 cols(tallest row 900)> with cell(0,0) containing
'<Table@0x7FA1349110B8 1 rows x 1 cols(tallest row 894)> with cell(0,0) containing\n\'<Table@0x7FA1349894E0 1 rows x 1 cols(tallest row 24)> with cell(0,0) containing\\n"<Table@0x7FA134989438 1 rows x 1 cols(tallest row 18)> with cell(0,0) containing\\\\n\\\'Vulnerability ( Virustotal Domain Report )\\\'"\''(583.2755905511812 x 900), tallest cell 900.0 points, too large on page 6 in frame 'normal'(583.2755905511812 x 794.8897637795277*) of template 'Later'
我为它做了一个PDF( A4 )大小并得到了错误,而我enter code here
为它制作了A3问题解决了,我想要A4大小的解决方案。
def getToolsTables(data, tname):
doc = SimpleDocTemplate(
"somefilename.pdf",
pagesize=A2,
topMargin=25,
bottomMargin=0,
)
main_header = []
h_arr1 = []
h_arr1.append(tname)
main_header.append(h_arr1)
mainHeader = Table(main_header, colWidths="*")
finalTable = []
main_table_header_Style = TableStyle(
[
("BACKGROUND", (0, 0), (-1, 0), "#D3D3D3"),
("TEXTCOLOR", (0, 0), (-1, -1), colors.black),
("ALIGN", (0, 0), (-1, -1), "LEFT"),
("FONTSIZE", (0, 0), (-1, -1), 12),
("FONTNAME", (0, 0), (-1, -1), "Courier-Bold"),
("TOPPADDING", (0, 0), (-1, -1), 5),
("BOTTOMPADDING", (0, 0), (-1, -1), 7),
("LINEBELOW", (0, 0), (-1, 0), 1, colors.black),
]
)
tools_table_header_Style = TableStyle(
[
("BACKGROUND", (0, 0), (-1, 0), "lightblue"),
("TEXTCOLOR", (0, 0), (-1, -1), colors.black),
("ALIGN", (0, 0), (-1, -1), "LEFT"),
("FONTSIZE", (0, 0), (-1, -1), 11),
("FONTNAME", (0, 0), (-1, -1), "Courier-Bold"),
]
)
tools_table_header_Style1 = TableStyle(
[
("BACKGROUND", (0, 0), (-1, 0), "lightgreen"),
("TEXTCOLOR", (0, 0), (-1, -1), colors.black),
("ALIGN", (0, 0), (-1, -1), "CENTER"),
("FONTSIZE", (0, 0), (-1, -1), 11),
("FONTNAME", (0, 0), (-1, -1), "Courier-Bold"),
]
)
Style2 = TableStyle(
[
("ALIGN", (0, 0), (-1, -1), "LEFT"),
("LEFTPADDING", (0, 0), (-1, -1), 0),
("RIGHTPADDING", (0, 0), (-1, -1), 0),
("BOTTOMPADDING", (0, 0), (-1, -1), -10),
]
)
Style3 = TableStyle(
[
("VALIGN", (0, 0), (-1, -1), "TOP"),
("ALIGN", (0, 0), (-1, -1), "RIGHT"),
("LEFTPADDING", (0, 0), (-1, -1), 130),
("RIGHTPADDING", (0, 0), (-1, -1), 0),
("TOPPADDING", (0, 0), (-1, -1), 0),
]
)
Style4 = TableStyle([("VALIGN", (0, 0), (-1, -1), "TOP")])
mainHeader.setStyle(
main_table_header_Style
) # adding style to table main header
finalTable.append(mainHeader)
# Create Tools Array
tools_header = []
tools_body = []
if type(data) == dict:
all_table = []
for key, value in data.items():
temp = []
temp_table = []
temp.append(key)
tool_table_header = Table([temp], colWidths="*")
tool_table_header.setStyle(tools_table_header_Style)
temp_table.append(tool_table_header)
if key != "Builtwith":
t_h = []
t_b = []
for k, v in value.items():
t_h.append(k)
t_b.append(v)
t_body = []
for index, item in enumerate(t_h):
if item != "status":
arr1 = []
arr2 = []
if type(t_b[index]) is list:
temp_txt = ""
for txt in t_b[index]:
temp_txt += txt + ", "
arr1.append(item + ":")
text = t_b[index]
wraped_text = "\n".join(
wrap(str(temp_txt[:-3]), 60)
) # 60 is line width
arr1.append(wraped_text)
else:
# MY CODE
arr2.append(arr1)
n_table = Table(arr2, [200, 370])
n_table.setStyle(Style4)
t_body.append(n_table)
tool_header = Table([temp_table], colWidths="*")
tool_body = Table([[t_body]], [200, 370])
finalTable.append(
Table(
[[[tool_header, tool_body]]],
colWidths="*",
)
)
发布于 2022-11-11 17:48:47
在splitInRow
类中使用Table
参数,以便将另一个页面上的数据拆分,例如:
tool_body = Table([[t_body]], [200, 370], splitInRow=1)
https://stackoverflow.com/questions/71218680
复制相似问题