本文整理汇总了PHP中TCPDF::setHeaderData方法的典型用法代码示例。如果您正苦于以下问题:PHP TCPDF::setHeaderData方法的具体用法?PHP TCPDF::setHeaderData怎么用?PHP TCPDF::setHeaderData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TCPDF
的用法示例。
在下文中一共展示了TCPDF::setHeaderData方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
public function display($tpl = null)
{
$this->app = JFactory::getApplication();
$this->params = $this->app->getParams('com_rsform');
$this->template = $this->get('template');
$this->directory = $this->get('directory');
if (!$this->directory->enablepdf) {
JError::raiseWarning(500, JText::_('JERROR_ALERTNOAUTHOR'));
$this->app->redirect(JURI::root());
}
parent::display($tpl);
if (class_exists('plgSystemRSFPPDF')) {
/**
* DOMPDF Library
*/
require_once JPATH_ADMINISTRATOR . '/components/com_rsform/helpers/pdf/pdf.php';
$pdf = new RSFormPDF();
// Build the PDF Document string from the document buffer
header('Content-Type: application/pdf; charset=utf-8');
header('Content-disposition: inline; filename="export.pdf"', true);
$contents = '<link rel="stylesheet" href="' . JPATH_SITE . '/components/com_rsform/assets/css/directory.css" type="text/css"/>';
$contents .= ob_get_contents();
$pdf->write('export.pdf', $contents, true);
jexit();
} else {
/*
* Setup external configuration options
*/
define('K_TCPDF_EXTERNAL_CONFIG', true);
define("K_PATH_MAIN", JPATH_LIBRARIES . "/tcpdf");
define("K_PATH_URL", JPATH_BASE);
define("K_PATH_FONTS", K_PATH_MAIN . '/fonts/');
define("K_PATH_CACHE", K_PATH_MAIN . "/cache");
define("K_PATH_URL_CACHE", K_PATH_URL . "/cache");
define("K_PATH_IMAGES", K_PATH_MAIN . "/images");
define("K_BLANK_IMAGE", K_PATH_IMAGES . "/_blank.png");
define("K_CELL_HEIGHT_RATIO", 1.25);
define("K_TITLE_MAGNIFICATION", 1.3);
define("K_SMALL_RATIO", 2 / 3);
define("HEAD_MAGNIFICATION", 1.1);
/*
* Create the pdf document
*/
jimport('tcpdf.tcpdf');
$pdf = new TCPDF();
$pdf->SetMargins(15, 27, 15);
$pdf->SetAutoPageBreak(true, 25);
$pdf->SetHeaderMargin(5);
$pdf->SetFooterMargin(10);
$pdf->setImageScale(4);
$document = JFactory::getDocument();
// Set PDF Metadata
$pdf->SetCreator($document->getGenerator());
$pdf->SetTitle($document->getTitle());
$pdf->SetSubject($document->getDescription());
$pdf->SetKeywords($document->getMetaData('keywords'));
// Set PDF Header data
$pdf->setHeaderData('', 0, $document->getTitle(), null);
// Set RTL
$lang = JFactory::getLanguage();
$pdf->setRTL($lang->isRTL());
// Set Font
$font = 'freesans';
$pdf->setHeaderFont(array($font, '', 10));
$pdf->setFooterFont(array($font, '', 8));
// Initialize PDF Document
if (is_callable(array($pdf, 'AliasNbPages'))) {
$pdf->AliasNbPages();
}
$pdf->AddPage();
$contents .= ob_get_contents();
$pdf->WriteHTML($contents, true);
$data = $pdf->Output('', 'S');
ob_end_clean();
// Build the PDF Document string from the document buffer
header('Content-Type: application/pdf; charset=utf-8');
header('Content-disposition: attachment; filename="export.pdf"', true);
echo $data;
die;
}
}
示例2: buildPdf
protected function buildPdf()
{
/*
* Setup external configuration options
*/
define('K_TCPDF_EXTERNAL_CONFIG', true);
/*
* Path options
*/
// Installation path
define("K_PATH_MAIN", JPATH_LIBRARIES . "/tcpdf");
// URL path
define("K_PATH_URL", JPATH_BASE);
// Fonts path
define("K_PATH_FONTS", K_PATH_MAIN . '/fonts/');
// Cache directory path
define("K_PATH_CACHE", K_PATH_MAIN . "/cache");
// Cache URL path
define("K_PATH_URL_CACHE", K_PATH_URL . "/cache");
// Images path
define("K_PATH_IMAGES", K_PATH_MAIN . "/images");
// Blank image path
define("K_BLANK_IMAGE", K_PATH_IMAGES . "/_blank.png");
/*
* Format options
*/
// Cell height ratio
define("K_CELL_HEIGHT_RATIO", 1.25);
// Magnification scale for titles
define("K_TITLE_MAGNIFICATION", 1.3);
// Reduction scale for small font
define("K_SMALL_RATIO", 2 / 3);
// Magnication scale for head
define("HEAD_MAGNIFICATION", 1.1);
/*
* Create the pdf document
*/
jimport('tcpdf.tcpdf');
$pdf = new TCPDF();
$pdf->SetMargins(15, 27, 15);
$pdf->SetAutoPageBreak(true, 25);
$pdf->SetHeaderMargin(5);
$pdf->SetFooterMargin(10);
$pdf->setImageScale(4);
$document = JFactory::getDocument();
// Set PDF Metadata
$pdf->SetCreator($document->getGenerator());
$pdf->SetTitle($document->getTitle());
$pdf->SetSubject($document->getDescription());
$pdf->SetKeywords($document->getMetaData('keywords'));
// Set PDF Header data
$pdf->setHeaderData('', 0, $document->getTitle(), null);
// Set RTL
$lang = JFactory::getLanguage();
$pdf->setRTL($lang->isRTL());
// Set Font
$font = 'freesans';
$pdf->setHeaderFont(array($font, '', 10));
$pdf->setFooterFont(array($font, '', 8));
// Initialize PDF Document
if (is_callable(array($pdf, 'AliasNbPages'))) {
$pdf->AliasNbPages();
}
$pdf->AddPage();
$pdf->WriteHTML(ob_get_contents(), true);
$data = $pdf->Output('', 'S');
ob_end_clean();
// Build the PDF Document string from the document buffer
header('Content-Type: application/pdf; charset=utf-8');
header('Content-disposition: inline; filename="export.pdf"', true);
echo $data;
die;
}
示例3: pdfTask
/**
* Output the contents of a wiki page as a PDF
*
* Based on work submitted by Steven Maus <steveng4235@gmail.com> (2014)
*
* @return void
*/
public function pdfTask()
{
// Does a page exist for the given pagename?
if (!$this->page->exists() || $this->page->isDeleted()) {
App::abort(404, Lang::txt('COM_WIKI_WARNING_NOT_FOUND'));
// No! Ask if they want to create a new page
/*$this->view->setLayout('doesnotexist');
if ($this->_group)
{
$this->page->set('group_cn', $this->_group);
$this->page->set('scope', $this->_group . '/wiki');
}
if ($this->getError())
{
foreach ($this->getErrors() as $error)
{
$this->view->setError($error);
}
}
$this->view->display();
return;*/
}
// Retrieve a specific version if given
$this->view->revision = $this->page->revision(Request::getInt('version', 0));
if (!$this->view->revision->exists()) {
foreach ($this->getErrors() as $error) {
$this->view->setError($error);
}
$this->view->set('page', $this->page)->setLayout('nosuchrevision')->display();
return;
}
Request::setVar('format', 'pdf');
$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// 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 margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(10);
$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', '', 11, '', true);
$pdf->setAuthor = $this->page->creator('name');
$pdf->setCreator = \Config::get('sitename');
$pdf->setDocModificationTimeStamp($this->page->modified());
$pdf->setHeaderData(NULL, 0, strtoupper($this->page->get('itle')), NULL, array(84, 94, 124), array(146, 152, 169));
$pdf->setFooterData(array(255, 255, 255), array(255, 255, 255));
$pdf->AddPage();
// Set the view page content to current revision html
$this->view->page = $this->page;
// Load the wiki parser
$wikiconfig = array('option' => $this->_option, 'scope' => $this->page->get('scope'), 'pagename' => $this->page->get('pagename'), 'pageid' => $this->page->get('id'), 'filepath' => '', 'domain' => $this->page->get('group_cn'));
$p = Parser::getInstance();
// Parse the text
$this->view->revision->set('pagehtml', $p->parse($this->view->revision->get('pagetext'), $wikiconfig, true, true));
$pdf->writeHTML($this->view->loadTemplate(), true, false, true, false, '');
header("Content-type: application/octet-stream");
// Close and output PDF document
// Force the download of the PDF
$pdf->Output($this->page->get('pagename') . '.pdf', 'D');
exit;
}
示例4: getSmartyTpl
//.........这里部分代码省略.........
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(PDF_AUTHOR);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setFontSubsetting(false);
$pdf->AddPage();
$completion_date = '';
$resutlt = eF_getTableData('module_workbook_progress', 'completion_date', "users_LOGIN='" . $currentUser->user['login'] . "' and lessons_ID='" . $currentLessonID . "'");
if ($resutlt) {
$completion_date = $resutlt[0]['completion_date'];
}
$workbookHTML = '';
$workbookHTML .= '<table>';
$workbookHTML .= '<tr>';
$workbookHTML .= '<td colspan="2">';
$workbookHTML .= formatLogin($currentUser->user['login']);
$workbookHTML .= '</td>';
$workbookHTML .= '</tr>';
$workbookHTML .= '<tr>';
$workbookHTML .= '<td>';
$workbookHTML .= $workbookLessonName;
$workbookHTML .= '</td>';
$workbookHTML .= '<td>';
$workbookHTML .= formatTimestamp($completion_date);
$workbookHTML .= '</td>';
$workbookHTML .= '</tr>';
$workbookHTML .= '</table>';
$pdf->writeHTML($workbookHTML, true, false, true, false, '');
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setHeaderFont(array('Freeserif', 'I', 11));
$pdf->setFooterFont(array('Freeserif', '', 8));
$pdf->setHeaderData('', '', '', $workbookLessonName);
$pdf->AliasNbPages();
$pdf->SetFont('Freeserif', '', 10);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('Freeserif', '', 10);
$pdf->SetTextColor(0, 0, 0);
$workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems));
$pdf->AddPage();
$workbookHTML .= '';
$itemLogo = new EfrontFile(G_DEFAULTIMAGESPATH . "32x32/unit.png");
$itemLogoUrl = $itemLogo['path'];
foreach ($workbookItems as $key => $value) {
$workbookHTML .= '<div id="pdf-block" style="width:98%;float:left;border:1px dotted #808080;page-break-after:always;">';
$workbookHTML .= '<div style="background-color: #EAEAEA;font-weight: bold;">';
$workbookHTML .= '<img src="' . $itemLogoUrl . '"/> ' . _WORKBOOK_ITEMS_COUNT . $value['position'];
if ($value['item_title'] != '') {
$workbookHTML .= ' - ' . $value['item_title'];
}
$workbookHTML .= '</div>';
if ($value['item_text'] != '') {
$workbookHTML .= '<div>' . $value['item_text'] . '</div>';
}
if ($value['item_question'] != '-1') {
$questionType = $lessonQuestions[$value['item_question']]['type'];
if ($workbookAnswers[$value['id']] == '') {
if ($questionType == 'drag_drop') {
$dragDrop = eF_getTableData("questions", "options, answer, text", "id=" . $value['item_question']);
$options = unserialize($dragDrop[0]['options']);
$answer = unserialize($dragDrop[0]['answer']);
shuffle($options);
shuffle($answer);
$workbookHTML .= $dragDrop[0]['text'];
for ($i = 0; $i < count($options); $i++) {
示例5: display
//.........这里部分代码省略.........
$params->set('marker_mobile', $image6);
$params->set('marker_class', 'jicons-icons');
break;
}
}
$params->set('prepare_content', '0');
// Setup the category parameters.
$cparams = $category->getParams();
$category->params = clone $params;
$category->params->merge($cparams);
$children = [$category->id => $children];
$maxLevel = $params->get('maxLevel', -1);
$items = $renderHelper->groupit(['items' => & $items, 'field' => 'lname']);
if (0)
{
foreach ($items as $s1)
{
$items[$s1] = $renderHelper->groupit(['items' => $items[$s1], 'field' => 'suburb']);
}
}
$this->renderHelper = $renderHelper;
$this->maxLevel = & $maxLevel;
$this->state = & $state;
$this->items = $items;
$this->category = & $category;
$this->children = & $children;
$this->params = & $params;
$this->pagination = & $pagination;
// Escape strings for HTML output
$this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
$menus = $app->getMenu();
$title = 'directory_prent_out';
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
// Clean the output buffer
@ob_end_clean();
// Create new PDF document
$this->pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// Set document information
$this->pdf->SetCreator(PDF_CREATOR);
$this->pdf->SetAuthor('NFSDA Church');
$this->pdf->SetTitle($this->params->get('page_title', ''));
$this->pdf->SetSubject('Church Directory');
$this->pdf->SetKeywords('Directory, PDF, Members');
// Set default header data
$this->pdf->setHeaderData(
$params->get('pdf_logo'),
$params->get('pdf_logo_width'),
$this->params->get('page_heading'),
$params->get('pdf_header_string')
);
// Remove default header/footer
$this->pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$this->pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// Set default monospaced font
$this->pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// Set margins
$this->pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$this->pdf->setHeaderMargin(PDF_MARGIN_HEADER);
$this->pdf->setFooterMargin(PDF_MARGIN_FOOTER);
// Set auto page breaks
$this->pdf->SetAutoPageBreak(true, PDF_MARGIN_BOTTOM);
$this->pdf->setCellHeightRatio(1.25);
// Set image scale factor
$this->pdf->setImageScale(2.5);
// ---------------------------------------------------------
// Set font
$this->pdf->SetFont('times', 'BI', 8, '', 'false');
// Set some text to print
$html = $this->loadTemplate($tpl);
$jweb = new JApplicationWeb;
$jweb->clearHeaders();
// Close and output PDF document
$this->pdf->Output($title . '.pdf', 'I');
return null;
}
示例6: getSmartyTpl
public function getSmartyTpl()
{
$currentUser = $this->getCurrentUser();
$rules = $this->getRules();
$smarty = $this->getSmartyVar();
if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
$currentLesson = $this->getCurrentLesson();
$currentLessonID = $currentLesson->lesson['id'];
if (!isset($_SESSION['module_journal_dimension']) || count($_GET) == 2 && $_GET['ctg'] == 'module' && $_GET['op'] == 'module_journal' || count($_GET) == 3 && $_GET['ctg'] == 'module' && $_GET['op'] == 'module_journal' && $_GET['new_lesson_id'] == $currentLessonID) {
$_SESSION['module_journal_dimension'] = 'small';
}
if (!isset($_SESSION['module_journal_entries_from']) || count($_GET) == 2 && $_GET['ctg'] == 'module' && $_GET['op'] == 'module_journal' || count($_GET) == 3 && $_GET['ctg'] == 'module' && $_GET['op'] == 'module_journal' && $_GET['new_lesson_id'] == $currentLessonID) {
$_SESSION['module_journal_entries_from'] = '-1';
}
if (isset($_SESSION['module_journal_scroll_position'])) {
$smarty->assign("T_JOURNAL_SCROLL_POSITION", $_SESSION['module_journal_scroll_position']);
}
$smarty->assign("T_JOURNAL_DIMENSIONS", $_SESSION['module_journal_dimension']);
$smarty->assign("T_JOURNAL_ENTRIES_FROM", $_SESSION['module_journal_entries_from']);
$entries = $this->getEntries($currentUser->user['login'], $_SESSION['module_journal_entries_from']);
global $popup;
isset($popup) && $popup == 1 ? $popup_ = '&popup=1' : ($popup_ = '');
}
$smarty->assign("T_JOURNAL_BASEURL", $this->moduleBaseUrl);
$smarty->assign("T_JOURNAL_BASELINK", $this->moduleBaseLink);
if (isset($_GET['edit_allow_export']) && $_GET['edit_allow_export'] == '1' && isset($_GET['allow'])) {
try {
$object = eF_getTableData("module_journal_settings", "id", "name='export'");
eF_updateTableData("module_journal_settings", array("value" => $_GET['allow']), "id=" . $object[0]['id']);
} catch (Exception $e) {
handleAjaxExceptions($e);
}
exit;
}
if (isset($_GET['edit_professor_preview']) && $_GET['edit_professor_preview'] == '1' && isset($_GET['preview'])) {
try {
$object = eF_getTableData("module_journal_settings", "id", "name='preview'");
eF_updateTableData("module_journal_settings", array("value" => $_GET['preview']), "id=" . $object[0]['id']);
} catch (Exception $e) {
handleAjaxExceptions($e);
}
exit;
}
if (isset($_GET['dimension']) && eF_checkParameter($_GET['dimension'], 'string')) {
$smarty->assign("T_JOURNAL_DIMENSIONS", $_GET['dimension']);
$_SESSION['module_journal_dimension'] = $_GET['dimension'];
}
if (isset($_GET['entries_from'])) {
$smarty->assign("T_JOURNAL_ENTRIES_FROM", $_GET['entries_from']);
$_SESSION['module_journal_entries_from'] = $_GET['entries_from'];
}
if (isset($_GET['delete_rule']) && eF_checkParameter($_GET['delete_rule'], 'id') && in_array($_GET['delete_rule'], array_keys($rules))) {
try {
eF_deleteTableData("module_journal_rules", "id=" . $_GET['delete_rule']);
} catch (Exception $e) {
handleAjaxExceptions($e);
}
exit;
}
if (isset($_GET['deactivate_rule']) && eF_checkParameter($_GET['deactivate_rule'], 'id') && in_array($_GET['deactivate_rule'], array_keys($rules))) {
eF_updateTableData("module_journal_rules", array('active' => 0), "id=" . $_GET['deactivate_rule']);
}
if (isset($_GET['activate_rule']) && eF_checkParameter($_GET['activate_rule'], 'id') && in_array($_GET['activate_rule'], array_keys($rules))) {
eF_updateTableData("module_journal_rules", array('active' => 1), "id=" . $_GET['activate_rule']);
}
if (isset($_GET['delete_entry']) && eF_checkParameter($_GET['delete_entry'], 'id') && in_array($_GET['delete_entry'], array_keys($entries))) {
$object = eF_getTableData("module_journal_entries", "users_LOGIN", "id=" . $_GET['delete_entry']);
if ($object[0]['users_LOGIN'] != $_SESSION['s_login']) {
eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_JOURNAL_NOACCESS) . $popup_);
exit;
}
eF_deleteTableData("module_journal_entries", "id=" . $_GET['delete_entry']);
}
if (isset($_GET['saveas']) && $_GET['saveas'] == 'pdf') {
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(PDF_AUTHOR);
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setFontSubsetting(false);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->setHeaderFont(array('Freeserif', 'I', 11));
$pdf->setFooterFont(array('Freeserif', '', 8));
$pdf->setHeaderData('', '', '', _JOURNAL_NAME);
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Freeserif', '', 10);
$pdf->SetTextColor(0, 0, 0);
foreach ($entries as $entry) {
$pdf->Cell(0, 0, $entry['entry_date_formatted'], 0, 1, L, 0);
$pdf->writeHTML('<br/>', true, false, true, false, '');
$pdf->writeHTML($entry['entry_body'], true, false, true, false, '');
$pdf->writeHTML('<div style="height: 5px;"></div>', true, false, true, false, '');
$pdf->writeHTML('<hr>', true, false, true, false, '');
}
$fileNamePdf = "journal.pdf";
header("Content-type: application/pdf");
header("Content-disposition: attachment; filename=" . $fileNamePdf);
echo $pdf->Output('', 'S');
//.........这里部分代码省略.........
示例7: setHeaderData
/**
* Creates a header for each page with a custom logo defined
* @param string $ln header image logo
* @param int $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
*/
public function setHeaderData($ln = '', $lw = 0, $ht = '', $hs = '')
{
$logo_path = get_config("PDF_LOGO");
if (!$ln) {
$ln = $logo_path ? $logo_path : '../../../../public/assets/images/logos/logoklein.png';
}
$lw = 30;
$ht = $ht == '' ? $this->h_title : $ht;
$hs = $hs == '' ? $this->h_string : $hs;
parent::setHeaderData($ln, $lw, $ht, $hs);
}
示例8: TCPDF
$proceso = $_GET['proceso'];
$tabla = $_GET['tabla'];
$query = "SELECT * " . "FROM " . $tabla . " " . "INNER JOIN ciudadanos " . "ON " . $tabla . ".id_ciudadano = ciudadanos.id_ciudadano " . "WHERE " . $tabla . ".id_" . $proceso . " = {$id}";
}
$rs = $objDB->getRecord($query);
// Include the main TCPDF library (search for installation path).
require_once '../tcpdf/tcpdf.php';
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, 'LETTER', 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');
$pdf->setHeaderData('oac_logo.png', '180.40');
//$pdf->Image('','40');
// // set default header data
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 021', PDF_HEADER_STRING);
//$pdf->setHeaderData('http://localhost/sdenuncias/imagenes/oac_logo.png');
// 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);
示例9: pdfTask
/**
* Output the contents of a wiki page as a PDF
*
* Based on work submitted by Steven Maus <steveng4235@gmail.com> (2014)
*
* @return void
*/
public function pdfTask()
{
// Does a page exist for the given pagename?
if (!$this->page->exists() || $this->page->isDeleted()) {
App::abort(404, Lang::txt('COM_WIKI_WARNING_NOT_FOUND'));
}
// Retrieve a specific version if given
if ($version = Request::getInt('version', 0)) {
$revision = $this->page->versions()->whereEquals('version', $version)->whereEquals('approved', 1)->row();
} else {
$revision = $this->page->version;
}
if (!$revision->exists()) {
$this->view->set('page', $this->page)->set('version', $version)->set('sub', $this->page->get('scope') != 'site')->setLayout('nosuchrevision')->display();
return;
}
// Log activity
$recipients = array(['wiki.site', 1]);
if ($this->page->get('scope') != 'site') {
$recipients[] = [$this->page->get('scope'), $this->page->get('scope_id')];
$recipients[0] = ['wiki.' . $this->page->get('scope'), $this->page->get('scope_id')];
}
Event::trigger('system.logActivity', ['activity' => ['action' => 'downloaded', 'scope' => 'wiki.page', 'scope_id' => $this->page->get('id'), 'description' => Lang::txt('COM_WIKI_ACTIVITY_PAGE_DOWNLOADED', '<a href="' . Route::url($this->page->link()) . '">' . $this->page->title . '</a>'), 'details' => array('title' => $this->page->title, 'url' => Route::url($this->page->link()), 'name' => $this->page->get('pagename'))], 'recipients' => $recipients]);
Request::setVar('format', 'pdf');
$pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// 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 margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(10);
$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', '', 11, '', true);
$pdf->setAuthor = $this->page->creator()->get('name');
$pdf->setCreator = \Config::get('sitename');
$pdf->setDocModificationTimeStamp($this->page->modified());
$pdf->setHeaderData(NULL, 0, strtoupper($this->page->title), NULL, array(84, 94, 124), array(146, 152, 169));
$pdf->setFooterData(array(255, 255, 255), array(255, 255, 255));
$pdf->AddPage();
// Parse wiki content
$revision->set('pagehtml', $revision->content($this->page));
// Set the view page content to current revision html
$this->view->set('page', $this->page)->set('revision', $revision);
$pdf->writeHTML($this->view->loadTemplate(), true, false, true, false, '');
header("Content-type: application/octet-stream");
// Close and output PDF document
// Force the download of the PDF
$pdf->Output($this->page->get('pagename') . '.pdf', 'D');
exit;
}
示例10: TCPDF
<?php
date_default_timezone_set("Europe/Berlin");
require_once "mygassi-config.php";
require_once TCPDFPath;
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('MyGassi');
$pdf->SetTitle('MyGassi');
$pdf->SetSubject('MyGassi Rechnung');
$pdf->SetKeywords('MyGassi Rechnung');
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->setHeaderData('', 0, '', '', array(0, 0, 0), array(255, 255, 255));
$pdf->setFooterData('', 0, '', '', array(0, 0, 0), array(255, 255, 255));
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->setFontSubsetting(true);
$pdf->SetFont('dejavusans', '', 14, '', true);
$pdf->AddPage();
/*
$temp = "";
foreach($invoices as $invoice){
foreach($invoice->getAllItems() as $item){
$temp .= $item->getName();
$temp .= "<br/>";
}
}
*/
$path = "shell/pdf/test.pdf";
$model = new Model();
$model->title = "Diese Rechnung wird von einer HTML/CSS Stylevorlage generiert und das freut uns alle sehr weil wir die Desighvorlagen übernehmen können.";
// $model->test = $temp;
示例11: TCPDF
function Generate_Content()
{
$pdf = new TCPDF();
//kods ņemts no
// http://www.tecnick.com/pagefiles/tcpdf/example_001.phps
// galvene
$pdf->setHeaderData("", "", "", "Atzīmju izraksts");
// set header and footer fonts
$pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', 12));
//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);
//initialize document
$pdf->AliasNbPages();
// add a page
$pdf->AddPage();
// set font
$pdf->SetFont("helvetica", "", 10);
// print a line using Cell()
$pdf->Cell(50, 12, "Skolēns: {$this->studentName}", 0, 0, 'L');
$pdf->Ln();
//ģenerē visu butisko saturu
for ($i = 0; $i < count($this->grades); $i++) {
$grade = $this->grades[$i];
$pdf->Cell(0, 0, sprintf("%s %s %s", $grade["date"], $grade["lesson"], $grade["grade"]), 0, 0, 'L');
$pdf->Ln();
}
$this->fileContents = $pdf;
}