使用Reportlab生成pdf,一切顺利。遇到引发以下错误的问题......
raise ValueError('paraparser: syntax error: %s' % message)
ValueError: (u"paraparser: syntax error: invalid attribute name alt attrMap=['height', 'src', 'valign', 'width']", '\nparagraph text u\'<para><p><strong>
这似乎是由一个ReportLab不喜欢的角色引起的,因为我可以使用&#34; escape&#34;但这会导致段落忽略<P>
和<strong>
是否有快速识别相关角色的方法?或者也许是解决这个问题的另一种方法?
def getDescription(eventid):
res = tq.get("api/events/%s/" % eventid)
ed = res['data']['description']
if not ed:
logger.debug("No description exists for event %s. Skipping this section." % eventid)
return()
else:
formattedDesc = ed.replace('\n', '<br/>')
logger.debug("Description of event is \n %s" % formattedDesc)
#Story.append(Paragraph(escape(formattedDesc), styles["TQ-Description"]))
#Changed to the following to prevent an error thrown by XX reports. Need to figure out why.
Story.append(Paragraph(escape(formattedDesc), styles["TQ-Description"]))