如何使用Python将表单转换为PDF

2024-04-26 17:34:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我用WTForms和html创建了一些表单。如何使用Python将其转换为PDF? 例如下面的表单,对于表单上的submit按钮,我想添加一个使用python将这些数据下载为pdf格式的方法。在

<div class="container" align="center" style="padding-top:15px;">
    <form action=" " method="POST" >
        <input type="hidden"  name="id_patient" id="id_patient" value="{{ doc_patient._id}}">
        <button type="submit">Download</button> </form>
        <section>
            <br>
            <h3 style="padding-left:50px;"> Patient Form</h3><br>

            <table class="patient-view-table">
                <tr>
                    <td class="property-name-col">Name:</td>
                    <td class="property-value-col">{{ patient_doc.name }}</td>
                </tr>
                <tr>
                    <td class="property-name-col">Surname:</td>
                    <td class="property-value-col">{{ patient_doc.surname }}</td>
                </tr>
                <tr>
                    <td class="property-name-col">Sex:</td>
                    <td class="property-value-col">{{ patient_doc.sex }}</td>
                </tr>
                <tr>
                    <td class="property-name-col">Personal number:</td>
                    <td class="property-value-col">{{ patient_doc.personal_number }}</td>
                </tr>
                <tr>
                    <td class="property-name-col">Date of birth:</td>
                    <td class="property-value-col">{{ patient_doc.birthday }}</td>
                </tr>
                <tr>
                    <td class="property-name-col">Address:</td>
                    <td class="property-value-col">{{ patient_doc.address }}</td>
                </tr>
            </section>
        </table>
</div>

有人能帮我吗?谢谢。在


Tags: namedivid表单docvaluestyletable