本文整理汇总了PHP中TCPDF::writeHTML方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF::writeHTML方法的具体用法?PHP TCPDF::writeHTML怎么用?PHP TCPDF::writeHTML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF
的用法示例。
在下文中一共展示了TCPDF::writeHTML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PdfAction
public function PdfAction()
{
$pdf = new TCPDF('L');
$pdf->SetPrintHeader(true);
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$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 some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
require_once dirname(__FILE__) . '/lang/eng.php';
$pdf->setLanguageArray($l);
}
// set font
$pdf->SetFont('helvetica', '', 8);
// add a page
$pdf->AddPage();
//get report data into $data variable
$project = $this->getServiceLocator()->get('ProjectTable');
$data = $project->getWsr();
$view = new PhpRenderer();
$resolver = new TemplateMapResolver();
//set the path of the pdf.phtml file
$resolver->setMap(array('PDFTemplate' => '/var/www/html/WSRAutomation/module/Application/view/application/index/pdf.phtml'));
$view->setResolver($resolver);
$viewModel = new ViewModel();
$viewModel->setTemplate('PDFTemplate')->setVariables(array('projects' => $data, 'view' => 'pdf'));
$html = $view->render($viewModel);
$pdf->writeHTML($html, true, 0, true, 0);
$pdf->Output('WsrReport.pdf', 'I');
}
示例2: testPdfOutput
public function testPdfOutput()
{
$this->markTestIncomplete('Transparency rendering on signature not working.');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 052');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 052', PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// 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 some language-dependent strings (optional)
$pdf->setLanguageArray($this->langSettings);
// ---------------------------------------------------------
/*
NOTES:
- To create self-signed signature: openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout tcpdf.crt -out tcpdf.crt
- To export crt to p12: openssl pkcs12 -export -in tcpdf.crt -out tcpdf.p12
- To convert pfx certificate to pem: openssl pkcs12 -in tcpdf.pfx -out tcpdf.crt -nodes
*/
// set certificate file
$certificate = 'file://tests/data/cert/tcpdf.crt';
// set additional information
$info = array('Name' => 'TCPDF', 'Location' => 'Office', 'Reason' => 'Testing TCPDF', 'ContactInfo' => 'http://www.tcpdf.org');
// set document signature
$pdf->setSignature($certificate, $certificate, 'tcpdfdemo', '', 2, $info);
// set font
$pdf->SetFont('helvetica', '', 12);
// add a page
$pdf->AddPage();
// print a line of text
$text = 'This is a <b color="#FF0000">digitally signed document</b> using the default (example) <b>tcpdf.crt</b> certificate.<br />To validate this signature you have to load the <b color="#006600">tcpdf.fdf</b> on the Arobat Reader to add the certificate to <i>List of Trusted Identities</i>.<br /><br />For more information check the source code of this example and the source code documentation for the <i>setSignature()</i> method.<br /><br /><a href="http://www.tcpdf.org">www.tcpdf.org</a>';
$pdf->writeHTML($text, true, 0, true, 0);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// *** set signature appearance ***
// create content for signature (image and/or text)
$pdf->Image('tests/images/tcpdf_signature.png', 180, 60, 15, 15, 'PNG');
// define active area for signature appearance
$pdf->setSignatureAppearance(180, 60, 15, 15);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// *** set an empty signature appearance ***
$pdf->addEmptySignatureAppearance(180, 80, 15, 15);
$this->comparePdfs($pdf);
}
示例3: 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');
}
示例4: 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');
}
示例5: class_report_pdf
public function class_report_pdf()
{
$class_date = date('Y-m-d');
if ($this->input->get('class_date') != "") {
$class_date = $this->input->get('class_date');
}
if ($this->input->post('class_date') != "") {
$class_date = $this->input->post('class_date');
}
$this->load->model('class_report_model');
$this->load->model('check_in_model');
$check_ins = $this->class_report_model->check_ins_get($class_date);
$totals = $this->class_report_model->class_report_totals($class_date);
$incident_report = $this->class_report_model->incident_report_get($class_date);
$teacher_check_ins = $this->check_in_model->check_ins_teachers_get($class_date);
$classes = $this->check_in_model->classes_get();
// $data['main_content'] = 'class_report_view';
// $html = $this->load->view('reports/class_report_view', $data);
require 'application/views/reports/class_report_view.php';
// $html = '<style>'.file_get_contents('./css/bootstrap.min.css').'</style>';
// exit($html);
// $html = '<h1>Class Report</h1>';
$this->load->library('pdf');
// create new PDF document
$pdf = new TCPDF("P", PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Solid Rock');
$pdf->SetTitle('Class Report');
$pdf->SetSubject('Class Report');
$pdf->SetKeywords('Solid Rock, Kidz Rock');
//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);
// add a page
$pdf->AddPage();
// create some HTML content
// $html = '<h1>Class Report</h1>';
// output the HTML content
$pdf->writeHTML($html, true, false, true, false, '');
//Close and output PDF document
$pdf->Output('class_report.pdf', 'I');
}
示例6: getPDFFromArray
public function getPDFFromArray($array, $header = null)
{
$tbl = '<table>';
$tbl .= '<tr>';
foreach ($header as $h) {
$tbl .= '<th style="font-weight: bold;">' . $h . '</th>';
}
$tbl .= '</tr>';
foreach ($array as $row) {
$tbl .= '<tr>';
foreach ($row as $d) {
$tbl .= '<td>' . $d . '</td>';
}
$tbl .= '</tr>';
}
$tbl .= '</table>';
return $this->pdf->writeHTML($tbl, true, false, false, false, '');
}
示例7: testPdfOutput
public function testPdfOutput()
{
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 021');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE . ' 021', PDF_HEADER_STRING);
// set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// 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 some language-dependent strings (optional)
$pdf->setLanguageArray($this->langSettings);
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 9);
// add a page
$pdf->AddPage();
// create some HTML content
$html = '<h1>Example of HTML text flow</h1>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. <em>Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur?</em> <em>Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</em><br /><br /><b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i> -> <b>A</b> + <b>B</b> = <b>C</b> -> <i>C</i> - <i>B</i> = <i>A</i> -> <i>C</i> - <i>A</i> = <i>B</i><br /><br /><b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u> <b>Bold</b><i>Italic</i><u>Underlined</u>';
// output the HTML content
$pdf->writeHTML($html, true, 0, true, 0);
// reset pointer to the last page
$pdf->lastPage();
$this->comparePdfs($pdf);
}
示例8: create_pdf
function create_pdf($content, $title)
{
tcpdf();
$obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$obj_pdf->SetCreator(PDF_CREATOR);
$title = $title;
$obj_pdf->SetTitle('MultiTV analytics');
$obj_pdf->SetAuthor('MultiTv');
$obj_pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $title, PDF_HEADER_STRING);
$obj_pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$obj_pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$obj_pdf->SetDefaultMonospacedFont('helvetica');
$obj_pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$obj_pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$obj_pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$obj_pdf->SetFont('helvetica', '', 9);
$obj_pdf->setFontSubsetting(false);
$obj_pdf->AddPage();
//ob_start();
// we can have any view part here like HTML, PHP etc
//$content = ob_get_contents();
ob_end_clean();
$obj_pdf->writeHTML($content, true, false, true, false, '');
$obj_pdf->Output('output.pdf', 'I');
}
示例9: 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);
}
示例10: 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');
}
示例11: 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;
}
示例12: display
function display($tpl = null)
{
global $mainframe;
$app = JFactory::getApplication();
$params = $app->getParams();
$this->assignRef('params', $params);
$user = JFactory::getUser();
$username = $user->username;
$this->child = JFactory::getUser($username);
$layout = $params->get('layout');
$this->tasks = JoomdleHelperContent::call_method("get_children_grade_user_report", $username);
$tpl = "catspdf";
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$this->_prepareDocument();
$htmlcontent = parent::loadTemplate($tpl);
require_once JPATH_SITE . '/libraries/tcpdf/tcpdf.php';
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$header = JText::_('COM_JOOMDLE_GRADES');
$pdf->SetHeaderData('', 0, $header);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFontSubsetting(false);
$pdf->SetFont('times', '', 8);
// add a page
$pdf->AddPage("L");
// output the HTML content
$pdf->writeHTML($htmlcontent, true, 0, true, 0);
$pdf->Output("grades.pdf", 'D');
exit;
}
示例13: __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']);
}
示例14: generatePDF
/**
* Method creates a PDF in landscape mode, using ilPDFGeneration Job
* Rest of method similar to superclass method
*
* @param ilPDFGenerationJob $job
*/
public static function generatePDF(ilPDFGenerationJob $job)
{
// create new PDF document
// 'L' for Landscape
$pdf = new TCPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator($job->getCreator());
$pdf->SetAuthor($job->getAuthor());
$pdf->SetTitle($job->getTitle());
$pdf->SetSubject($job->getSubject());
$pdf->SetKeywords($job->getKeywords());
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins($job->getMarginLeft(), $job->getMarginTop(), $job->getMarginRight());
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak($job->getAutoPageBreak(), $job->getMarginBottom());
$pdf->setImageScale($job->getImageScale());
$pdf->SetFont('dejavusans', '', 10);
foreach ($job->getPages() as $page) {
$pdf->AddPage();
$pdf->writeHTML($page, true, false, true, false, '');
}
$result = $pdf->Output($job->getFilename(), $job->getOutputMode());
// (I - Inline, D - Download, F - File)
}
示例15: 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";
}