PDFKit generate pdf in python -
i need generate pdf html tables, , looking library allows take html tables full css , make pdf. i'm trying pdfkit. installed , tested simple examples explained in documentation,it works. documentation link:pdfkit
i have tables this,this table want convert pdf:
<form action="{{ url_for('patient_directory.make_pdf')}}" method="post"> <button id="download_s" type="submit" class="btn btn-success">create pdf</button> <table class="patient-view-table" id="table_to_pdf"> <thead> <tr> <th>name</th> <th>surname</th> <th>sex</th> <th>date of birth</th> <th>diagnosis</th> </tr> </thead> <tbody> <tr> <td class="property-value-col">{{ patient.name }}</td> <td class="property-value-col">{{ patient.surname }}</td> <td class="property-value-col">{{ patient.sex }}</td> <td class="property-value-col">{{ patient.date_of_birth }}</td> <td class="property-value-col">{{ patient.diagnosis }}</td> </tr> </tbody> </table> </form> in form action of table above called method, created route method:
mod_patient_directory.add_url_rule( '/pdf',methods=['get', 'post']) def make_pdf(''): pdfkit.from_string(table_to_pdf, 'example.pdf') my problem when try generate pdf don't know how pass arguments, example, how make know want generate pdf table id="table_to_pdf"? help?
it looks using flask framework:
have @ of example here , here.
you can pass form id in url parameter.
@app.route('/pdf/<formid>/', methods=['get', 'post']) def make_pdf(formid): ...
Comments
Post a Comment