hello,

i try to write a pdf from a server side generated svg.

def pdf():
    import os
    from svglib.svglib import svg2rlg
    from svglib.svglib import SvgRenderer
    from reportlab.graphics import renderPDF
    import gluon.contenttype
    import StringIO
    import xml.dom.minidom
    resp = StringIO.StringIO()   
    file_path = os.path.join(request.folder, 'static/svg', 
'templatevdsl.svg')
    file = open(file_path, "rb")
    svg = file.read()
    tmpl = TAG(svg)
    s = tmpl.elements('g[inkscape:groupmode=layer]')   
    for el in s:
       el['_style']='display:none'
    s[0]['_style']='display:inline'

    drawing = svg2rlg(svg)
    renderPDF.drawToFile(drawing, resp)
    resp.seek(0)
    response.headers['Content-Type'] = gluon.contenttype.contenttype('.pdf')
    filename = "%s_Purchases.pdf" % (request.env.server_name)
    response.headers['Content-disposition'] = "attachment; filename=\"%s\"" 
% filename
    return resp.read()

Dont work.
I get de folowing error

Traceback (most recent call last):
  File "gluon/restricted.py", line 212, in restricted
  File "D:/dev/web2py/applications/map/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/map/controllers/default.py>, line 
134, in <module>
  File "gluon/globals.py", line 193, in <lambda>
  File "D:/dev/web2py/applications/map/controllers/default.py" 
<http://127.0.0.1:8000/admin/default/edit/map/controllers/default.py>, line 73, 
in pdf
  File "D:\dev\web2py\site-packages\reportlab\graphics\renderPDF.py", line 276, 
in drawToFile
  File "D:\dev\web2py\site-packages\reportlab\graphics\renderbase.py", line 
167, in renderScaledDrawing
AttributeError: 'NoneType' object has no attribute 'renderScale'


any sugestion?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to