📄 tcpdf.php
字号:
$this->buffer=''; $this->pages=array(); $this->OrientationChanges=array(); $this->state=0; $this->fonts=array(); $this->FontFiles=array(); $this->diffs=array(); $this->images=array(); $this->links=array(); $this->InFooter=false; $this->lasth=0; $this->FontFamily=''; $this->FontStyle=''; $this->FontSizePt=12; $this->underline=false; $this->DrawColor='0 G'; $this->FillColor='0 g'; $this->TextColor='0 g'; $this->ColorFlag=false; $this->ws=0; // encryption values $this->encrypted=false; $this->last_rc4_key=''; $this->padding="\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A"; //Standard Unicode fonts $this->CoreFonts=array( 'courier'=>'Courier', 'courierB'=>'Courier-Bold', 'courierI'=>'Courier-Oblique', 'courierBI'=>'Courier-BoldOblique', 'helvetica'=>'Helvetica', 'helveticaB'=>'Helvetica-Bold', 'helveticaI'=>'Helvetica-Oblique', 'helveticaBI'=>'Helvetica-BoldOblique', 'times'=>'Times-Roman', 'timesB'=>'Times-Bold', 'timesI'=>'Times-Italic', 'timesBI'=>'Times-BoldItalic', 'symbol'=>'Symbol', 'zapfdingbats'=>'ZapfDingbats' ); //Scale factor switch (strtolower($unit)){ case 'pt': {$this->k=1; break;} case 'mm': {$this->k=72/25.4; break;} case 'cm': {$this->k=72/2.54; break;} case 'in': {$this->k=72; break;} default : {$this->Error('Incorrect unit: '.$unit); break;} } //Page format if(is_string($format)) { // Page formats (45 standard ISO paper formats and 4 american common formats). // Paper cordinates are calculated in this way: (inches * 72) where (1 inch = 2.54 cm) switch (strtoupper($format)){ case '4A0': {$format = array(4767.87,6740.79); break;} case '2A0': {$format = array(3370.39,4767.87); break;} case 'A0': {$format = array(2383.94,3370.39); break;} case 'A1': {$format = array(1683.78,2383.94); break;} case 'A2': {$format = array(1190.55,1683.78); break;} case 'A3': {$format = array(841.89,1190.55); break;} case 'A4': default: {$format = array(595.28,841.89); break;} case 'A5': {$format = array(419.53,595.28); break;} case 'A6': {$format = array(297.64,419.53); break;} case 'A7': {$format = array(209.76,297.64); break;} case 'A8': {$format = array(147.40,209.76); break;} case 'A9': {$format = array(104.88,147.40); break;} case 'A10': {$format = array(73.70,104.88); break;} case 'B0': {$format = array(2834.65,4008.19); break;} case 'B1': {$format = array(2004.09,2834.65); break;} case 'B2': {$format = array(1417.32,2004.09); break;} case 'B3': {$format = array(1000.63,1417.32); break;} case 'B4': {$format = array(708.66,1000.63); break;} case 'B5': {$format = array(498.90,708.66); break;} case 'B6': {$format = array(354.33,498.90); break;} case 'B7': {$format = array(249.45,354.33); break;} case 'B8': {$format = array(175.75,249.45); break;} case 'B9': {$format = array(124.72,175.75); break;} case 'B10': {$format = array(87.87,124.72); break;} case 'C0': {$format = array(2599.37,3676.54); break;} case 'C1': {$format = array(1836.85,2599.37); break;} case 'C2': {$format = array(1298.27,1836.85); break;} case 'C3': {$format = array(918.43,1298.27); break;} case 'C4': {$format = array(649.13,918.43); break;} case 'C5': {$format = array(459.21,649.13); break;} case 'C6': {$format = array(323.15,459.21); break;} case 'C7': {$format = array(229.61,323.15); break;} case 'C8': {$format = array(161.57,229.61); break;} case 'C9': {$format = array(113.39,161.57); break;} case 'C10': {$format = array(79.37,113.39); break;} case 'RA0': {$format = array(2437.80,3458.27); break;} case 'RA1': {$format = array(1729.13,2437.80); break;} case 'RA2': {$format = array(1218.90,1729.13); break;} case 'RA3': {$format = array(864.57,1218.90); break;} case 'RA4': {$format = array(609.45,864.57); break;} case 'SRA0': {$format = array(2551.18,3628.35); break;} case 'SRA1': {$format = array(1814.17,2551.18); break;} case 'SRA2': {$format = array(1275.59,1814.17); break;} case 'SRA3': {$format = array(907.09,1275.59); break;} case 'SRA4': {$format = array(637.80,907.09); break;} case 'LETTER': {$format = array(612.00,792.00); break;} case 'LEGAL': {$format = array(612.00,1008.00); break;} case 'EXECUTIVE': {$format = array(521.86,756.00); break;} case 'FOLIO': {$format = array(612.00,936.00); break;} // default: {$this->Error('Unknown page format: '.$format); break;} } $this->fwPt=$format[0]; $this->fhPt=$format[1]; } else { $this->fwPt=$format[0]*$this->k; $this->fhPt=$format[1]*$this->k; } $this->fw=$this->fwPt/$this->k; $this->fh=$this->fhPt/$this->k; //Page orientation $orientation=strtolower($orientation); if($orientation=='p' or $orientation=='portrait') { $this->DefOrientation='P'; $this->wPt=$this->fwPt; $this->hPt=$this->fhPt; } elseif($orientation=='l' or $orientation=='landscape') { $this->DefOrientation='L'; $this->wPt=$this->fhPt; $this->hPt=$this->fwPt; } else { $this->Error('Incorrect orientation: '.$orientation); } $this->CurOrientation=$this->DefOrientation; $this->w=$this->wPt/$this->k; $this->h=$this->hPt/$this->k; //Page margins (1 cm) $margin=28.35/$this->k; $this->SetMargins($margin,$margin); //Interior cell margin (1 mm) $this->cMargin=$margin/10; //Line width (0.2 mm) $this->LineWidth=.567/$this->k; //Automatic page break $this->SetAutoPageBreak(true,2*$margin); //Full width display mode $this->SetDisplayMode('fullwidth'); //Compression $this->SetCompression(true); //Set default PDF version number $this->PDFVersion = "1.5"; $this->encoding = $encoding; $this->b = 0; $this->i = 0; $this->u = 0; $this->HREF = ''; $this->fontlist = array("arial", "times", "courier", "helvetica", "symbol"); $this->issetfont = false; $this->issetcolor = false; $this->tableborder = 0; $this->tdbegin = false; $this->tdwidth= 0; $this->tdheight = 0; if($this->rtl) { $this->tdalign = "R"; } else { $this->tdalign = "L"; } $this->tdbgcolor = false; $this->SetFillColor(200, 200, 200, true); $this->SetTextColor(0, 0, 0, true); } /** * Default destructor. * @since 1.53.0.TC016 */ public function __destruct() { // restore internal encoding if (isset($this->internal_encoding) AND !empty($this->internal_encoding)) { mb_internal_encoding($this->internal_encoding); } } /** * Enable or disable Right-To-Left language mode * @param Boolean $enable if true enable Right-To-Left language mode. * @since 2.0.000 (2008-01-03) */ public function setRTL($enable) { $this->rtl = $enable ? true : false; $this->tmprtl = false; } /** * Force temporary RTL language direction * @param mixed $mode can be false, 'L' for LTR or 'R' for RTL * @since 2.1.000 (2008-01-09) */ public function setTempRTL($mode) { switch ($mode) { case false: case 'L': case 'R': { $this->tmprtl = $mode; } } } /** * Set the last cell height. * @param float $h cell height. * @author Nicola Asuni * @since 1.53.0.TC034 */ public function setLastH($h) { $this->lasth=$h; } /** * Set the image scale. * @param float $scale image scale. * @author Nicola Asuni * @since 1.5.2 */ public function setImageScale($scale) { $this->imgscale=$scale; } /** * Returns the image scale. * @return float image scale. * @author Nicola Asuni * @since 1.5.2 */ public function getImageScale() { return $this->imgscale; } /** * Returns the page width in units. * @return int page width. * @author Nicola Asuni * @since 1.5.2 */ public function getPageWidth() { return $this->w; } /** * Returns the page height in units. * @return int page height. * @author Nicola Asuni * @since 1.5.2 */ public function getPageHeight() { return $this->h; } /** * Returns the page break margin. * @return int page break margin. * @author Nicola Asuni * @since 1.5.2 */ public function getBreakMargin() { return $this->bMargin; } /** * Returns the scale factor (number of points in user unit). * @return int scale factor. * @author Nicola Asuni * @since 1.5.2 */ public function getScaleFactor() { return $this->k; } /** * Defines the left, top and right margins. By default, they equal 1 cm. Call this method to change them. * @param float $left Left margin. * @param float $top Top margin. * @param float $right Right margin. Default value is the left one. * @since 1.0 * @see SetLeftMargin(), SetTopMargin(), SetRightMargin(), SetAutoPageBreak() */ public function SetMargins($left, $top, $right=-1) { //Set left, top and right margins $this->lMargin=$left; $this->tMargin=$top; if($right==-1) { $right=$left; } $this->rMargin=$right; } /** * Defines the left margin. The method can be called before creating the first page. If the current abscissa gets out of page, it is brought back to the margin. * @param float $margin The margin. * @since 1.4 * @see SetTopMargin(), SetRightMargin(), SetAutoPageBreak(), SetMargins() */ public function SetLeftMargin($margin) { //Set left margin $this->lMargin=$margin; if(($this->page > 0) AND ($this->x < $margin)) { $this->x = $margin; } } /** * Defines the top margin. The method can be called before creating the first page. * @param float $margin The margin. * @since 1.5 * @see SetLeftMargin(), SetRightMargin(), SetAutoPageBreak(), SetMargins() */ public function SetTopMargin($margin) { //Set top margin $this->tMargin=$margin; if(($this->page > 0) AND ($this->y < $margin)) { $this->y = $margin; } } /** * Defines the right margin. The method can be called before creating the first page. * @param float $margin The margin. * @since 1.5 * @see SetLeftMargin(), SetTopMargin(), SetAutoPageBreak(), SetMargins() */ public function SetRightMargin($margin) { $this->rMargin=$margin; if(($this->page > 0) AND ($this->x > ($this->w - $margin))) { $this->x = $this->w - $margin; } } /** * Set the internal Cell padding. * @param float $pad internal padding. * @since 2.1.000 (2008-01-09) * @see Cell(), SetLeftMargin(), SetTopMargin(), SetAutoPageBreak(), SetMargins() */ public function SetCellPadding($pad) { $this->cMargin=$pad; } /** * Enables or disables the automatic page breaking mode. When enabling, the second parameter is the distance from the bottom of the page that defines the triggering limit. By default, the mode is on and the margin is 2 cm. * @param boolean $auto Boolean indicating if mode should be on or off. * @param float $margin Distance from the bottom of the page. * @since 1.0 * @see Cell(), MultiCell(), AcceptPageBreak() */ public function SetAutoPageBreak($auto, $margin=0) { //Set auto page break mode and triggering margin $this->AutoPageBreak = $auto; $this->bMargin = $margin; $this->PageBreakTrigger = $this->h - $margin; } /** * Defines the way the document is to be displayed by the viewer. The zoom level can be set: pages can be displayed entirely on screen, occupy the full width of the window, use real size, be scaled by a specific zooming factor or use viewer default (configured in the Preferences menu of Acrobat). The page layout can be specified too: single at once, continuous display, two columns or viewer default. By default, documents use the full width mode with continuous display. * @param mixed $zoom The zoom to use. It can be one of the following string values or a number indicating the zooming factor to use. <ul><li>fullpage: displays the entire page on screen </li><li>fullwidth: uses maximum width of window</li><li>real: uses real size (equivalent to 100% zoom)</li><li>default: uses viewer default mode</li></ul> * @param string $layout The page layout. Possible values are:<ul><li>single: displays one page at once</li><li>continuous: displays pages continuously (default)</li><li>two: displays two pages on two columns</li><li>default: uses viewer default mode</li></ul> * @since 1.2 */ public function SetDisplayMode($zoom, $layout='continuous') { //Set display mode in viewer if($zoom=='fullpage' or $zoom=='fullwidth' or $zoom=='real' or $zoom=='default' or !is_string($zoom)) { $this->ZoomMode=$zoom; } else { $this->Error('Incorrect zoom display mode: '.$zoom); } if($layout=='single' or $layout=='continuous' or $layout=='two' or $layout=='default') { $this->LayoutMode=$layout; } else { $this->Error('Incorrect layout display mode: '.$layout); } } /** * Activates or deactivates page compression. When activated, the internal representation of each page is compressed, which leads to a compression ratio of about 2 for the resulting document. Compression is on by default. * Note: the Zlib extension is required for this feature. If not present, compression will be turned off. * @param boolean $compress Boolean indicating if compression must be enabled. * @since 1.4 */ public function SetCompression($compress) { //Set page compression if(function_exists('gzcompress')) { $this->compress=$compress; } else { $this->compress=false; } } /** * Defines the title of the document. * @param string $title The title. * @since 1.2 * @see SetAuthor(), SetCreator(), SetKeywords(), SetSubject() */ public function SetTitle($title) { //Title of document $this->title=$title; } /** * Defines the subject of the document. * @param string $subject The subject. * @since 1.2 * @see SetAuthor(), SetCreator(), SetKeywords(), SetTitle() */ public function SetSubject($subject) { //Subject of document $this->subject=$subject; } /** * Defines the author of the document. * @param string $author The name of the author. * @since 1.2 * @see SetCreator(), SetKeywords(), SetSubject(), SetTitle() */ public function SetAuthor($author) { //Author of document $this->author=$author; } /** * Associates keywords with the document, generally in the form 'keyword1 keyword2 ...'.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -