代码之家  ›  专栏  ›  技术社区  ›  DeepProblems

敏捷的页脚产生一个奇怪的边距成比例的大小

  •  2
  • DeepProblems  · 技术社区  · 6 年前

    以下是我的页脚代码:

    <!doctype html>
    <html>
    <head>
        <meta charset="UTF-8">
    
    </head>
    <body>
    <div style="height: 1rem; background-color: #1C440C">
    
        <span>Hello world</span>
    
    </div>
    </body>
    </html>
    

    主页面:

    <!doctype html>
    <html>
    <head>
        <meta charset="UTF-8">
    
    </head>
    <body>
    
    
        Hello world page
    
    </body>
    </html>
    

    以及控制器:

       /**
         * @Route("/path", name="myurl")
         */
        public function toPdf()
        {
            $html = $this->renderView('pdf/page.html.twig');
            $footer = $this->renderView('pdf/footer2_pdf.html.twig');
            return new Response(
                $this->get('knp_snappy.pdf')->getOutputFromHtml($html, array(
                    'footer-html' => $footer
                )),
                200,
                array(
                    'Content-Type'          => 'application/pdf',
                    'Content-Disposition'   => 'attachment; filename="file.pdf"'
                )
            );
    

    enter image description here

    “helloworld”和页面bot之间的距离看起来像pdf的默认边距,所以看起来还可以。

    然后,如果我将height改为5rem以获得更大的页脚,我会得到:

    enter image description here

    页脚变大了,但页脚和页尾之间的边距却疯狂地增加了。我真的不明白为什么。

    谢谢你的阅读,如果你知道答案,请随意回答。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Daneel    6 年前

    为便于将来参考,只需使用此解决方案设置下边距: pdf page margins with snappy and symfony2 干杯!