本文整理汇总了PHP中TCPDF类的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF类的具体用法?PHP TCPDF怎么用?PHP TCPDF使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TCPDF类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output
/**
* Generates Pdf from html
*
* @return string raw pdf data
*/
public function output()
{
//TCPDF often produces a whole bunch of errors, although there is a pdf created when debug = 0
//Configure::write('debug', 0);
$TCPDF = new \TCPDF($this->_Pdf->orientation(), 'mm', $this->_Pdf->pageSize());
$TCPDF->AddPage();
$TCPDF->writeHTML($this->_Pdf->html());
return $TCPDF->Output('', 'S');
}
示例2: __construct
function __construct()
{
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$this->pdf = $pdf;
$this->widths = new stdClass();
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetAutoPageBreak(false);
$pdf->AddPage();
}
示例3: loadPdf
function loadPdf($article_id)
{
$this->load->library('pdf');
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// Add a page
$pdf->AddPage();
// $html = '<div class="col-lg-12"> <h1 class="page-header">News</h1></div>';
//$data['article'] = $this->articles->get_article($article_id);
//$html= $this->load->view('output_pdf', $data);
$data = $this->articles->get_article($article_id);
$html = '<body style="height: 100%;margin-bottom: 30px;"><div style="height: 30px;">News<br/>Title:' . $data['title'] . '</div><div id="content"><center><img src="./././images/' . $data['photo'] . '"' . 'width="100" height="150" align="center"></center><br/>' . $data['text'] . '[</div><div style="height: 30px;position: absolute;
bottom: 0;">[Author Name]:' . $data['user_name'] . '- [TimeStamp]:' . $data['curr_time'] . '</div>';
$pdf->writeHTML($html, true, false, true, false, '');
ob_clean();
$pdf->Output('news_001.pdf', 'I');
}
示例4: getPageContentHeight
/**
* Returns the usable page height, which is the page height without top and bottom margin.
*
* @param \TCPDF $pdf
* @param int $page
* @return float
*/
public static function getPageContentHeight(\TCPDF $pdf, $page)
{
// get total height of the page in user units
$totalHeight = $pdf->getPageHeight($page) / $pdf->getScaleFactor();
$margin = $pdf->getMargins();
return $totalHeight - $margin['bottom'] - $margin['top'];
}
示例5: __construct
public function __construct(TCPDF $pdf, $title, $slogan, $name, $details)
{
$pdf->SetTextColor(255, 255, 255);
$pdf->SetFont('league-gothic', '', 100, '', true);
$pdf->writeHTMLCell(200, 200, 18, 35, $this->buildHTML('h1', $title), 0, 1, 0);
$pdf->SetFont('league-gothic', '', 70, '', true);
$pdf->writeHTMLCell(80, 200, 130, 135, $this->buildHTML('p', $slogan, 80), 0, 1, 0);
$pdf->SetFont('AlegreyaSans-ExtraBold', '', 25, '', true);
$pdf->writeHTMLCell(120, 100, 18, 241, $this->buildHTML('h2', $name, 30), 0, 1, 0);
$pdf->SetFont('AlegreyaSans-Regular', '', 16, '', true);
$pdf->writeHTMLCell(175, 100, 18, 254, $this->buildHTML('p', $details, 20), 0, 1, 0);
}
示例6: save
/**
* Save PHPExcel to file
*
* @param string $pFilename Name of the file to save as
* @throws PHPExcel_Writer_Exception
*/
public function save($pFilename = null)
{
$fileHandle = parent::prepareForSave($pFilename);
// Default PDF paper size
$paperSize = 'LETTER';
// Letter (8.5 in. by 11 in.)
// Check for paper size and page orientation
if (is_null($this->getSheetIndex())) {
$orientation = $this->_phpExcel->getSheet(0)->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet(0)->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet(0)->getPageMargins();
} else {
$orientation = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P';
$printPaperSize = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageSetup()->getPaperSize();
$printMargins = $this->_phpExcel->getSheet($this->getSheetIndex())->getPageMargins();
}
// Override Page Orientation
if (!is_null($this->getOrientation())) {
$orientation = $this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_LANDSCAPE ? 'L' : 'P';
}
// Override Paper Size
if (!is_null($this->getPaperSize())) {
$printPaperSize = $this->getPaperSize();
}
if (isset(self::$paperSizes[$printPaperSize])) {
$paperSize = self::$paperSizes[$printPaperSize];
}
// Create PDF
$pdf = new TCPDF($orientation, 'pt', $paperSize);
$pdf->setFontSubsetting(false);
// Set margins, converting inches to points (using 72 dpi)
$pdf->SetMargins($printMargins->getLeft() * 72, $printMargins->getTop() * 72, $printMargins->getRight() * 72);
$pdf->SetAutoPageBreak(true, $printMargins->getBottom() * 72);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->AddPage();
// Set the appropriate font
$pdf->SetFont($this->getFont());
$pdf->writeHTML($this->generateHTMLHeader(false) . $this->generateSheetData() . $this->generateHTMLFooter());
// Document info
$pdf->SetTitle($this->_phpExcel->getProperties()->getTitle());
$pdf->SetAuthor($this->_phpExcel->getProperties()->getCreator());
$pdf->SetSubject($this->_phpExcel->getProperties()->getSubject());
$pdf->SetKeywords($this->_phpExcel->getProperties()->getKeywords());
$pdf->SetCreator($this->_phpExcel->getProperties()->getCreator());
// Write to file
fwrite($fileHandle, $pdf->output($pFilename, 'S'));
parent::restoreStateAfterSave($fileHandle);
}
示例7: download
public function download($id)
{
$book = Book::with(array('chapter' => function ($query) {
$query->orderBy('order', 'asc');
}, 'chapter.element' => function ($query) {
$query->orderBy('order', 'asc');
}))->where("id", "=", $id)->get();
$view = View::make('pdf/result', array("book" => $book));
$pdf = new TCPDF();
$pdf->AddPage();
$pdf->writeHTML($view, true, false, true, false, '');
$filename = public_path() . '/pdf/test.pdf';
$pdf->output($filename, 'F');
return Response::download($filename);
}
示例8: __construct
/**
* Initialize
*
*/
function __construct($params = array())
{
$orientation = 'P';
$unit = 'mm';
$format = 'A4';
$unicode = true;
$encoding = 'UTF-8';
$diskcache = false;
if (isset($params['orientation'])) {
$orientation = $params['orientation'];
}
if (isset($params['unit'])) {
$unit = $params['unit'];
}
if (isset($params['format'])) {
$format = $params['format'];
}
if (isset($params['encoding'])) {
$encoding = $params['encoding'];
}
if (isset($params['diskcache'])) {
$diskcache = $params['diskcache'];
}
# initialize TCPDF
parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache);
}
示例9: initPdf
/**
* initPdf - initialize TCPDF with current setting
*
* @return void
*/
private function initPdf()
{
if (empty($this->pdfEngine)) {
$this->pdfEngine = new TCPDF($this->pageOrientation, $this->unit, $this->pageSize, true, 'UTF-8', false);
if (isset($this->pdfAuthor)) {
$this->pdfEngine->SetAuthor($this->pdfAuthor);
}
if (isset($this->pdfTitle)) {
$this->pdfEngine->SetTitle($this->pdfTitle);
}
if (isset($this->pdfSubject)) {
$this->pdfEngine->SetSubject($this->pdfSubject);
}
if (isset($this->pdfKeywords)) {
$keywords = is_array($this->pdfKeywords) ? implode(', ', $this->pdfKeywords) : (string) $this->pdfKeywords;
$this->pdfEngine->SetKeywords($keywords);
}
if (!empty($this->pdfCreator)) {
$this->pdfEngine->SetCreator($this->pdfCreator);
}
if (!empty($this->fontFamily)) {
$this->pdfEngine->SetFont($this->fontFamily, $this->fontStyle, $this->fontSize);
}
if (!empty($this->monoFontFamily)) {
$this->pdfEngine->SetDefaultMonospacedFont($this->monoFontFamily);
}
if (!empty($this->leftMargin)) {
$this->pdfEngine->SetMargins($this->leftMargin, $this->topMargin, $this->rightMargin);
}
if (empty($this->bottomMargin)) {
$this->bottomMargin = PDF_MARGIN_BOTTOM;
}
$this->pdfEngine->SetAutoPageBreak(true, $this->bottomMargin);
}
}
示例10: Footer
public function Footer()
{
$txt = '';
if ($this->footer_param['form']) {
$txt = HTML2PDF::textGET('pdf05');
}
if ($this->footer_param['date'] && $this->footer_param['heure']) {
$txt .= ($txt ? ' - ' : '') . HTML2PDF::textGET('pdf03');
}
if ($this->footer_param['date'] && !$this->footer_param['heure']) {
$txt .= ($txt ? ' - ' : '') . HTML2PDF::textGET('pdf01');
}
if (!$this->footer_param['date'] && $this->footer_param['heure']) {
$txt .= ($txt ? ' - ' : '') . HTML2PDF::textGET('pdf02');
}
if ($this->footer_param['page']) {
$txt .= ($txt ? ' - ' : '') . HTML2PDF::textGET('pdf04');
}
if (strlen($txt) > 0) {
$txt = str_replace('[[date_d]]', date('d'), $txt);
$txt = str_replace('[[date_m]]', date('m'), $txt);
$txt = str_replace('[[date_y]]', date('Y'), $txt);
$txt = str_replace('[[date_h]]', date('H'), $txt);
$txt = str_replace('[[date_i]]', date('i'), $txt);
$txt = str_replace('[[date_s]]', date('s'), $txt);
$txt = str_replace('[[current]]', $this->PageNo(), $txt);
$txt = str_replace('[[nb]]', '{nb}', $txt);
parent::SetY(-11);
$this->setOverline(false);
$this->SetFont('helvetica', 'I', 8);
$this->Cell(0, 10, $txt, 0, 0, 'R');
}
}
示例11: Rotate
private function Rotate($type, $x = -1, $y = -1)
{
if ($type == "") {
$angle = 0;
} elseif ($type == "Left") {
$angle = 90;
} elseif ($type == "Right") {
$angle = 270;
} elseif ($type == "UpsideDown") {
$angle = 180;
}
if ($x == -1) {
$x = $this->pdf->getX();
}
if ($y == -1) {
$y = $this->pdf->getY();
}
if ($this->angle != 0) {
$this->pdf->_out('Q');
}
$this->angle = $angle;
if ($angle != 0) {
$angle *= M_PI / 180;
$c = cos($angle);
$s = sin($angle);
$cx = $x * $this->pdf->k;
$cy = ($this->pdf->h - $y) * $this->pdf->k;
$this->pdf->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm', $c, $s, -$s, $c, $cx, $cy, -$cx, -$cy));
}
}
示例12: Footer
public function Footer()
{
$this->SetFont('helvetica', '', 10);
parent::Footer();
$this->Cell(0, 5, "", 0, 1, 'L', 0, '', 0, false, 'M', 'M');
$this->Cell(0, 8, "Report generated with Open-LIMS (" . date("dS M Y H:i") . ")", 0, 1, 'L', 0, '', 0, false, 'M', 'M');
}
示例13: Footer
public function Footer()
{
if (defined('WPPTOPDFENH_CUSTOM_FOOTER')) {
$this->writeHTMLCell(WPPTOPDFENH_FOOTER_WIDTH, WPPTOPDFENH_FOOTER_MIN_HEIGHT, WPPTOPDFENH_FOOTER_X, WPPTOPDFENH_FOOTER_Y, WPPTOPDFENH_CUSTOM_FOOTER, WPPTOPDFENH_FOOTER_BORDER, 0, WPPTOPDFENH_FOOTER_FILL, true, WPPTOPDFENH_FOOTER_ALIGN, WPPTOPDFENH_FOOTER_PAD);
} else {
// call parent footer method for default footer
parent::Footer();
}
}
示例14:
/**
* Draws a filled rectangle at x1,y1 with width w and height h
*
* See {@link Style::munge_color()} for the format of the color array.
*
* @param float $x1
* @param float $y1
* @param float $w
* @param float $h
* @param array $color
*/
function filled_rectangle($x1, $y1, $w, $h, $color) {
$this->_set_fill_color($color);
// FIXME: ugh, need to handle styles here
$this->_pdf->rect($x1, $y1, $w, $h, "F");
}
示例15: _getLastAbsoluteY
/**
* get the last absolute Y
*
* @access protected
* @return float $y
*/
protected function _getLastAbsoluteY()
{
for ($k = count($this->table) - 1; $k >= 0; $k--) {
if ($this->table[$k]['y'] && $this->table[$k]['position']) return $this->table[$k]['y'];
}
return $this->_pdf->gettMargin();
}