本文整理汇总了PHP中mPDF::SetCreator方法的典型用法代码示例。如果您正苦于以下问题:PHP mPDF::SetCreator方法的具体用法?PHP mPDF::SetCreator怎么用?PHP mPDF::SetCreator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mPDF
的用法示例。
在下文中一共展示了mPDF::SetCreator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pdf
public function pdf($content, $namafile, $paper_size = '', $orientation = 'P', $border = true, $title = '', $subject = '', $mode = 'D', $watermark = false)
{
$margin = 20;
$namafile = preg_replace('/\\.pdf$/', '', $namafile);
$mL = $mR = $mT = $mB = $margin;
// $mB = $margin + 50;
$mH = 0;
$mF = 0;
if (!$paper_size) {
$paper_size = array(215, 330);
}
Yii::import('system.docotel.cms.extensions.mpdf.mPDF');
$mpdf = new mPDF('', $paper_size, 0, '', $mL, $mR, $mT, $mB, $mH, $mF, $orientation);
$mpdf->SetDefaultFont('Arial');
$mpdf->SetProtection(array('print', 'print-highres'), '', md5(time()), 128);
$mpdf->SetTitle($title);
$mpdf->SetAuthor('Makarim & Taira');
$mpdf->SetCreator('News');
$mpdf->SetSubject($subject);
$mpdf->h2toc = array('H4' => 0, 'H5' => 1);
//$mpdf->setFooter('{PAGENO}');
// $stylesheet = file_get_contents(Yii::app()->getBaseUrl(true).'/themes/flatlab/assets/css/bootstrap.min.css'); // external css
// $mpdf->WriteHTML($stylesheet,1);
// echo $content; exit;
$mpdf->WriteHTML($content);
$mpdf->Output($namafile . '.pdf', $mode);
if ($mode === 'D' or $mode === 'I') {
exit;
}
}
示例2: pdf_echo
function pdf_echo($filename = "")
{
global $__pdf_html, $__pdf_orientation, $__pdf_wm_text, $__pdf_wm_img, $__pdg_pgn_pos, $__pdf_title, $__pdf_subject, $__pdf_author, $__pdf_creator, $__pdf_keywords, $__pdf_wm_talpha, $__pdf_wm_font, $__pdf_wm_ialpha, $__pdf_pgn_text, $__pdf_pgn_pos, $__pdf_pgn_oalign, $__pdf_pgn_ealign, $__pdf_pgn_show, $__pdf_pgn_fcolor, $__pdf_pgn_ftype, $__pdf_pgn_fsize, $__pdf_pgn_fstyle, $__pdf_pgn_lstyle, $__pdf_pgn_lwidth, $__pdf_pgn_lcolor, $__pdf_pgmargin_l, $__pdf_pgmargin_r, $__pdf_pgmargin_t, $__pdf_pgmargin_b, $__pdf_pgmargin_h, $__pdf_pgmargin_f;
require_once dirname(__FILE__) . "/__RES__/mpdf.php";
$pdf = new mPDF("th");
$pdf->useOddEven = 1;
if ($__pdf_pgn_show) {
$dv1 = "<div style=\"{$__pdf_pgn_fcolor};width:auto;text-align:";
$dv2 = ";{$__pdf_pgn_ftype}{$__pdf_pgn_fsize}{$__pdf_pgn_fstyle}";
$dv3 = "style:{$__pdf_pgn_lstyle};";
$dv4 = "width:{$__pdf_pgn_lwidth};";
$dv5 = "color:{$__pdf_pgn_lcolor};";
$dv6 = "\">{$__pdf_pgn_text}</div>";
if ($__pdf_pgn_pos == "TOP") {
$align = $__pdf_pgn_oalign;
$border = "border-bottom-";
$pgh_o = "{$dv1}{$align}{$dv2}{$border}{$dv3}{$border}{$dv4}{$border}{$dv5}{$dv6}";
$pdf->DefHTMLHeaderByName("ho", $pgh_o);
$align = $__pdf_pgn_ealign;
$pgh_e = "{$dv1}{$align}{$dv2}{$border}{$dv3}{$border}{$dv4}{$border}{$dv5}{$dv6}";
$pdf->DefHTMLHeaderByName("he", $pgh_e);
$pdf->AddPage($__pdf_orientation, '', '', '', '', $__pdf_pgmargin_l, $__pdf_pgmargin_r, $__pdf_pgmargin_t, $__pdf_pgmargin_b, $__pdf_pgmargin_h, $__pdf_pgmargin_f, 'html_ho', 'html_he', '', '', 1, 1, 0, 0);
} else {
if ($__pdf_pgn_pos == "BOTTOM") {
$align = $__pdf_pgn_oalign;
$border = "border-top-";
$pgf_o = "{$dv1}{$align}{$dv2}{$border}{$dv3}{$border}{$dv4}{$border}{$dv5}{$dv6}";
$pdf->DefHTMLFooterByName("fo", $pgf_o);
$align = $__pdf_pgn_ealign;
$pgf_e = "{$dv1}{$align}{$dv2}{$border}{$dv3}{$border}{$dv4}{$border}{$dv5}{$dv6}";
$pdf->DefHTMLFooterByName("fe", $pgf_e);
$pdf->AddPage($__pdf_orientation, '', '', '', '', $__pdf_pgmargin_l, $__pdf_pgmargin_r, $__pdf_pgmargin_t, $__pdf_pgmargin_b, $__pdf_pgmargin_h, $__pdf_pgmargin_f, '', '', 'html_fo', 'html_fe', 0, 0, 1, 1);
}
}
} else {
$pdf->AddPage($__pdf_orientation);
}
$pdf->SetTitle($__pdf_title);
$pdf->SetAuthor($__pdf_author);
$pdf->SetCreator($__pdf_creator);
$pdf->SetSubject($__pdf_subject);
$pdf->SetKeywords($__pdf_keywords);
if ($__pdf_wm_text != "") {
$pdf->SetWatermarkText($__pdf_wm_text, $__pdf_wm_talpha);
$pdf->showWatermarkText = true;
if ($__pdf_wm_font) {
$pdf->watermark_font = $__pdf_wm_font;
}
}
if (file_exists($__pdf_wm_img)) {
$pdf->SetWatermarkImage($__pdf_wm_img, $__pdf_wm_ialpha);
$pdf->showWatermarkImage = true;
}
$pdf->WriteHTML($__pdf_html);
$pdf->Output($filename, $dest);
}
示例3: mpdf
static public function mpdf( $html_path, $pdf_path, $css_rel_path, $format = 'A4', $download = false) {
// reporting komplett abschalten
$error_reporting = error_reporting();
error_reporting(0);
ProjectConfiguration::registerMPDF();
$mpdf=new mPDF('ch-DE',$format,'8','DejaVuSansCondensed',15,15,30,15,10,10);
$mpdf->packTableData = true;
//$mpdf->debug = true;
$mpdf->SetDisplayMode('fullpage');
$mpdf->defaultfooterfontstyle='';
$mpdf->defaultfooterfontsize='8';
$mpdf->SetFooter(basename($pdf_path).'|Stand: {DATE j.m.Y H:i}|Seite {PAGENO}/{nbpg}');
$mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
$mpdf->shrink_tables_to_fit=1;
// LOAD a stylesheet
#$stylesheet = file_get_contents(sfConfig::get('sf_web_dir').'/css/backend/pdf/class_etat.css');
$stylesheet = file_get_contents(sfConfig::get('sf_web_dir').'/css/'.$css_rel_path);
$mpdf->WriteHTML($stylesheet,1); // parameter 1 indicates this is css
$html = file_get_contents($html_path);
$mpdf->WriteHTML($html,2);
//$mpdf->SetTitle();
$mpdf->SetAuthor('');
$mpdf->SetCreator('rockstep');
if ($download) {
$mpdf->Output( $pdf_path, 'I');
} else {
$mpdf->Output( $pdf_path, 'F');
}
error_reporting($error_reporting);
}
示例4: pdf_export
/**
* Export a pdf
*
* @static
* @param string $title Document title
* @param string $css CSS Contents
* @param string $html HTML Contents
* @param string $page_format Default A4
* @param string $orientation Can be P|L
* @return boolean
*/
public static function pdf_export($title, $css, $html, $page_format = 'A4', $orientation = 'P')
{
// language set
$l = array();
$l['a_meta_charset'] = 'UTF-8';
$l['a_meta_dir'] = 'rtl';
$l['a_meta_language'] = X4Route_core::$lang;
$l['w_page'] = _PAGE;
X4Core_core::auto_load('mpdf_library');
// create the PDF object
$mpdf = new mPDF(X4Route_core::$lang, $page_format, 0, 0, 0, 0, 0, 0, $orientation);
$title = SERVICE . ' - ' . $title . ' - ' . date('Y-m-d H:i:s');
$mpdf->SetAuthor($_SESSION['nickname']);
$mpdf->SetCreator(SERVICE);
$mpdf->SetTitle($title);
$mpdf->SetDisplayMode('fullwidth');
$mpdf->WriteHTML($css, 1);
$mpdf->WriteHTML($html, 2);
$filename = X4Utils_helper::unspace(str_replace(' - ', '-', $title), true);
$mpdf->Output($filename . '.pdf', 'D');
exit;
}
示例5: substr
<?php
# THIS ONE DOES NOT HAVE AddPageByArray
include "../mpdf.php";
$html_data = file_get_contents("body.html");
$html = substr($html_data, 12, strlen($html_data) - 27);
$style_data = file_get_contents("style_current.css");
$frontmatter_data = file_get_contents("frontmatter_current.html");
$mpdf = new mPDF();
// Make it DOUBLE SIDED document
$mpdf->mirrorMargins = 1;
$mpdf->bleedMargin = 4;
$mpdf->h2toc = array();
$mpdf->WriteHTML($style_data, 1);
$html = "<sethtmlpagefooter name=\"footer-left\" page=\"E\" value=\"on\" />" . $html;
$html = "<sethtmlpagefooter name=\"footer-right\" page=\"O\" value=\"on\" />" . $html;
$mpdf->WriteHTML($frontmatter_data, 2);
$mpdf->WriteHTML($html, 2);
$mpdf->SetTitle("Title");
$mpdf->SetAuthor("Author");
$mpdf->SetCreator("Booktype");
$mpdf->Output();
?>
示例6: _getPDFBinaryString
/**
* Retorna o PDF em forma de string binária
* O objetivo é permitir envio do PDF através de anexo de e-mail
*/
protected function _getPDFBinaryString($css, $html)
{
// Foi difícil, mas achei a solução: http://stackoverflow.com/a/9178296/846419
try {
ob_start();
// This is very important to start output buffering and to catch out any possible notices
require_once MPDF_PATH;
$mpdf = new mPDF('utf-8', 'A4', 10, 'Arial', 5, 5, 48, 25, 10, 10);
$mpdf->debug = true;
$mpdf->allow_output_buffering = true;
$mpdf->useOnlyCoreFonts = true;
// false is default
$mpdf->SetTitle($this->doc_titulo);
$mpdf->SetAuthor($this->doc_autor);
$mpdf->SetCreator($this->doc_criador);
$mpdf->SetWatermarkText("SiGE");
$mpdf->showWatermarkText = true;
$mpdf->watermark_font = 'DejaVuSansCondensed';
$mpdf->watermarkTextAlpha = 0.1;
$mpdf->SetDisplayMode('fullpage');
// $mpdf->SetAutoFont(0); // deprecated
$mpdf->autoScriptToLang = FALSE;
$mpdf->WriteHTML($css, 1);
$mpdf->WriteHTML($html);
$pdf_binary = $mpdf->Output('', 'S');
// With the binary PDF data in $pdf we can do whatever we want - attach it to email, save to filesystem, push to browser's PDF plugin or offer it to user for download
// ob_get_contents(); // Here we catch out previous output from buffer (and can log it, email it, or throw it away as I do :-) )
ob_end_clean();
// Finaly we clean output buffering and turn it off
return $pdf_binary;
} catch (Exception $e) {
throw $e;
}
}
示例7: generate
/**
* Generate the PDF file using the mPDF library.
*
* @param string $html
* contents of the template already with the node data.
* @param string $filename
* name of the PDF file to be generated.
*/
public function generate($html, $config, $filename = 'newPdfDocument')
{
// International Paper Sizes ( width x height).
$paper_size = array('4A0' => array('w' => 1682, 'h' => 2378), '2A0' => array('w' => 1189, 'h' => 1682), 'A0' => array('w' => 841, 'h' => 1189), 'A1' => array('w' => 594, 'h' => 841), 'A2' => array('w' => 420, 'h' => 594), 'A3' => array('w' => 297, 'h' => 420), 'A4' => array('w' => 210, 'h' => 297), 'A5' => array('w' => 148, 'h' => 210), 'A6' => array('w' => 105, 'h' => 148), 'A7' => array('w' => 74, 'h' => 105), 'A8' => array('w' => 52, 'h' => 74), 'A9' => array('w' => 37, 'h' => 52), 'A10' => array('w' => 26, 'h' => 37), 'B0' => array('w' => 1000, 'h' => 1414), 'B1' => array('w' => 707, 'h' => 1000), 'B2' => array('w' => 500, 'h' => 707), 'B3' => array('w' => 353, 'h' => 500), 'B4' => array('w' => 250, 'h' => 353), 'B5' => array('w' => 176, 'h' => 250), 'B6' => array('w' => 125, 'h' => 176), 'B7' => array('w' => 88, 'h' => 125), 'B8' => array('w' => 62, 'h' => 88), 'B9' => array('w' => 44, 'h' => 62), 'B10' => array('w' => 31, 'h' => 44), 'C0' => array('w' => 917, 'h' => 1297), 'C1' => array('w' => 648, 'h' => 917), 'C2' => array('w' => 458, 'h' => 648), 'C3' => array('w' => 324, 'h' => 458), 'C4' => array('w' => 229, 'h' => 324), 'C5' => array('w' => 162, 'h' => 229), 'C6' => array('w' => 114, 'h' => 162), 'C7' => array('w' => 81, 'h' => 114), 'C8' => array('w' => 57, 'h' => 81), 'C9' => array('w' => 40, 'h' => 57), 'C10' => array('w' => 28, 'h' => 40), 'RA0' => array('w' => 860, 'h' => 1220), 'RA1' => array('w' => 610, 'h' => 860), 'RA2' => array('w' => 430, 'h' => 610), 'SRA0' => array('w' => 900, 'h' => 1280), 'SRA1' => array('w' => 640, 'h' => 900), 'SRA2' => array('w' => 450, 'h' => 640), 'Letter' => array('w' => 215.9, 'h' => 279.4), 'Legal' => array('w' => 215.9, 'h' => 355.6), 'Ledger' => array('w' => 279.4, 'h' => 431.8));
$page = $config['page_type'];
//conf
$font_size = $config['font_size'];
$font_style = $config['font_style'];
// DEFAULT PDF margin Values.
$margin_top = $config['margin_top'];
//conf
$margin_right = $config['margin_right'];
$margin_bottom = $config['margin_bottom'];
$margin_left = $config['margin_left'];
$margin_header = $config['margin_header'];
$margin_footer = $config['margin_footer'];
// Creating Instance of mPDF Class Library.
require_once 'Src/Modules/Pdf/Libs/mpdf60/mpdf.php';
$mpdf = new \mPDF('', array($paper_size[$page]['w'], $paper_size[$page]['h']), $font_size, $font_style, $margin_left, $margin_right, $margin_top, $margin_bottom, $margin_header, $margin_footer);
// set document DPI
$mpdf->dpi = 96;
// Set image DPI
$mpdf->img_dpi = 96;
// Enabling header option if available.
$header = $config['header'];
//string in conf
if (isset($header) && $header != NULL) {
//$header = token_replace($header);
$mpdf->SetHTMLHeader($header);
}
// Enabling Footer option if available.
$footer = $config['footer'];
if (isset($footer) && $footer != NULL) {
//$footer = token_replace($footer);
$mpdf->SetHTMLFooter($footer);
}
// Setting Watermark Text to PDF.
$watermark_option = 'text';
//conf
$watermark_opacity = $config['watermark_opacity'];
// For watermark Text.
if ($watermark_option == 'text') {
$text = $config['watermark_text'];
if (isset($text) && $text != NULL) {
$mpdf->SetWatermarkText($text, $watermark_opacity);
$mpdf->showWatermarkText = TRUE;
}
}
// Setting Title to PDF.
$title = $config['doc_title'];
if (isset($title) && $title != NULL) {
$mpdf->SetTitle($title);
}
// Setting Author to PDF.
$author = $config['doc_author'];
//conf
if (isset($author) && $author != NULL) {
$mpdf->SetAuthor($author);
}
// Setting Subject to PDF.
$subject = $config['doc_subject'];
if (isset($subject) && $subject != NULL) {
$mpdf->SetSubject($subject);
}
// Setting creator to PDF.
$creator = $config['doc_creator'];
if (isset($creator) && $creator != NULL) {
$mpdf->SetCreator($creator);
}
// Setting Password to PDF.
$password = $config['password'];
if (isset($password) && $password != NULL) {
// Print and Copy is allowed.
$mpdf->SetProtection(array('print', 'copy'), $password, $password);
}
// Setting CSS stylesheet to PDF.
if (!empty($config['stylesheets'])) {
$cssArr = explode('<br />', nl2br($config['stylesheets']));
$cssArr = array_map('trim', $cssArr);
$cssArr = array_filter($cssArr);
foreach ($cssArr as $key => $stylesheet) {
$stylesheet_content = NULL;
if (isset($stylesheet) && $stylesheet != NULL) {
$stylesheet_content = file_get_contents($stylesheet);
$mpdf->WriteHTML($stylesheet_content, 1);
}
}
}
// Writing html content for pdf buffer.
$mpdf->WriteHTML($html);
return $mpdf->Output($filename . '.pdf', $config['save_option']);
}
示例8: substr
<?php
# THIS ONE DOES NOT HAVE AddPageByArray ANY MORE :-)
include "../mpdf.php";
$html_data = file_get_contents("body.html");
$html = substr($html_data, 12, strlen($html_data) - 27);
$style_data = file_get_contents("style_setheader.css");
$frontmatter_data = file_get_contents("frontmatter_setheader.html");
// Create new PDF with font subsetting, 234mm wide, 297mm high
$mpdf = new mPDF('s', array(234, 297));
// Make it DOUBLE SIDED document with 4mm bleed
$mpdf->mirrorMargins = 1;
$mpdf->bleedMargin = 4;
$mpdf->h2toc = array();
$mpdf->WriteHTML($style_data, 1);
$mpdf->WriteHTML($frontmatter_data, 2);
$mpdf->WriteHTML($html, 2);
$mpdf->SetTitle("An Example Title");
$mpdf->SetAuthor("Aco");
$mpdf->SetCreator("Booktype 2.0 and mPDF 6.0");
$mpdf->Output();
?>
示例9: die
* PURPOSE. See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public *
* License along with eLabFTW. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
require_once 'inc/common.php';
require_once ELAB_ROOT . 'inc/locale.php';
require_once ELAB_ROOT . 'vendor/autoload.php';
// Check id is valid and assign it to $id
if (isset($_GET['id']) && is_pos_int($_GET['id'])) {
$id = $_GET['id'];
} else {
die(_("The id parameter is not valid!"));
}
// check the type
if ($_GET['type'] === 'experiments' || $_GET['type'] === 'items') {
$type = $_GET['type'];
} else {
die(_("The type parameter is not valid."));
}
// do the pdf
$pdf = new \Elabftw\Elabftw\MakePdf($id, $type);
$mpdf = new mPDF();
$mpdf->SetAuthor($pdf->author);
$mpdf->SetTitle($pdf->title);
$mpdf->SetSubject('eLabFTW pdf');
$mpdf->SetKeywords($pdf->tags);
$mpdf->SetCreator('www.elabftw.net');
$mpdf->WriteHTML($pdf->content);
$mpdf->Output($pdf->getFileName(), 'I');
示例10: generate_pdf
public function generate_pdf($content, $name = 'download.pdf', $output_type = NULL, $footer = NULL, $margin_bottom = NULL, $header = NULL, $margin_top = NULL, $orientation = 'P')
{
if (!$output_type) {
$output_type = 'D';
}
if (!$margin_bottom) {
$margin_bottom = 10;
}
if (!$margin_top) {
$margin_top = 10;
}
$this->load->library('pdf');
$pdf = new mPDF('utf-8', 'A4-' . $orientation, '13', '', 10, 10, $margin_top, $margin_bottom, 9, 9);
$pdf->debug = false;
$pdf->autoScriptToLang = true;
$pdf->autoLangToFont = true;
$pdf->SetProtection(array('print'));
// You pass 2nd arg for user password (open) and 3rd for owner password (edit)
//$pdf->SetProtection(array('print', 'copy')); // Comment above line and uncomment this to allow copying of content
$pdf->SetTitle($this->Settings->site_name);
$pdf->SetAuthor($this->Settings->site_name);
$pdf->SetCreator($this->Settings->site_name);
$pdf->SetDisplayMode('fullpage');
$stylesheet = file_get_contents('assets/bs/bootstrap.min.css');
$pdf->WriteHTML($stylesheet, 1);
$pdf->WriteHTML($content);
if ($header != '') {
$pdf->SetHTMLHeader('<p class="text-center">' . $header . '</p>', '', TRUE);
}
if ($footer != '') {
$pdf->SetHTMLFooter('<p class="text-center">' . $footer . '</p>', '', TRUE);
}
//$pdf->SetHeader($this->Settings->site_name.'||{PAGENO}', '', TRUE); // For simple text header
//$pdf->SetFooter($this->Settings->site_name.'||{PAGENO}', '', TRUE); // For simple text footer
if ($output_type == 'S') {
$file_content = $pdf->Output('', 'S');
write_file('assets/uploads/' . $name, $file_content);
return 'assets/uploads/' . $name;
} else {
$pdf->Output($name, $output_type);
}
}
示例11: PDF_processing
/**
* Creates the PDF and does a specific output (see PDF_Generator function above for $output variable types)
*/
public function PDF_processing($html, $filename, $id, $output = 'view', $arguments)
{
/*
* DOMPDF replaced with mPDF in v3.0.0
* Check which version of mpdf we are calling
* Full, Lite or Tiny
*/
if (!class_exists('mPDF')) {
if (FP_PDF_ENABLE_MPDF_TINY === true) {
include FP_PDF_PLUGIN_DIR . '/mPDF/mpdf-extra-lite.php';
} elseif (FP_PDF_ENABLE_MPDF_LITE === true) {
include FP_PDF_PLUGIN_DIR . '/mPDF/mpdf-lite.php';
} else {
include FP_PDF_PLUGIN_DIR . '/mPDF/mpdf.php';
}
}
/*
* Initialise class and set the paper size and orientation
*/
$paper_size = $arguments['pdf_size'];
if (!is_array($paper_size)) {
$orientation = $arguments['orientation'] == 'landscape' ? '-L' : '';
$paper_size = $paper_size . $orientation;
} else {
$orientation = $arguments['orientation'] == 'landscape' ? 'L' : 'P';
}
$mpdf = new mPDF('', $paper_size, 0, '', 15, 15, 16, 16, 9, 9, $orientation);
/*
* Display PDF is full-page mode which allows the entire PDF page to be viewed
* Normally PDF is zoomed right in.
*/
$mpdf->SetDisplayMode('fullpage');
if (FP_PDF_ENABLE_SIMPLE_TABLES === true) {
$mpdf->simpleTables = true;
}
/*
* Automatically detect fonts and substitue as needed
*/
if (FP_PDF_DISABLE_FONT_SUBSTITUTION === true) {
$mpdf->useSubstitutions = false;
} else {
$mpdf->SetAutoFont(AUTOFONT_ALL);
$mpdf->useSubstitutions = true;
}
/*
* Set Creator Meta Data
*/
$mpdf->SetCreator('Formidable Pro PDF Extended v' . FP_PDF_EXTENDED_VERSION . '. http://formidablepropdfextended.com');
/*
* Set RTL languages at user request
*/
if ($arguments['rtl'] === true) {
$mpdf->SetDirectionality('rtl');
}
/*
* Set up security if user requested
*/
if ($arguments['security'] === true && $arguments['pdfa1b'] !== true && $arguments['pdfx1a'] !== true) {
$password = strlen($arguments['pdf_password']) > 0 ? $arguments['pdf_password'] : '';
$master_password = strlen($arguments['pdf_master_password']) > 0 ? $arguments['pdf_master_password'] : null;
$pdf_privileges = is_array($arguments['pdf_privileges']) ? $arguments['pdf_privileges'] : array();
$mpdf->SetProtection($pdf_privileges, $password, $master_password, 128);
}
/* PDF/A1-b support added in v3.4.0 */
if ($arguments['pdfa1b'] === true) {
$mpdf->PDFA = true;
$mpdf->PDFAauto = true;
} else {
if ($arguments['pdfx1a'] === true) {
$mpdf->PDFX = true;
$mpdf->PDFXauto = true;
}
}
/*
* Check if we should auto prompt to print the document on open
*/
if (isset($_GET['print'])) {
$mpdf->SetJS('this.print();');
}
/* load HTML block */
$mpdf->WriteHTML($html);
switch ($output) {
case 'download':
$mpdf->Output($filename, 'D');
exit;
break;
case 'view':
$mpdf->Output(time(), 'I');
exit;
break;
case 'save':
/*
* PDF wasn't writing to file with the F method - http://mpdf1.com/manual/index.php?tid=125
* Return as a string and write to file manually
*/
$pdf = $mpdf->Output('', 'S');
return $this->savePDF($pdf, $filename, $id);
//.........这里部分代码省略.........
示例12: createPdf
/**
* Create a PDF and export to defined path
* @param $dir str directory of the source file to convert
* @param $src str filename of the source file to convert
* @param $path str path to export the resultant PDF to
* @param $chapters array chapters to convert into a single PDF
* @param $journalId int Id of the journal(imprint)
* @param $args array arguments for the conversion (e.g. Description, cover image, etc)
* @param $coverPath str path to export the front cover artwork to
*/
function createPdf($dir = null, $src, $path, $chapters = array(), $journalId, $args = array(), $coverPath)
{
$mpdf = new mPDF('utf-8');
$mpdf->useOddEven = 1;
$htmlEncode = array('title', 'author');
foreach ($htmlEncode as $encode) {
$args[$encode] = htmlentities($args[$encode], ENT_QUOTES, "UTF-8");
}
isset($args['title']) ? $mpdf->SetTitle($args['title']) : $mpdf->SetTitle("No Title");
isset($args['description']) ? $mpdf->SetSubject($args['description']) : $mpdf->SetSubject("No description");
isset($args['author']) ? $mpdf->SetCreator($args['author']) : $mpdf->SetCreator("No author");
$CBPPlatformDao =& DAORegistry::getDAO('CBPPlatformDAO');
$imprintType = $CBPPlatformDao->getImprintType($journalId);
$stylesheet = $CBPPlatformDao->getImprintStylesheet($journalId);
$stylesheetContents = file_get_contents($this->stylesheetDir . "{$stylesheet}.css");
$mpdf->WriteHTML($stylesheetContents, 1);
$mpdf->WriteHTML($this->contentStart . '
<htmlpagefooter name="myFooter1" style="display:none">
<table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 8pt;
color: #000000; font-weight: bold; font-style: italic;"><tr>
<td width="33%" style="text-align: right; ">{PAGENO}</td>
</tr></table>
</htmlpagefooter>
<htmlpagefooter name="myFooter2" style="display:none">
<table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 8pt;
color: #000000; font-weight: bold; font-style: italic;"><tr>
<td width="33%"><span style="font-weight: bold; font-style: italic;">{PAGENO}</span></td>
</tr></table>
</htmlpagefooter>');
$imagesize = getimagesize($args['cover']);
if (substr($imagesize[1] / $imagesize[0], 0, strpos($imagesize[1] / $imagesize[0], '.') + 1 + 2) == 1.41 || substr($imagesize[1] / $imagesize[0], 0, strpos($imagesize[1] / $imagesize[0], '.') + 1 + 2) == 1.53) {
$pdfContent .= '<div style="position: absolute; left:0; right: 0; top: 0; bottom: 0;"><img src="' . $args['cover'] . '" id="cover" /></div>';
} else {
$pdfContent .= "<div style='margin: 0 auto; width: 80%; text-align: center;'>";
if (isset($args['title'])) {
$pdfContent .= "<h1>" . $args['title'] . "</h1>";
}
if (isset($args['cover'])) {
$pdfContent .= "<img src=\"" . $args['cover'] . "\" >";
} else {
$pdfContent .= "<br/>";
}
if (isset($args['author'])) {
$pdfContent .= "<h2>" . $args['author'] . "</h2>";
}
$pdfContent .= "</div>";
}
$mpdf->WriteHTML($pdfContent);
$mpdf->AddPage('', '', '', '', 'Off');
$copyrightStatement = $CBPPlatformDao->getJournalCopyrightStatement($journalId);
if (!empty($copyrightStatement)) {
$copyrightStatement = reset($copyrightStatement);
$mpdf->AddPage('', '', '', '', 'Off');
$innerPageConent = "<div style='width: 90%; text-align: center; margin: 0 auto;'><p>" . $copyrightStatement . "</p></div>";
$mpdf->WriteHTML($innerPageConent);
}
if (!empty($chapters)) {
$mpdf->TOCpagebreakByArray(array('TOCusePaging' => true, 'TOCuseLinking' => true, 'toc_preHTML' => '<h1>Table of Contents</h1>', 'toc_postHTML' => '', 'resetpagenum' => 1, 'suppress' => 'true'));
$chapterCount = 0;
$authorBiographies = 0;
foreach ($chapters as $chapter) {
if (!isset($chapter['type']) && $chapter['type'] != "supp") {
$chapterCount++;
} else {
if ($chapter['desc'] == "Author Biography") {
$authorBiographies++;
}
$suppChapters = true;
}
}
for ($i = 0; $i < count($chapters); $i++) {
$htmlEncode = array('name', 'author');
foreach ($htmlEncode as $encode) {
$chapters[$i][$encode] = htmlentities($chapters[$i][$encode], ENT_QUOTES, "UTF-8");
}
$document = new TransformDoc();
$document->setStrFile($chapters[$i]['src'], $chapters[$i]['dir']);
$document->generateXHTML();
//problem, here
$document->validatorXHTML();
if ($chapterCount == 1) {
$contentPreg = $this->stripTagsAddChapters($document->getStrXHTML());
$contentPreg = ltrim($contentPreg);
if (substr($contentPreg, 0, 13) == "<pagebreak />") {
$contentPreg = substr_replace($contentPreg, '', 0, 13);
}
$mpdf->addPage('', '', '', '', 'On');
$mpdf->PageNumSubstitutions[] = array('from' => $mpdf->page + 1, 'reset' => 1, 'type' => '1', 'suppress' => 'off');
$mpdf->WriteHTML("<div class='content'>", 2);
$mpdf->WriteHTML($contentPreg, 2);
//.........这里部分代码省略.........
示例13: setCreator
public function setCreator($strCreator)
{
$this->objPdf->SetCreator($strCreator);
}
示例14: setMetaCreator
/**
* Set PDF Meta Creator.
*
* @param string $str The page creator
*
* @return PdfInterface The current instance
*/
public function setMetaCreator(string $str) : PdfInterface
{
$this->setProperty('metaCreator', $str);
$this->mpdf->SetCreator($this->metaCreator);
return $this;
}
示例15: 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();
}
$this->setOrientation($orientation);
// Override Page Orientation
if (!is_null($this->getOrientation())) {
$orientation = $this->getOrientation() == PHPExcel_Worksheet_PageSetup::ORIENTATION_DEFAULT ? PHPExcel_Worksheet_PageSetup::ORIENTATION_PORTRAIT : $this->getOrientation();
}
$orientation = strtoupper($orientation);
// Override Paper Size
if (!is_null($this->getPaperSize())) {
$printPaperSize = $this->getPaperSize();
}
if (isset(self::$_paperSizes[$printPaperSize])) {
$paperSize = self::$_paperSizes[$printPaperSize];
}
// Create PDF
$pdf = new mPDF();
$ortmp = $orientation;
$pdf->_setPageSize(strtoupper($paperSize), $ortmp);
$pdf->DefOrientation = $orientation;
$pdf->AddPage($orientation);
// 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());
$pdf->WriteHTML($this->generateHTMLHeader(FALSE) . $this->generateSheetData() . $this->generateHTMLFooter());
// Write to file
fwrite($fileHandle, $pdf->Output('', 'S'));
parent::restoreStateAfterSave($fileHandle);
}