TCPDF Custom page size

前端 未结 7 1559
执笔经年
执笔经年 2020-12-09 08:35

This example on tcpdf\'s website shows how to use page formats like A4, A5 etc, but how do I set tcpdf to use custom sizes like 175mm x 266 mm?

Solutions appreciated.

7条回答
  •  不思量自难忘°
    2020-12-09 09:25

    EDIT : I was just wrong : you can give an array (array($width, $height)) in parameter..

    I created a tcpdf subclass where I modified a few things : getPageSizeFromFormat(); Here is the code : http://paste.pocoo.org/show/294958/.

    Then I call my custom class, add a new format and set a new format :

    $pdf = new CUSTOMPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);  
    //Add a custom size  
    $width = 175;  
    $height = 266; 
    $orientation = ($height>$width) ? 'P' : 'L';  
    $pdf->addFormat("custom", $width, $height);  
    $pdf->reFormat("custom", $orientation);  
    

提交回复
热议问题