Skip to content

Incorporate into Flask Application #2

@stenlytw

Description

@stenlytw

Hi,

Is there any way to incorporate this module into Flask Application? I tried incorporating into Flask by creating a function:

def render_pdf(string, filename):    
    import pyppdf
    pdf = pyppdf.save_pdf(filename + '.pdf', html=string)	

    response = make_response(pdf)
    response.headers['Content-Type'] = 'application/pdf'
    response.headers['Content-Disposition'] = 'attachment; filename = ' + filename + '.pdf'
    return response

and call render_template as the first parameter, but got this error:

File "C:\Users\admiin\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pyppdf\pyppeteer_pdf.py", line 216, in save_pdf
return asyncio.get_event_loop().run_until_complete(
File "C:\Users\admiin\AppData\Local\Programs\Python\Python37-32\lib\asyncio\events.py", line 644, in get_event_loop
% threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Thread-3'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions