2010-10-16 336 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