⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcpdf.php

📁 简介:一个用PHP编写的
💻 PHP
📖 第 1 页 / 共 5 页
字号:
			//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.3";						$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;			$this->tdalign = "L";			$this->tdbgcolor = false;						$this->SetFillColor(200, 200, 200, true);			$this->SetTextColor(0, 0, 0, true);		}		/**		* Set the image scale.		* @param float $scale image scale.		* @author Nicola Asuni		* @since 1.5.2		*/		function setImageScale($scale) {			$this->imgscale=$scale;		}		/**		* Returns the image scale.		* @return float image scale.		* @author Nicola Asuni		* @since 1.5.2		*/		function getImageScale() {			return $this->imgscale;		}		/**		* Returns the page width in units.		* @return int page width.		* @author Nicola Asuni		* @since 1.5.2		*/		function getPageWidth() {			return $this->w;		}		/**		* Returns the page height in units.		* @return int page height.		* @author Nicola Asuni		* @since 1.5.2		*/		function getPageHeight() {			return $this->h;		}		/**		* Returns the page break margin.		* @return int page break margin.		* @author Nicola Asuni		* @since 1.5.2		*/		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		*/		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()		*/		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()		*/		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()		*/		function SetTopMargin($margin) {			//Set top margin			$this->tMargin=$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()		*/		function SetRightMargin($margin) {			//Set right margin			$this->rMargin=$margin;		}		/**		* 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()		*/		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		*/		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		*/		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()		*/		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()		*/		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()		*/		function SetAuthor($author) {			//Author of document			$this->author=$author;		}		/**		* Associates keywords with the document, generally in the form 'keyword1 keyword2 ...'.		* @param string $keywords The list of keywords.		* @since 1.2		* @see SetAuthor(), SetCreator(), SetSubject(), SetTitle()		*/		function SetKeywords($keywords) {			//Keywords of document			$this->keywords=$keywords;		}		/**		* Defines the creator of the document. This is typically the name of the application that generates the PDF.		* @param string $creator The name of the creator.		* @since 1.2		* @see SetAuthor(), SetKeywords(), SetSubject(), SetTitle()		*/		function SetCreator($creator) {			//Creator of document			$this->creator=$creator;		}		/**		* Defines an alias for the total number of pages. It will be substituted as the document is closed.<br />		* <b>Example:</b><br />		* <pre>		* class PDF extends TCPDF {		* 	function Footer() {		* 		//Go to 1.5 cm from bottom		* 		$this->SetY(-15);		* 		//Select Arial italic 8		* 		$this->SetFont('Arial','I',8);		* 		//Print current and total page numbers		* 		$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');		* 	}		* }		* $pdf=new PDF();		* $pdf->AliasNbPages();		* </pre>		* @param string $alias The alias. Default value: {nb}.		* @since 1.4		* @see PageNo(), Footer()		*/		function AliasNbPages($alias='{nb}') {			//Define an alias for total number of pages			$this->AliasNbPages = $this->_escapetext($alias);		}		/**		* This method is automatically called in case of fatal error; it simply outputs the message and halts the execution. An inherited class may override it to customize the error handling but should always halt the script, or the resulting document would probably be invalid.		* 2004-06-11 :: Nicola Asuni : changed bold tag with strong		* @param string $msg The error message		* @since 1.0		*/		function Error($msg) {			//Fatal error			die('<strong>TCPDF error: </strong>'.$msg);		}		/**		* This method begins the generation of the PDF document. It is not necessary to call it explicitly because AddPage() does it automatically.		* Note: no page is created by this method		* @since 1.0		* @see AddPage(), Close()		*/		function Open() {			//Begin document			$this->state=1;		}		/**		* Terminates the PDF document. It is not necessary to call this method explicitly because Output() does it automatically. If the document contains no page, AddPage() is called to prevent from getting an invalid document.		* @since 1.0		* @see Open(), Output()		*/		function Close() {			//Terminate document			if($this->state==3) {				return;			}			if($this->page==0) {				$this->AddPage();			}			//Page footer			$this->InFooter=true;			$this->Footer();			$this->InFooter=false;			//Close page			$this->_endpage();			//Close document			$this->_enddoc();		}		/**		* Adds a new page to the document. If a page is already present, the Footer() method is called first to output the footer. Then the page is added, the current position set to the top-left corner according to the left and top margins, and Header() is called to display the header.		* The font which was set before calling is automatically restored. There is no need to call SetFont() again if you want to continue with the same font. The same is true for colors and line width.		* The origin of the coordinate system is at the top-left corner and increasing ordinates go downwards.		* @param string $orientation Page orientation. Possible values are (case insensitive):<ul><li>P or Portrait</li><li>L or Landscape</li></ul> The default value is the one passed to the constructor.		* @since 1.0		* @see TCPDF(), Header(), Footer(), SetMargins()		*/		function AddPage($orientation='') {			//Start a new page			if($this->state==0) {				$this->Open();			}			$family=$this->FontFamily;			$style=$this->FontStyle.($this->underline ? 'U' : '');			$size=$this->FontSizePt;			$lw=$this->LineWidth;			$dc=$this->DrawColor;			$fc=$this->FillColor;			$tc=$this->TextColor;			$cf=$this->ColorFlag;			if($this->page>0) {				//Page footer				$this->InFooter=true;				$this->Footer();				$this->InFooter=false;				//Close page				$this->_endpage();			}			//Start new page			$this->_beginpage($orientation);			//Set line cap style to square			$this->_out('2 J');			//Set line width			$this->LineWidth=$lw;			$this->_out(sprintf('%.2f w',$lw*$this->k));			//Set font			if($family) {				$this->SetFont($family,$style,$size);			}			//Set colors			$this->DrawColor=$dc;			if($dc!='0 G') {				$this->_out($dc);			}			$this->FillColor=$fc;			if($fc!='0 g') {				$this->_out($fc);			}			$this->TextColor=$tc;			$this->ColorFlag=$cf;			//Page header			$this->Header();			//Restore line width			if($this->LineWidth!=$lw) {				$this->LineWidth=$lw;				$this->_out(sprintf('%.2f w',$lw*$this->k));			}			//Restore font			if($family) {				$this->SetFont($family,$style,$size);			}			//Restore colors			if($this->DrawColor!=$dc) {				$this->DrawColor=$dc;				$this->_out($dc);			}			if($this->FillColor!=$fc) {				$this->FillColor=$fc;				$this->_out($fc);			}			$this->TextColor=$tc;			$this->ColorFlag=$cf;		}								/**	 	 * Set header data.		 * @param string $ln header image logo		 * @param string $lw header image logo width in mm		 * @param string $ht string to print as title on document header		 * @param string $hs string to print on document header		*/		function setHeaderData($ln="", $lw=0, $ht="", $hs="") {			$this->header_logo = $ln;			$this->header_logo_width = $lw;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -