Merge pull request #447 from reingart/master

fixing pypdf table rendering issues due attribute sanitization
This commit is contained in:
mdipierro
2014-05-22 08:12:41 -05:00
2 changed files with 11 additions and 1 deletions

View File

@@ -179,6 +179,7 @@
'Exception instance attributes': 'Atributos de la instancia de Excepción',
'Exit Fullscreen': 'Exit Fullscreen',
'Expand Abbreviation': 'Expand Abbreviation',
'Expand Abbreviation (html files only)': 'Expand Abbreviation (html files only)',
'export as csv file': 'exportar como archivo CSV',
'exposes': 'expone',
'exposes:': 'expone:',
@@ -237,6 +238,7 @@
'invalid ticket': 'tiquete inválido',
'Key bindings': 'Key bindings',
'Key bindings for ZenCoding Plugin': 'Key bindings for ZenCoding Plugin',
'Keyboard shortcuts': 'Keyboard shortcuts',
'language file "%(filename)s" created/updated': 'archivo de lenguaje "%(filename)s" creado/actualizado',
'Language files (static strings) updated': 'Archivos de lenguaje (cadenas estáticas) actualizados',
'languages': 'lenguajes',

View File

@@ -58,8 +58,16 @@ def pyfpdf_from_html(html):
pass
pdf = MyFPDF()
pdf.add_page()
# pyfpdf needs some attributes to render the table correctly:
html = sanitize(
html, escape=False) # should have better list of allowed tags
html, allowed_attributes={
'a': ['href', 'title'],
'img': ['src', 'alt'],
'blockquote': ['type'],
'td': ['align', 'bgcolor', 'colspan', 'height', 'width'],
'tr': ['bgcolor', 'height', 'width'],
'table': ['border', 'bgcolor', 'height', 'width'],
}, escape=False)
pdf.write_html(html, image_map=image_map)
return XML(pdf.output(dest='S'))