【问题标题】:TCPDF Custom page sizeTCPDF 自定义页面大小
【发布时间】:2011-04-26 07:36:20
【问题描述】:

tcpdf 网站上的This example 展示了如何使用 A4、A5 等页面格式,但我如何将 tcpdf 设置为使用 175 毫米 x 266 毫米等自定义尺寸?

解决方案赞赏。

【问题讨论】:

    标签: tcpdf


    【解决方案1】:

    不需要编辑类... tcpdf 不接受宽度/长度参数,它只接受两个长度并确定哪个使用布局(纵向或横向)

    $pageLayout = array($width, $height); //  or array($height, $width) 
    $pdf = new TCPDF('p', 'pt', $pageLayout, true, 'UTF-8', false);
    

    【讨论】:

    • 谢谢!帮了我很多!
    【解决方案2】:

    转到 /config/tcpdf_config.php 并在第 117 行附近,修改该行:

    define ('PDF_PAGE_FORMAT', 'A4');
    

    通过

    define ('PDF_PAGE_FORMAT', 'LETTER');
    

    “LETTER”大写很重要,您可以在此文件中看到所有可能的值:tcpdf/include/tcpdf_static.php。

    【讨论】:

      【解决方案3】:

      在较新的 TCPDF 版本上,您可以通过多种方式定义页面大小:

      • 已经定义了所有标准页面格式(超过 300 种类型)。
      • 您可以通过定义一个包含 2 个数字的数组来简单地定义页面大小:宽度、高度(无论页面方向)。
      • 或者,您可以按照setPageFormat() 方法http://www.tcpdf.org 的文档中的说明定义高级页面详细信息(MediaBox、Cropbox、BleedBox、TrimBox、ArtBox)。

      还要检查默认示例编号。 28 岁和 60 岁,http://www.tcpdf.org。

      【讨论】:

        【解决方案4】:

        说实话,现在你可以这样解决了。

        //AddPage [P(PORTRAIT),L(LANDSCAPE)],FORMAT(A4-A5-ETC)
        
        $pdf->AddPage('P','A5');
        

        来源: https://tcpdf.org/examples/example_028/

        【讨论】:

          【解决方案5】:

          // 8.5 X 13 英寸纸

          $pdf = new Pdf('P', 'mm', array(215.9, 330.2), true, 'UTF-8', false);

          【讨论】:

          【解决方案6】:

          编辑 tcpdf.php 并添加新的页面类型或将现有类型修改为您的页面大小。

          【讨论】:

            【解决方案7】:

            上面的答案对我不起作用,所以我在这里添加我的解决方案 - 从http://www.tcpdf.org/examples/example_060.phps,更改 urx, ury 以达到您的目的

            // set page format (read source code documentation for further information)
            // MediaBox - width = urx - llx 210 (mm), height = ury - lly = 297 (mm) this is A4
            $page_format = array(
                'MediaBox' => array ('llx' => 0, 'lly' => 0, 'urx' => 210, 'ury' => 297),
                //'CropBox' => array ('llx' => 0, 'lly' => 0, 'urx' => 210, 'ury' => 297),
                //'BleedBox' => array ('llx' => 5, 'lly' => 5, 'urx' => 205, 'ury' => 292),
                //'TrimBox' => array ('llx' => 10, 'lly' => 10, 'urx' => 200, 'ury' => 287),
                //'ArtBox' => array ('llx' => 15, 'lly' => 15, 'urx' => 195, 'ury' => 282),
                'Dur' => 3,
                'trans' => array(
                    'D' => 1.5,
                    'S' => 'Split',
                    'Dm' => 'V',
                    'M' => 'O'
                ),
                'Rotate' => 90,
                'PZ' => 1,
            );
            
            // Check the example n. 29 for viewer preferences
            
            // add first page ---
            $pdf->AddPage('P', $page_format, false, false);
            

            【讨论】:

              猜你喜欢
              • 2020-02-28
              • 2015-02-27
              • 1970-01-01
              • 1970-01-01
              • 2018-08-26
              • 1970-01-01
              • 2011-12-14
              • 2021-01-16
              • 1970-01-01
              相关资源
              最近更新 更多