naitsirch tcpdf extension
v1.2.0
TCPDF는 PDF 문서를 생성하는 PHP 라이브러리입니다. 기능이 풍부하지만 사용하기 쉽지는 않습니다.
이 라이브러리는 TCPDF 라이브러리 위에 있습니다. 현재 상태에서는 편안한 방식으로 테이블을 만드는 스마트 API 만 제공합니다.
이 저장소는 포기되어 더 이상 사용해서는 안됩니다. naitsirch/tcpdf-extension 에서 호환 stollr/tcpdf-extension 으로 변경하십시오.
이 라이브러리를 사용하는 가장 쉬운 방법은 작곡가를 통해 설치하는 것입니다.
이것을 프로젝트의 composer.json에 추가하십시오.
{
"require" : {
"naitsirch/tcpdf-extension" : " dev-master "
}
}먼저 TCPDF 인스턴스를 만들어야합니다.
use TCPDF ;
$ pdf = new TCPDF ( ' P ' , ' mm ' , ' A4 ' , true , ' UTF-8 ' , false );
$ pdf -> SetTitle ( ' My PDF file ' );
$ pdf -> SetMargins ( 20 , 20 , 20 );
$ pdf -> SetPrintHeader ( false );
$ pdf -> SetPrintFooter ( false );
$ pdf -> SetAutoPageBreak ( true , 9 );
$ pdf -> SetFont ( ' dejavusans ' , '' , 10 );익숙하지 않은 경우 TCPDF 클래스의 문서를 살펴보십시오.
다음 단계에서는 테이블을 만들 수 있습니다.
use Tcpdf Extension Table Table ;
$ pdf -> AddPage (); // add a new page to the document
$ table = new Table ( $ pdf );
$ table
-> newRow ()
-> newCell ()
-> setText ( ' Last Name ' )
-> setFontWeight ( ' bold ' )
-> end ()
-> newCell ()
-> setText ( ' First Name ' )
-> setFontWeight ( ' bold ' )
-> end ()
-> newCell ()
-> setText ( ' DOB ' )
-> setFontWeight ( ' bold ' )
-> end ()
-> newCell ()
-> setText ( ' Email ' )
-> setFontWeight ( ' bold ' )
-> end ()
-> end ()
-> newRow ()
-> newCell ( ' Foo ' )-> end ()
-> newCell ( ' John ' )-> end ()
-> newCell ( ' 1956-04-14 ' )-> end ()
-> newCell ( ' [email protected] ' )-> end ()
-> end ()
;
$ table -> end (); // this prints the table to the PDF. Don't forget!위의 코드는 매우 간단한 테이블을 만드는 방법을 보여줍니다. 그러나 다른 방식으로 테이블 셀을 사용자 정의 할 수 있습니다.
$ table
-> newRow ()
-> newCell ( ' Last Name ' ) // you can set the cell content like this
-> setText ( ' Override Text ' ) // or like this
-> setFontWeight ( ' bold ' ) // set font weight 'bold' or 'normal'
-> setAlign ( ' L ' ) // text alignment ('L', 'C', 'R' or 'J')
-> setVerticalAlign ( ' top ' ) // vertical alignment ('top', 'bottom' or 'middle')
-> setBorder ( 1 ) // border format (like in TCPDF::MultiCell)
-> setRowspan ( 1 ) // rowspan like in HTML
-> setColspan ( 2 ) // colspan like in HTML
-> setFontSize ( 10 ) // unit for font size is same as defined in TCPDF
-> setMinHeight ( 10 ) // defining min-height of the cell like in CSS
-> setPadding ( 2 , 4 ) // setting cell padding (inner margin) like in CSS
-> setPadding ( 2 , 4 , 5 , 6 ) // or like this
-> setWidth ( 125 ) // unit for width is same as defined in TCPDF
-> end ()배경색 정의 :
$ table
-> newRow ()
-> newCell ( ' Last Name ' )
-> setBackgroundColor ( ' #ff4400 ' ) // hexadecimal RGB color code
->setBackgroundColor( array ( 250 , 80 , 10 ) // decimal RGB color array
-> end ()
-> end ()각 테이블 셀의 배경 이미지를 정의 할 수 있습니다.
$ table
-> newRow ()
-> newCell ( ' Last Name ' )
-> setBackgroundDpi ( 300 ) // define the resolution for the printing
-> setBackgroundImage ( ' /path/to/my/image.png ' ) // pass the path to your image
-> setBackgroundImage ( $ binaryImageString ) // or pass the binary file content of your image
-> end ()
-> end ()