2010-10-16 1279 views

回答

15

编辑: 我是不对的:你可以给一个数组中的参数(数组($宽度,高度$))..

我创建了一个子类TCPDF,我修改了几件事情:getPageSizeFromFormat (); 这里是代码:http://paste.pocoo.org/show/294958/

然后,我打电话给我的自定义类,添加一个新的格式,并设置一个新的格式:

$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); 
0

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

30

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

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

谢谢!帮助我很多! – Refilon 2014-10-30 13:10:58

7

Onthe较新版本TCPDF可以以多种方式定义的页面大小。 所有标准页面格式都已定义(超过300种类型)。 您可以简单地通过定义一个包含2个数字的数组来定义页面大小:宽度,高度(不管页面方向)。 另外,您也可以定义高级页面详细信息(MediaBox,Cropbox,BleedBox,TrimBox,ArtBox),如在 的setPageFormat()方法文档中所述。 28和60在http://www.tcpdf.org

0

以上回答不会为我工作,所以我在这里添加我的解决方案 - 从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); 
5

进入/配置/ tcpdf_config。 PHP和围绕线117,修改的行:通过

define ('PDF_PAGE_FORMAT', 'LETTER'); 

define ('PDF_PAGE_FORMAT', 'A4'); 

它将“LETTER”放入大写字母非常重要,您可以在该文件中看到所有可能的值:tcpdf/include/tcpdf_static.php