本文整理汇总了PHP中TCPDF::setPrintHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF::setPrintHeader方法的具体用法?PHP TCPDF::setPrintHeader怎么用?PHP TCPDF::setPrintHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF
的用法示例。
在下文中一共展示了TCPDF::setPrintHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: TCPDF
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();
}
示例2: run
public function run()
{
include getcwd() . '/vendor/autoload.php';
$navStructure = (include getcwd() . '/docs/navigation.php');
echo "Loading markdown...\n";
$markdown = $this->findMarkdown($navStructure);
echo "Converting markdown to html...\n";
$Parsedown = new \Parsedown();
$html = $Parsedown->text($markdown);
$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
#$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('My Documentation');
#$pdf->SetSubject('TCPDF Tutorial');
#$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetFont('helvetica', '', 20);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->AddPage();
$pdf->writeHTML($html, true, 0, true, 0);
$pdf->lastPage();
echo "Writing PDF...\n";
$pdf->Output($this->config['output'], 'F');
echo "Complete.\n";
}
示例3: pdf
/**
* @param string $html 要转为pdf的内容
* @param string $filename 文件名
* @param string $type 'I'在页面中显示;'D'直接下载
*/
public static function pdf($html, $filename = 'hzd.pdf', $type = 'I')
{
import("Tools.TCPDF.TCPDF");
import("Tools.TCPDF.config.tcpdf_config.php");
$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('HZD');
$pdf->SetTitle('HZD');
$pdf->SetSubject('HZD');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->setPrintHeader(false);
//不显示头部
$pdf->setPrintFooter(false);
//不显示底部
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// ---------------------------------------------------------
// set font
$pdf->SetFont('stsongstdlight', '', 20);
// add a page
$pdf->AddPage();
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output($filename, $type);
}
示例4: convertHtmlToPdf
function convertHtmlToPdf($html)
{
if (!$html) {
throw new \Exception("Html Not Given");
}
$pagelayout = array($this->options['width'], $this->options['height']);
// or array($width,$height)
$pdf = new \TCPDF('l', 'px', $pagelayout, true, 'UTF-8', false);
$pdf->SetMargins(0, 0, 0);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(0);
// $pdf = new \TCPDF_TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetAutoPageBreak(false);
if ($this->options['header_font_family']) {
$pdf->SetFont($this->options['header_font_family']);
}
// add a page
$pdf->AddPage();
$pdf->WriteHTML($html, true, false, true, false);
$this->pdf = $pdf->Output(null, 'S');
//for test
// $this->pdf = $pdf->Output(null);
// echo $this->pdf;
// exit;
}
示例5: renderRfqRequest
/**
* Render a PDF file and show in browser or save to disk
* If save to disk return file location
*/
public function renderRfqRequest($quote, $saveToDisk = false)
{
$storeid = $quote->getStoreId();
if ($storeid) {
$appEmulation = Mage::getSingleton('core/app_emulation');
$initial = $appEmulation->startEnvironmentEmulation($storeid, Mage_Core_Model_App_Area::AREA_FRONTEND, true);
}
$pdf = new TCPDF();
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->AddPage();
$pdf->SetAutoPageBreak(true, 30);
$pdf->setHeaderMargin(20);
$pdf->setFooterMargin(20);
$pdf->setImageScale(1.5);
$emailtext = Mage::helper('request4quote/email')->sendRequestProposalNotification($quote, false, true);
$pdf->writeHTML(Mage::helper('cms')->getBlockTemplateProcessor()->filter($emailtext), false);
$pdf->endPage();
if ($storeid) {
$appEmulation->stopEnvironmentEmulation($initial);
}
$rfqfilename = 'rfq_' . $quote->getId() . '.pdf';
if (!$saveToDisk) {
return $pdf->Output($rfqfilename);
} else {
if ($saveToDisk) {
$filePath = $this->getFilePath() . $rfqfilename;
$pdf->Output($filePath, 'F');
return $filePath;
}
}
exit;
}
示例6: processing
function processing($contextData, $options)
{
$prodId = $contextData[0]['id'];
$prodName = $contextData[0]['name'];
$unitPrice = $contextData[0]['unitprice'];
$pFile = $contextData[0]['photofile'];
$timestamp = new DateTime();
$tsString = $timestamp->format("Y-m-d H:i:s");
$fileName = "{$prodId}.pdf";
require_once './tcpdf/tcpdf.php';
$pdf = new TCPDF("P", "mm", "A4", true, "UTF-8");
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetMargins(0, 0, 0, 0);
$pdf->AddPage();
$pdf->setTextColor(100, 100, 100);
$pdf->SetFont('', '', 14);
$pdf->Text(40, 40, "Product ID: {$prodId}");
$pdf->Text(40, 50, "Product Name: {$prodName}");
$pdf->Text(40, 60, "Unit Price: {$unitPrice}");
$pdf->Text(40, 70, "Today: {$tsString}");
$pdf->Image("../Sample_products/images/{$pFile}", 40, 80, 100);
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=\"{$fileName}\"");
header('X-Frame-Options: SAMEORIGIN');
$pdf->Output();
}
示例7: indexAction
public function indexAction(Request $request, SessionInterface $session)
{
Util::checkUserIsLoggedInAndRedirect();
$loggedInUserId = $session->get('user/id');
$pageId = $request->get('id');
$page = $this->getRepository(Entity::class)->getById($pageId, $loggedInUserId);
// create new PDF document
$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->setPrintHeader(false);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// ---------------------------------------------------------
// set font
$pdf->SetFont('dejavusans', '', 10);
// add a page
$pdf->AddPage();
$html = $page['content'];
$pdf->writeHTML($html, true, false, true, false, '');
// Close and output PDF document
$pdf->Output('./../../' . $page['name'] . '.pdf', 'D');
}
示例8: __construct
/**
* 初始化
*
* @access public
* @param array $params 初始化参数
* @return void
*/
public function __construct($params)
{
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor($this->pdf_author);
$pdf->SetTitle($this->pdf_title);
$pdf->SetSubject($this->pdf_subject);
$pdf->SetKeywords($this->pdf_keywords);
// 不显示头部和底部
$pdf->setPrintHeader(FALSE);
$pdf->setPrintFooter(FALSE);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
//set some language-dependent strings
require TCPDF_BASE_PATH . 'tcpdf/config/lang/eng.php';
$pdf->setLanguageArray($l);
// set font
$pdf->SetFont('stsongstdlight', '', 10);
$pdf->AddPage();
$pdf->writeHTML($params['content'], true, false, true, false, '');
$pdf->lastPage();
// 输出方式 I:浏览器直接输出 D:文件下载 如果需要浏览器输出或者下载的同时生成文件请在前面加上F
$pdf->Output($params['filename'], $params['flag']);
}
示例9: list
/**
* Class constructor
*
* @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or
* an array(xmin,ymin,xmax,ymax)
* @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
* @param DOMPDF $dompdf
*/
function __construct($paper = "letter", $orientation = "portrait", DOMPDF $dompdf)
{
//***
if (is_array($paper)) {
$size = $paper;
} else {
if (isset(self::$PAPER_SIZES[mb_strtolower($paper)])) {
$size = self::$PAPER_SIZES[mb_strtolower($paper)];
} else {
$size = self::$PAPER_SIZES["letter"];
}
}
$ori = 'P';
// ***
if (mb_strtolower($orientation) === "landscape") {
list($size[2], $size[3]) = array($size[3], $size[2]);
$ori = 'L';
// ***
}
$this->_width = $size[2] - $size[0];
$this->_height = $size[3] - $size[1];
$this->_dompdf = $dompdf;
//***$this->_pdf = new My_TCPDF('P', 'pt', $paper, true, 'UTF-8', false);
$this->_pdf = new My_TCPDF($ori, 'pt', $paper, true, 'UTF-8', false);
// ***
$this->_pdf->SetCreator("DOMPDF Converter");
// CreationDate and ModDate info are added by TCPDF itself
// don't use TCPDF page defaults
$this->_pdf->SetAutoPageBreak(false);
$this->_pdf->SetMargins(0, 0, 0, true);
$this->_pdf->setPrintHeader(false);
// remove default header/footer
$this->_pdf->setPrintFooter(false);
$this->_pdf->setHeaderMargin(0);
$this->_pdf->setFooterMargin(0);
$this->_pdf->SetCellPadding(0);
$this->_pdf->AddPage();
$this->_pdf->SetDisplayMode('fullpage', 'continuous');
$this->_page_number = $this->_page_count = 1;
$this->_page_text = array();
$this->_pages = array($this->_pdf->PageNo());
$this->_image_cache = array();
// other TCPDF stuff...
$this->_objs = array();
// for templating support
$this->_nameddest = array();
// for internal link support
$this->_internal_links = array();
// " " "
$this->_pdf->setAlpha(1.0);
$this->_currentLineTransparency = array("mode" => "Normal", "opacity" => 1.0);
$this->_currentFillTransparency = array("mode" => "Normal", "opacity" => 1.0);
$this->_last_fill_color = $this->_last_stroke_color = null;
//dompdf_debug("trace", "Exit");
}
示例10: getPdfData
private function getPdfData()
{
$pdf = new \TCPDF();
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetFont('times', 'BI', 12);
$pdf->AddPage();
$pdf->Write(0, 'Fichier pdf', '', 0, 'C', true, 0, false, false, 0);
return $pdf->Output('fichier.pdf', 'S');
}
示例11: Adresaro
function Adresaro()
{
$pdf = new TCPDF();
$tiparo = "freesans";
$pdf->AddFont($tiparo, '', $tiparo . ".php");
$pdf->AddFont($tiparo, 'B', $tiparo . "b.php");
$pdf->setFont($tiparo);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->setAutoPageBreak(false);
$pdf->Open();
$this->pdf =& $pdf;
}
示例12: 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);
}
示例13: orderViewPDF
function orderViewPDF()
{
$l = null;
require_once OSEMSC_F_PATH . DS . 'libraries' . DS . 'tcpdf' . DS . 'tcpdf.php';
require_once OSEMSC_F_PATH . DS . 'libraries' . DS . 'tcpdf' . DS . 'config' . DS . 'lang' . DS . 'eng.php';
$order_id = JRequest::getInt('order_id', 0);
//$my = JFactory::getUser();
$member_id = JRequest::getInt('member_id', 0);
$where = array();
$where[] = " `order_id` = {$order_id}";
$where[] = " `user_id` = {$member_id}";
$orderInfo = oseRegistry::call('payment')->getOrder($where, 'obj');
if (empty($orderInfo)) {
$result = array();
$result['title'] = 'Error';
$result['content'] = 'Error';
oseExit('Error');
}
$receipt = oseRegistry::call('member')->getReceipt($orderInfo);
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('OSEMSC');
$pdf->SetTitle('Invoice #' . $order_id);
$pdf->SetSubject('Invoice');
$pdf->SetKeywords('invoice');
// set default header data
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->SetMargins(30, 18, 30);
//set some language-dependent strings
$pdf->setLanguageArray($l);
$pdf->SetAutoPageBreak(TRUE, 10);
$pdf->AddPage();
//ob_get_clean();
$pdf->WriteHTML($receipt->body, true);
$pdf->Output("Invoice-#{$order_id}.pdf", "I");
oseExit();
/*
//$receipt = self::orderView();
$order_id = JRequest::getInt('order_id');
$app = JFactory::getApplication('SITE');
//oseExit('dfdf');
$app->redirect( JRoute::_('index.php?option=com_osemsc&view=member&format=pdf&memberTask=generateOrderView&order_id='.$order_id));
*/
}
示例14: __construct
public function __construct()
{
// $orientation='P', $unit='mm', $format='A4', $unicode=true, $encoding='UTF-8', $diskcache=false, $pdfa=false
$pdf = new \TCPDF('P', 'mm', 'A4', true, 'UTF-8', false);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetDefaultMonospacedFont('courier');
$pdf->SetMargins(10, 10, 7, true);
$pdf->SetAutoPageBreak(true, 5);
$pdf->setImageScale(1);
$pdf->SetFont('freeserif', '', 12, '', false);
$pdf->SetLineWidth(0.05);
$this->pdf = $pdf;
$this->cell = new cell($this->pdf);
}
示例15: initializePdf
/**
*
* @param string $orientation P / L
* @param string $size paper size
* @param string $title document title
* @return \TCPDF model
*/
public function initializePdf($orientation, $size, $title)
{
Yii::createComponent('ext.tcpdf.TcPdf', 'P', 'cm', 'A4', true, 'UTF-8');
spl_autoload_unregister(array('YiiBase', 'autoload'));
$pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
spl_autoload_register(array('YiiBase', 'autoload'));
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetTitle($title);
//no headers and footers
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
//automatically insert page break bottom
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->addPage($orientation, $size);
return $pdf;
}