【问题标题】:Django pdf: page layout with long texts using pisaDjango pdf:使用比萨的长文本页面布局
【发布时间】:2011-09-20 13:12:30
【问题描述】:

我使用 pisa 生成了一些如下布局的 PDF 文件:

  @page {
        size: a4;
        @frame header {
          top: 5.4cm;
          bottom: 4cm;
          left: 1.2cm;
          right: 1.2cm;
        }
        @frame main {
          top: 10.5cm;
          bottom: 4cm;
          left: 1.2cm;
          right: 1.2cm;
        }
        @frame footer {
          top: 26cm;
          left: 1.2cm;
          right: 1.2cm;
        }
      }

有时主框架的内容不够短,无法放入单个页面,因此它也会使用页脚框架的空间。取而代之的是,我希望将其余文本放在第二页的主要框架空间中(并保持其余框架的空间清晰)。有什么建议吗?

【问题讨论】:

    标签: django pisa


    【解决方案1】:

    比萨不是特别容易弄清楚。我用它来生成几种不同格式的报告。

    我不会将我的主要内容放在框架内。此外,它都是英寸/字母大小,但我想告诉你我的设置是如何设置的,并且适用于多个页面。

    您的问题可以通过向@page<keepinframe></keepinframe> 添加边距来解决 标签。

    <document pagesize='letter'>
    <head>
        <title>{{ title }}</title>
        <style type="text/css">
            @page {
                size: letter portrait;
                margin: 1.0in 0.25in 0.5in 0.25in;
                padding: 0;
    
                @frame header {
                    -pdf-frame-content: headerContent;
                    width: 8in;
                    top: 0.5in;
                    margin-left: 0.5in;
                    margin-right: 0.5in;
                    height: 1.0in;
                }
                @frame footer {
                    -pdf-frame-content: footerContent;
                    width: 8in;
                    bottom: 0in;
                    margin-left: 2cm;
                    margin-right: 2cm;
                    height: 1cm;
                }
            } <!-- end of @page bracket -->
    
            <!-- add content styles here -->
            h1 { text-align: middle; font-size: 18px; }
        </style>
    </head>
    <body>
    <div id='headerContent'>
        <!-- header content -->
    </div>
    <div>
        <keepinframe>
         <!-- Content -->
        </keepinframe>
    </div>
    <div id='footerContent'>
        <!-- footer content -->
        <pdf:pagenumber>
    </div>
    </body>
    </document>
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-04
    相关资源
    最近更新 更多