pisa pdf generation-仅限第一页的文字

时间:2012-03-09 15:52:24

标签: python django pdf reportlab pisa

我想用比萨(& django python)创建字母。我需要公司地址出现在第一页而不是后续页面。我无法解决如何做到这一点,这让我感到疯狂(比萨上没有很多文件。

此外,我希望能够在不使内容静态的情况下使用框架(与-pdf-frame-content css属性一样)。

目前我的徽标显示在顶部和底部,我的文字显示正常,我只是在努力控制它出现的位置。

<!DOCTYPE HTML>
<html>
    <head>
       <title>Patient Acceptance</title>
       <style type="text/css">
           @page {
               size:  {{ pagesize }};
               margin-top: 3.5cm;
               margin-left: 2.5cm;
               margin-bottom: 4cm;
               margin-right: 2cm;
               @frame footer {
                   -pdf-frame-content: pdf_footer_content;
                   bottom: 0cm;
                   margin-left: 2cm;
                   margin-right: 0.5cm;
                   height: 3cm;
               }
               @frame blar_logo {
                   -pdf-frame-content: pdf_blar_logo;
                   top: 0.5cm;
                   margin-left: 2cm;
                   margin-right: 15cm;
                   height:3cm;
               }
           }
           .blar_address {
                   top: 0cm;
                   margin-left: 13cm;
                   margin-right: 0cm;
                   height:4cm;
               }
           .institution_address {
                   top: 0.9cm;
                   margin-left: 0cm;
                   width: 10cm;
                   height:4cm;
               }
       </style>
    </head>
    <body>
       <div id = "pdf_logo">
           <img alt="study logo" src="/media/images/logo_for_letters2.jpg"/>
       </div>
       <div class="blar_address">
           Central Monitoring Office</br>
           Castle Hospital</br>
           Castle Road</br>
           Brendam</br>
           East Binkleshire, BK2 3LK</br>
       </div>
       <div class="institution_address">
        {{ gp.gp_title }} {{ gp.gp_firstname }} {{ gp.gp_surname }}</br>
        {{ gp.practice_id.practice_name }} </br>
        {{ gp.practice_id.address_1 }} </br>
        {% if gp.practice_id.address_2 %}
            {{ gp.practice_id.address_2 }} </br>
        {% endif %}
        {% if gp.practice_id.address_3 %}
            {{ gp.practice_id.address_3 }} </br>
        {% endif %}
        {% if gp.practice_id.address_4 %}
            {{ gp.practice_id.address_4 }} </br>
        {% endif %}
        {% if gp.practice_id.town_city %}
            {{ gp.practice_id.town_city }} </br>
        {% endif %}
        {% if gp.practice_id.post_code %}
            {{ gp.practice_id.post_code }} </br>
        {% endif %}
       </div>
       <p> {{ date }} </p>
       <p>Please file this letter and a copy of the patient&#39s informed consent in the patient&#39s case records</p>
       <p>Dear {{ gp.gp_title }} {{ gp.gp_surname }},</p>
       <p>I am writing to inform you that your patient {{ patient.patient_title }} {{ patient.patient_firstname }} {{ patient.patient_surname }}, {{ patient.address_1}}
        {% if patient.address_2 %}
            , {{ patient.address_2 }}
        {% endif %}
        {% if patient.address_3 %}
            , {{ patient.address_3 }}
        {% endif %}
        {% if patient.address_4 %}
            , {{ patient.address_4 }}
        {% endif %}
        {% if patient.town_city %}
            , {{ patient.town_city }}
        {% endif %}
        {% if patient.post_code %}
            , {{ patient.postcode }}
        {% endif %}
       , has volunteered to participate in a clinical trial entitled Blar</p>
       <p>This patient has been assigned to   
       {% if patient.cora = 'C' %}
            blar
       {% else %}
            blar
       {% endif %}                         
       <p>This is a randomised controlled trial funded by the NHS comparing blar and blar
       <p>Should you have any questions or concerns, please contact the central monitoring office on 01815 654864.</p>
       <p>Yours sincerely,</p>
       </br>
       </br>
       <p>Professor Blar</p>
       <div>
       </div>

       <div id="pdf_footer_content">
           <img alt="Bniklle NHS Logo" src="/media/images/blar_nhs_logo_for_letters2.jpg"/>
           <img alt="University of Bunkum Logo" src="/media/images/uni_blar_logo_for_letters2.jpg"/>
       </div>
    </body>
</html>

0 个答案:

没有答案