本文整理汇总了PHP中FPDI::setPrintHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP FPDI::setPrintHeader方法的具体用法?PHP FPDI::setPrintHeader怎么用?PHP FPDI::setPrintHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPDI
的用法示例。
在下文中一共展示了FPDI::setPrintHeader方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: listAction
public function listAction()
{
$receipt = new \FPDI();
// PDFの余白(上左右)を設定
$receipt->SetMargins(0, 0, 0);
// ヘッダーの出力を無効化
$receipt->setPrintHeader(false);
// フッターの出力を無効化
$receipt->setPrintFooter(false);
// フォントを登録
$fontPathRegular = $this->getLibPath() . '/tcpdf/fonts/migmix-2p-regular.ttf';
// $regularFont = $receipt->addTTFfont($fontPathRegular, '', '', 32);
$font = new TCPDF_FONTS();
$regularFont = $font->addTTFfont($fontPathRegular);
$fontPathBold = $this->getLibPath() . '/tcpdf/fonts/migmix-2p-bold.ttf';
// $boldFont = $receipt->addTTFfont($fontPathBold, '', '', 32);
$font = new TCPDF_FONTS();
$boldFont = $font->addTTFfont($fontPathBold);
// ページを追加
$receipt->AddPage();
// テンプレートを読み込み
// $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/receipt.pdf');
// $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/template.pdf');
// $receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/w01_1.pdf');
$receipt->setSourceFile($this->getLibPath() . '/tcpdf/tpl/senijiten.pdf');
// 読み込んだPDFの1ページ目のインデックスを取得
$tplIdx = $receipt->importPage(1);
// 読み込んだPDFの1ページ目をテンプレートとして使用
$receipt->useTemplate($tplIdx, null, null, null, null, true);
// 書き込む文字列のフォントを指定
$receipt->SetFont($regularFont, '', 11);
// 書き込む文字列の文字色を指定
$receipt->SetTextColor(0, 0, 255);
// X : 42mm / Y : 108mm の位置に
$receipt->SetXY(59, 248);
// 文字列を書き込む
$receipt->Write(0, isset($_POST['name']) ? $_POST['name'] . 'さん' : '名無しさん');
/* $response = new Response(
// Output関数の第一引数にはファイル名、第二引数には出力タイプを指定する
// 今回は文字列で返してほしいので、ファイル名はnull、出力タイプは S = String を選択する
$receipt->Output(null, 'S'),
200,
array('content-type' => 'application/pdf')
);
// レスポンスヘッダーにContent-Dispositionをセットし、ファイル名をreceipt.pdfに指定
$response->headers->set('Content-Disposition', 'attachment; filename="receipt.pdf"');
return $response;
*/
// $receipt->
$receipt->output('newpdf.pdf', 'I');
}
示例2: merge
/**
* Merges your provided PDFs and outputs to specified location.
* @param $outputmode
* @param $outputname
* @return PDF
*/
public function merge($outputmode = 'browser', $outputpath = 'newfile.pdf')
{
if (!isset($this->_files) || !is_array($this->_files)) {
throw new exception("No PDFs to merge.");
}
$fpdi = new FPDI();
$fpdi->setPrintHeader(FALSE);
$fpdi->setPrintFooter(FALSE);
//merger operations
foreach ($this->_files as $file) {
$filename = $file[0];
$filepages = $file[1];
$count = $fpdi->setSourceFile($filename);
//add the pages
if ($filepages == 'all') {
for ($i = 1; $i <= $count; $i++) {
$template = $fpdi->importPage($i);
$size = $fpdi->getTemplateSize($template);
$orientation = $size['w'] <= $size['h'] ? 'P' : 'L';
$fpdi->AddPage($orientation, array($size['w'], $size['h']));
$fpdi->useTemplate($template);
}
} else {
foreach ($filepages as $page) {
if (!($template = $fpdi->importPage($page))) {
throw new exception("Could not load page '{$page}' in PDF '{$filename}'. Check that the page exists.");
}
$size = $fpdi->getTemplateSize($template);
$orientation = $size['w'] <= $size['h'] ? 'P' : 'L';
$fpdi->AddPage($orientation, array($size['w'], $size['h']));
$fpdi->useTemplate($template);
}
}
}
//output operations
$mode = $this->_switchmode($outputmode);
if ($mode == 'S') {
return $fpdi->Output($outputpath, 'S');
} else {
if ($fpdi->Output($outputpath, $mode) == '') {
return true;
} else {
throw new exception("Error outputting PDF to '{$outputmode}'.");
return false;
}
}
}
示例3: uuid
$tif_files[] = $dir_fax_temp . '/' . $fax_name . '.tif';
}
//if
}
//foreach
// unique id for this fax
$fax_instance_uuid = uuid();
//generate cover page, merge with pdf
if ($fax_subject != '' || $fax_message != '') {
//load pdf libraries
require_once "resources/tcpdf/tcpdf.php";
require_once "resources/fpdi/fpdi.php";
// initialize pdf
$pdf = new FPDI('P', 'in');
$pdf->SetAutoPageBreak(false);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetMargins(0, 0, 0, true);
if (strlen($fax_cover_font) > 0) {
if (substr($fax_cover_font, -4) == '.ttf') {
$pdf_font = TCPDF_FONTS::addTTFfont($fax_cover_font);
} else {
$pdf_font = $fax_cover_font;
}
}
if (!$pdf_font) {
$pdf_font = 'times';
}
//add blank page
$pdf->AddPage('P', array($page_width, $page_height));
// content offset, if necessary
示例4: emarking_create_quiz_pdf
//.........这里部分代码省略.........
$search[] = 'src="' . $image . '"';
$replacehtml = ' src="' . $filename . '"';
$replacehtmlxweb = ' src="' . $image . '"';
// Si el html de la misma contiene ancho o alto, se deja tal cual
$imghtml = $imageshtml[$idx];
if (substr_count($imghtml, "width") + substr_count($imghtml, "height") == 0) {
$width = $imageinfo[0];
$height = $imageinfo[1];
$ratio = floatval(10) / floatval($height);
$height = 10;
$width = (int) ($ratio * floatval($width));
$sizehtml = 'width="' . $width . '" height="' . $height . '"';
$replacehtml = $sizehtml . ' ' . $replacehtml;
$replacehtmlxweb = $sizehtml . ' ' . $replacehtmlxweb;
}
$replace[] = $replacehtml;
$replaceweb[] = $replacehtmlxweb;
$imagesize[] = $imageinfo;
}
$idx++;
}
if ($debug) {
foreach ($fullhtml as $uid => $questions) {
$index = 0;
foreach ($questions as $question) {
echo str_replace($search, $replaceweb, $fullhtml[$uid][$index]);
$index++;
}
}
return;
}
// Now we create the pdf file with the modified html
$doc = new FPDI();
$doc->setPrintHeader(false);
$doc->setPrintFooter(false);
$doc->SetFont('times', '', 12);
// set margins
$doc->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$doc->SetHeaderMargin(250);
$doc->SetFooterMargin(PDF_MARGIN_FOOTER);
if ($pbar) {
$progressbar->update_full(100, get_string('finished', 'mod_emarking'));
echo $OUTPUT->heading(get_string('creatingpdffile', 'mod_emarking'), 3);
$progressbar = new progress_bar();
$progressbar->create();
}
$current = 0;
foreach ($fullhtml as $uid => $questions) {
$current++;
$stinfo = $DB->get_record('user', array('id' => $uid));
$stinfo->name = $stinfo->firstname . ' ' . $stinfo->lastname;
$stinfo->picture = emarking_get_student_picture($stinfo, $userimgdir);
$stinfo->idnumber = $uid . '-' . $attemptids[$uid];
if ($pbar) {
$progressbar->update($current, count($fullhtml), $stinfo->name);
}
$groups = groups_get_user_groups($course->id, $uid);
if ($groups && isset($groups[0][0]) && ($group = $DB->get_record('groups', array('id' => $groups[0][0])))) {
$stinfo->group = $group->name;
} else {
$stinfo->group = '';
}
emarking_add_answer_sheet($doc, $filedir, $stinfo, $logofilepath, null, $fileimg, $course, $quizobj->get_quiz_name(), $numanswers[$uid], $attemptids[$uid]);
// Una vez agregada la página de respuestas, si es todo lo que hay que hacer saltar al siguiente
if ($answersheetsonly) {
continue;
示例5: download_tag
public function download_tag()
{
$r1 = Input::has('r1') ? Input::get('r1') : 'Mr Sam Sample';
$r2 = Input::has('r2') ? Input::get('r2') : 'Sample Street';
$r3 = Input::has('r3') ? Input::get('r3') : 'Sampletown VIC 3000';
$r4 = Input::has('r4') ? Input::get('r4') : 'phone +61 414 141 414';
if ($user = Auth::user()) {
$member = Member::where('user_id', '=', $user->id)->first();
$r1 = $member->firstname . ' ' . $member->lastname;
$r2 = $member->address;
$r3 = $member->suburb . ' ' . $member->state . ' ' . $member->postcode;
$r4 = 'phone ' . $member->phone;
}
$pdf = new FPDI('L');
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->AddPage();
$pdf->setSourceFile(realpath(dirname(__FILE__)) . '/../../public/assets/pdf/luggage_tags.pdf');
$pdf->SetTextColor(0, 0, 0);
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx);
$pdf->SetFont('museosansrounded1000');
$pdf->SetXY(121, 40);
$pdf->Write(20, $r1);
$pdf->SetXY(121, 45);
$pdf->Write(20, $r2);
$pdf->SetXY(121, 50);
$pdf->Write(20, $r3);
$pdf->SetXY(121, 55);
$pdf->Write(20, $r4);
$pdf->Output('luggage-tag.pdf');
}
示例6: generatepdfAction
public function generatepdfAction($id)
{
$width = 320;
$height = 450;
$pdfmerge = $this->getDoctrine()->getRepository('PrintBundle:Pdfmerge')->find($id);
$elementwidth = $pdfmerge->getWidth();
$elementheight = $pdfmerge->getHeight();
$marge = $pdfmerge->getMarge();
$singlewidth = $elementwidth + $marge;
$singleheight = $elementheight + $marge;
// test occupation
$test1 = (int) ($height / $singleheight) * (int) ($width / $singlewidth);
$test2 = (int) ($width / $singleheight) * (int) ($height / $singlewidth);
if ($test1 >= $test2) {
$width = 320;
$height = 450;
$orientation = "P";
} else {
$width = 450;
$height = 320;
$orientation = "L";
}
// calculate margin
$nbrX = (int) ($width / $singlewidth);
$nbrY = (int) ($height / $singleheight);
$marginleft = ($width - $nbrX * $singlewidth) / 2;
$margintop = ($height - $nbrY * $singleheight) / 2;
//print_r(array($orientation, $marginleft, $margintop));
$custom_layout = array($width, $height);
$pdf = new \FPDI($orientation, 'mm', 'SRA3', true, 'UTF-8', false);
$pdf->setPageOrientation($orientation);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetMargins($marginleft, 40, $marginleft);
$pdf->SetAutoPageBreak(true, 40);
$pdf->setFontSubsetting(false);
// add a page
$pdf->AddPage($orientation);
$i = 0;
$path = $this->get('kernel')->getRootDir() . '/../web/';
$toaddheight = $margintop;
$face = array();
$j = 0;
foreach ($pdfmerge->getPdflist() as $list) {
for ($k = 0; $k < $list->getRepeat(); $k++) {
if ($i == $nbrX) {
$i = 0;
$j++;
$toaddheight += $singleheight;
}
$toaddwidth = $i * $singlewidth + $marginleft;
$face[$toaddheight][$toaddwidth] = $list->getFile();
$i++;
}
}
$reverse = array();
foreach ($face as $y => $value) {
foreach ($value as $x => $fichier) {
$file = $path . $fichier;
$pdf->setSourceFile($file);
$_tplIdx = $pdf->importPage(1);
$size = $pdf->useTemplate($_tplIdx, $x, $y, 85);
$reverse[$y][$x] = $fichier;
}
}
//echo "<pre>";print_r($face);exit;
$this->repert($pdf, $face, $marginleft, $margintop, $singlewidth, $singleheight, $height, $width);
if ($pdfmerge->getNbpage() == 2) {
$pdf->AddPage($orientation);
foreach ($reverse as $y => $value) {
foreach ($value as $x => $fichier) {
$file = $path . $fichier;
$pdf->setSourceFile($file);
$_tplIdx = $pdf->importPage(2);
$size = $pdf->useTemplate($_tplIdx, $x, $y, 85);
$reverse[$y][$x] = $fichier;
}
}
$this->repert($pdf, $face, $marginleft, $margintop, $singlewidth, $singleheight, $height, $width);
}
$pdf->Output("aaa.pdf", 'I');
}