本文整理汇总了PHP中FPDI::SetMargins方法的典型用法代码示例。如果您正苦于以下问题:PHP FPDI::SetMargins方法的具体用法?PHP FPDI::SetMargins怎么用?PHP FPDI::SetMargins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FPDI
的用法示例。
在下文中一共展示了FPDI::SetMargins方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: runProcessStep
public function runProcessStep($dokument)
{
$file = $dokument->getLatestRevision()->getFile();
$extension = array_pop(explode(".", $file->getExportFilename()));
#$this->ziphandler->addFile($file->getAbsoluteFilename(), $file->getExportFilename());
// Print Metainfo for PDFs
if (strtolower($extension) == "pdf") {
try {
$fpdf = new FPDI();
$pagecount = $fpdf->setSourceFile($file->getAbsoluteFilename());
$fpdf->SetMargins(0, 0, 0);
$fpdf->SetFont('Courier', '', 8);
$fpdf->SetTextColor(0, 0, 0);
$documentSize = null;
for ($i = 0; $i < $pagecount; $i++) {
$string = $dokument->getLatestRevision()->getIdentifier() . " (Seite " . ($i + 1) . " von " . $pagecount . ", Revision " . $dokument->getLatestRevision()->getRevisionID() . ")";
$fpdf->AddPage();
$tpl = $fpdf->importPage($i + 1);
$size = $fpdf->getTemplateSize($tpl);
// First Page defines documentSize
if ($documentSize === null) {
$documentSize = $size;
}
// Center Template on Document
$fpdf->useTemplate($tpl, intval(($documentSize["w"] - $size["w"]) / 2), intval(($documentSize["h"] - $size["h"]) / 2), 0, 0, true);
$fpdf->Text(intval($documentSize["w"]) - 10 - $fpdf->GetStringWidth($string), 5, $string);
}
$this->ziphandler->addFromString($dokument->getLatestRevision()->getIdentifier() . "." . $extension, $fpdf->Output("", "S"));
} catch (Exception $e) {
$this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension);
}
} else {
$this->ziphandler->addFile($file->getAbsoluteFilename(), $dokument->getLatestRevision()->getIdentifier() . "." . $extension);
}
}
示例2: 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');
}
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$id = $input->getArgument('id');
$pdffile = $input->getArgument('pdf');
$em = $this->getContainer()->get('doctrine');
$tab = $this->csv($pdffile);
$template = $em->getRepository('PrintBundle:Template')->find($id);
$path = $this->getContainer()->get('kernel')->getRootDir() . '/../web/uploads/pdf/' . $template->getPdffile();
$width = $template->getWidth();
$height = $template->getHeight();
$orientation = $height > $width ? 'P' : 'L';
$custom_layout = array($width, $height);
$i = 1;
foreach ($tab as $key => $value) {
$pdf = new \FPDI($orientation, 'mm', $custom_layout, true, 'UTF-8', false);
$pdf->setPageOrientation($orientation);
$pdf->SetMargins(PDF_MARGIN_LEFT, 40, PDF_MARGIN_RIGHT);
$pdf->SetAutoPageBreak(true, 40);
$pdf->setFontSubsetting(false);
// add a page
$pdf->AddPage($orientation);
$pdf->setSourceFile($path);
$_tplIdx = $pdf->importPage(1);
$size = $pdf->useTemplate($_tplIdx, 0, 0, $width, true);
foreach ($template->getChildactivity() as $opt) {
$pdf->SetXY($opt->getX(), $opt->getY());
$pdf->SetFont($opt->getFont(), '', $opt->getFontsize() * 2);
// echo $opt->getFontsize()."\n";
$pdf->Cell($opt->getWidth(), $opt->getHeight(), $value[$opt->getName()]);
}
//$pdf->Cell(0, $size['h'], 'TCPDF and FPDI');
// echo $template->getId();
$pdf->Output($this->getContainer()->get('kernel')->getRootDir() . '/../web/folder/pdf' . $template->getId() . "-{$i}.pdf", 'F');
$i++;
}
}
示例4: uuid
//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
$x = 0;
$y = 0;
示例5: FPDI
$page_height = 8.5;
//in
break;
case 'letter':
default:
$page_width = 11;
//in
$page_height = 8.5;
//in
}
// initialize pdf
$pdf = new FPDI('L', 'in');
$pdf->SetAutoPageBreak(false);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetMargins(0.5, 0.5, 0.5, true);
//set default font
$pdf->SetFont('helvetica', '', 7);
//add new page
$pdf->AddPage('L', array($page_width, $page_height));
$chunk = 0;
//write the table column headers
$data_start = '<table cellpadding="0" cellspacing="0" border="0" width="100%">';
$data_end = '</table>';
$data_head = '<tr>';
$data_head .= '<td width="7.5%"><b>' . $text['label-direction'] . '</b></td>';
$data_head .= '<td width="15%"><b>' . $text['label-cid-name'] . '</b></td>';
$data_head .= '<td width="8.5%"><b>' . $text['label-cid-number'] . '</b></td>';
$data_head .= '<td width="11%"><b>' . $text['label-destination'] . '</b></td>';
$data_head .= '<td width="11%"><b>' . $text['label-start'] . '</b></td>';
$data_head .= '<td width="4%" align="right"><b>' . $text['label-tta'] . '</b></td>';
示例6: save_design
public function save_design()
{
if ($this->input->post('mode') == 'edit') {
$this->db->delete('designs', array('id' => $this->input->post('design_id')));
}
$faceMacket = str_replace('http://klever.media/', '', $this->input->post('faceMacket'));
$backMacket = str_replace('http://klever.media/', '', $this->input->post('backMacket'));
$face = $this->input->post('face');
$back = $this->input->post('back');
// get all fonts
$query = $this->db->get('fonts');
$fonts = array();
foreach ($query->result() as $font) {
$fonts[$font->family] = $font->source;
}
// generate pdf face template name and preview name
$face_pdf = 'uploads/redactor/face_' . md5(microtime(true)) . '.pdf';
$face_preview = 'uploads/redactor/face_' . md5(microtime(true)) . '.jpg';
// convert face image to pdf
$img = new Imagick($faceMacket);
$img->setresolution(300, 300);
$img->setcolorspace(Imagick::COLORSPACE_CMYK);
$img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
$img->setimageformat('pdf');
$img->writeimage($face_pdf);
// include TCPDF ana FPDI
include_once APPPATH . 'libraries/tcpdf/tcpdf.php';
include_once APPPATH . 'libraries/tcpdf/fpdi.php';
include_once APPPATH . 'libraries/tcpdf/include/tcpdf_fonts.php';
$fontMaker = new TCPDF_FONTS();
// создаём лист
$pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
$pdf->SetMargins(0, 0, 0, true);
$pdf->AddPage('L');
// загрузим ранее сохранённый шаблон
$pdf->setSourceFile($face_pdf);
$pdf->SetMargins(0, 0, 0, true);
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, null, null, 0, 0, true);
// установим опции для pdf
$pdf->setCellHeightRatio(1);
$pdf->setCellPaddings(0, 0, 0, 0);
$pdf->setCellMargins(0, 0, 0, 0);
$pdf->SetAutoPageBreak(false, 0);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
if (!empty($face)) {
// отрисуем сначала изображения лица
foreach ($face as $item) {
if ($item['type'] == 'image') {
$pdf->Image($_SERVER['DOCUMENT_ROOT'] . '/' . str_replace('http://klever.media/', '', $item['content']), $this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $this->px_to_mm($item['width']), '', '', '', '', false, 300);
}
}
// потом текст на лице
foreach ($face as $item) {
if ($item['type'] == 'text') {
$cmyk = $this->rgbToCmyk($item['color']);
$pdf->SetTextColor($cmyk['c'] * 100, $cmyk['m'] * 100, $cmyk['y'] * 100, $cmyk['k'] * 100);
// set font
$tcpdfFont = $fontMaker->addTTFfont(realpath('fonts/redactor/' . $fonts[$item['font']]));
$pdf->SetFont($tcpdfFont, '', $item['size'] / 2, '', 'false');
$pdf->Text($this->px_to_mm($item['left']), $this->px_to_mm($item['top']), $item['content'], false, false, true, 0, 0, 'L', false, '', 0, false, 'T', 'L', false);
}
}
}
// сохраним пдф лица
$pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf, 'F');
// сделаем превью для пользователя
$im = new Imagick();
$im->setResolution(300, 300);
$im->readimage($face_pdf . '[0]');
$im->flattenimages();
$im->setImageFormat('jpg');
$im->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
$im->writeImage($face_preview);
$im->clear();
$im->destroy();
//exec('$ convert ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_pdf . ' ' . $_SERVER['DOCUMENT_ROOT'] . '/' . $face_preview);
// есть ли оборот
if (!empty($backMacket)) {
// generate pdf back template name and preview name
$back_pdf = 'uploads/redactor/back_' . md5(microtime(true)) . '.pdf';
$back_preview = 'uploads/redactor/back_' . md5(microtime(true)) . '.jpg';
// convert back image to pdf
$img = new Imagick($backMacket);
$img->setresolution(300, 300);
$img->setcolorspace(Imagick::COLORSPACE_CMYK);
$img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
$img->setimageformat('pdf');
$img->writeimage($back_pdf);
// создаём лист
$pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
$pdf->AddPage('L');
// загрузим ранее сохранённый шаблон
$pdf->setSourceFile($_SERVER['DOCUMENT_ROOT'] . '/' . $back_pdf);
$pdf->SetMargins(0, 0, 0, true);
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, null, null, 0, 0, true);
// установим опции для pdf
$pdf->SetMargins(0, 0, 0, true);
//.........这里部分代码省略.........
示例7: SetMargins
function SetMargins()
{
parent::SetMargins($this->leftmargin, $this->topmargin, $this->rightmargin);
}
示例8: 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;
}
$doc->AddPage();
emarking_draw_header($doc, $stinfo, $quizobj->get_quiz_name(), 2, $fileimg, $logofilepath, $course, null, false, 0);
$doc->SetFont('times', '', 12);
$doc->SetAutoPageBreak(true);
$doc->SetXY(PDF_MARGIN_LEFT, 40);
$index = 0;
foreach ($questions as $question) {
$prevy = $doc->getY();
$fullhtml[$uid][$index] = str_replace($search, $replace, $fullhtml[$uid][$index]);
$doc->writeHTML($fullhtml[$uid][$index]);
$y = $doc->getY();
$fmargin = $doc->getFooterMargin();
$height = $doc->getPageHeight();
$spaceleft = $height - $fmargin - $y;
$questionsize = $y - $prevy;
if ($spaceleft < 70) {
$doc->AddPage();
}
$index++;
}
}
if ($pbar) {
$progressbar->update_full(100, get_string('finished', 'mod_emarking'));
}
$qid = $quizobj->get_quizid();
$pdfquizfilename = 'quiz-' . $qid . '-' . random_string() . '.pdf';
$fs = get_file_storage();
$filerecord = array('component' => 'mod_emarking', 'filearea' => 'pdfquiz', 'contextid' => $context->id, 'itemid' => $quizobj->get_quizid(), 'filepath' => '/', 'filename' => $pdfquizfilename);
$doc->Output($filedir . '/' . $pdfquizfilename, 'F');
$file = $fs->create_file_from_pathname($filerecord, $filedir . '/' . $pdfquizfilename);
$downloadurl = moodle_url::make_file_url("{$CFG->wwwroot}/pluginfile.php", "/{$context->id}/mod_emarking/pdfquiz/{$qid}/{$pdfquizfilename}", null, true);
return $downloadurl;
}
示例9: unserialize
$calc_result = unserialize($contract_data['calc_result']);
require_once 'fpdf17/fpdf.php';
require_once 'fpdi/fpdi.php';
//Вносим необходимые данные в полис и отдаём в формате pdf
$pdf = new FPDI();
$pdf->AddFont('ArialMT', '', 'arial_cyr.php');
$pdf->AddFont('Arial-BoldMT', '', 'arialbold.php');
$pdf->AddPage();
// $pdf->setSourceFile('blank/bso3.pdf');
// // Указываем номер импортируемой страницы
// $tplIdx = $pdf->importPage(1);
// //указываем размер страницы
// //$pdf->useTemplate($tplIdx, 0, 0, 210, 297, true);
// $pdf->useTemplate($tplIdx, 0, 0, 210, 297, true);
//Ставим поля по нулям
$pdf->SetMargins(0, 0, 0, 0);
$pdf->SetAutoPageBreak(false);
//указываем шрифт и размер
$pdf->SetFont('Arial-BoldMT', '', '13');
//указываем цвет текста
$pdf->SetTextColor(0, 0, 0);
////////////////////////////////////////////////////////Добавляем данные в полис//////////////////////////////
//Время начала действия договора
$pdf->SetXY(120.8, 42.5);
$pdf->Write(0, $contract_data['start_time'][0]);
$pdf->SetXY(125.8, 42.5);
$pdf->Write(0, $contract_data['start_time'][1]);
$pdf->SetXY(137.3, 42.5);
$pdf->Write(0, $contract_data['start_time'][3]);
$pdf->SetXY(142.3, 42.5);
$pdf->Write(0, $contract_data['start_time'][4]);
示例10: 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');
}
示例11: FlyerRendering
//.........这里部分代码省略.........
$kontaktFooterPositionX = $wLinks;
//mm
$kontaktFooterPositionY = 95.40000000000001;
//mm
$kontaktFooterWidth = $wMitte;
//mm
$kontaktFooterFontSize = 10.9;
//pt
echo "\n";
// Output-Dasteiname zusammenbauen
$outputFile = $outputPostfix . "-" . $inputFile;
// initiate FPDI
$pdf = new FPDI();
echo "Input: {$inputFile}\n";
$pageCount = $pdf->setSourceFile($inputFile);
// Importiere Vorder- und Rueckseite
$Vorderseite = $pdf->ImportPage(1);
$Rueckseite = $pdf->ImportPage(2);
// Seitenabmessungen holen
$size = $pdf->getTemplateSize($Vorderseite);
$dokumentBreite = round($size['w'], 2);
$dokumentHoehe = round($size['h'], 2);
echo "Dokumenten Breite: {$dokumentBreite} mm\n";
echo "Dokumenten Hoehe: {$dokumentHoehe} mm\n";
echo "Anschnitt: {$anschnitt} mm\n";
// Vorderseite uebernehmen
// Anfang eines bloeden Hacks wegen des FooterZeilen-Textes.
// Der Footertext laesst sich nur einfügen, wenn die Seite eine A4 Seite ist.
// Keine Ahnung warum!
$pdf->AddPage('L');
$tplVorderseite = $pdf->importPage(1);
$pdf->useTemplate($tplVorderseite);
//Margin ist wegen der Rand-Platzierung des Community Names wichtig.
$pdf->SetMargins(0, 0, 0);
// erstmal alle Fonts laden
echo "Lade Fonts...\n";
$pdf->AddFont('lato-bold');
$pdf->AddFont('lato-regular');
$pdf->AddFont('alternategothic');
// Rendern Titel Text
echo "Verarbeite Titel Text...\n";
$pdf->SetFont('lato-bold');
$pdf->SetFontSize($kontaktTitelFontSize);
$pdf->SetTextColor(0, 0, 0);
//schwarz
$pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktTitelPositionY + $anschnitt);
$pdf->Write(0, iconv('UTF-8', 'windows-1252', $kontaktTitelText));
// Rendern Info Text
echo "Verarbeite Info Text...\n";
$pdf->SetTextColor(0, 0, 0);
//schwarz
$pdf->SetFontSize($kontaktInfoFontSize);
foreach ($kontaktInfoTexte as $a) {
$pdf->SetFont('lato-bold');
$pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt);
$pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[0]));
$pdf->SetFont('lato-regular');
$pdf->SetXY($kontaktInfoTextPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt);
$pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[1]));
$kontaktInfoPositionY = $kontaktInfoPositionY + $kontaktInfoZeilenOffsetY;
}
// Rendern Community Logo
echo "Verarbeite Logo...\n";
$pdf->Image($kontaktLogoDateiName, $kontaktLogoPositionX + $anschnitt, $kontaktLogoPositionY + $anschnitt, $kontaktLogoWidth, 0);
// Rendern Fusszeilen Text
echo "Verarbeite Fusszeile...\n";
示例12: generatepdfAction
public function generatepdfAction(command $commande)
{
$request = $this->get('request');
$tools = $this->get('tools.utils');
$session = $request->getSession();
if ($session->has('tpl')) {
$tpl = $commande->getToprint();
$pdffile = "";
foreach ($tpl as $key => $elemnt) {
foreach ($elemnt as $val) {
$prod = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($val['id']);
$template = $prod->getTpl();
$tplpdf = str_replace("../", "", $template->getPdf());
$pdffile = $this->get('kernel')->getRootDir() . '/../web/' . $tplpdf;
}
}
$custom_layout = array(85, 55);
$orientation = 'L';
$pdf = new \FPDI($orientation, 'mm', $custom_layout, true, 'UTF-8', false);
$pdf->setPageOrientation($orientation);
$pdf->SetMargins(0, 0, 0);
$pdf->SetAutoPageBreak(true, 0);
$pdf->setFontSubsetting(false);
$pdf->AddPage($orientation);
// echo "<pre>";print_r($pdf->getMargins());exit;
$pdf->setSourceFile($pdffile);
$_tplIdx = $pdf->importPage(1);
$size = $pdf->useTemplate($_tplIdx, 0, 0, 85, 55, true);
$idd = "";
$i = 0;
$oldx = 0;
$oldy = 0;
foreach ($elemnt as $value) {
//if($i==0)
if ($idd != $value['id'] && $value['value'] != "") {
$pdf->SetPageMark();
if (substr($value['value'], 0, 4) != "/tmp") {
//$tools->dump($value);
$align = strtoupper(substr($value['align'], 0, 1));
$color = $this->hex2rgb($value['color']);
$pdf->SetTextColor($color[0], $color[1], $color[2]);
$param = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($value['id']);
$y2 = $param->getX1() / 5;
$x1 = $param->getY1() / 5;
//$x1 = 10;$y2 = 8;
$w = $param->getX2() / 5;
$h = $param->getY2() / 5;
$oldx = $x1;
$oldy = $y2;
$pdf->SetX($x1, false);
$pdf->SetY($y2, false);
//$pdf->SetXY($x1, $y2,true);
$pdf->SetFont(null, '', $param->getSize() * 0.6);
//$param->getPolice()
// echo $opt->getFontsize()."\n";
$pdf->Cell($w, $h, $value["value"], 0, 0, $align);
} else {
$param = $this->getDoctrine()->getRepository('MainFrontBundle:paramtpl')->find($value['id']);
$img = $this->getParameter('base_url') . $value['value'];
$pdf->Image($img, $param->getX1() / 4.5, $param->getY1() / 4.55, $param->getX2() / 4.55, $param->getY2() / 4.5, '', '', '', true);
}
}
$idd = $value['id'];
$i++;
}
//$pdf->Cell(0, $size['h'], 'TCPDF and FPDI');
// echo $template->getId();
$pdf->Output($this->get('kernel')->getRootDir() . '/../web/pdf.pdf');
}
return new Response("");
}
示例13: generatePDF
function generatePDF($id_invoice, $introduction_letter = false, $target = 'file', $docs = false)
{
if (!is_numeric($id_invoice)) {
error_log('$id_invoice not defined');
exit(1);
}
if (!defined('EURO')) {
define('EURO', chr(128));
}
$facture = Facture::getInfos($id_invoice);
foreach (array(LC_MESSAGES, LC_TIME, LC_MONETARY, LC_CTYPE) as $locale) {
setlocale($locale, $facture->language . ".UTF-8") or die("locale {$locale} language failed {$facture->language}");
}
bindtextdomain('webfinance', dirname(__FILE__) . '/../../lang') or die("Set gettext bindtextdomain language failed\n");
textdomain('webfinance') or die("Set gettext textdomain language failed\n");
$type_doc = $facture->type_doc;
if ($facture->language == 'en_US' and $facture->type_doc == 'facture') {
$type_doc = 'invoice';
}
if ($facture->language == 'en_US' and $facture->type_doc == 'devis') {
$type_doc = 'quote';
}
// Generate PDF filename
$filename = sys_get_temp_dir() . '/' . ucfirst($type_doc) . ' ' . preg_replace('/[^a-z0-9éàçùî\\._-]/i', ' ', $facture->num_facture . ' ' . $facture->nom_client) . '.pdf';
foreach ($facture as $n => $v) {
if (!is_array($v)) {
$facture->{$n} = preg_replace("/€/", "EUROSYMBOL", $facture->{$n});
// FPDF ne support pas l'UTF-8
$facture->{$n} = utf8_decode($facture->{$n});
$facture->{$n} = preg_replace("/EUROSYMBOL/", chr(128), $facture->{$n});
$facture->{$n} = preg_replace("/\\\\EUR\\{([0-9.,]+)\\}/", "\\1 " . chr(128), $facture->{$n});
}
}
$pdf = new FPDI('P', 'mm', 'A4');
// Address
$address = "{$facture->nom_client}\n";
for ($i = 0; $i < 3; $i++) {
$n = sprintf("addr%d", $i + 1);
if ($facture->{$n} != "") {
$address .= $facture->{$n} . "\n";
}
}
$address .= "{$facture->cp} {$facture->ville}\n{$facture->pays}";
//Get docs, if needed
if ($docs !== false) {
$pagecount = $pdf->SetSourceFile(dirname(__FILE__) . '/../admin/invoice_docs/docs_' . $facture->language . '.pdf');
for ($n = 1; $n <= $pagecount; $n++) {
$tplidx = $pdf->ImportPage($n, '/MediaBox');
$pdf->AddPage();
$pdf->UseTemplate($tplidx);
}
}
$pdf->SetMargins(10, 10, 10);
$pdf->SetDisplayMode('fullwidth');
$pdf->AddPage();
$prefs = new WebfinancePreferences();
// UTF8 to ISO
$prefs->prefs['societe']->invoice_top_line1 = preg_replace("/€/", "EUROSYMBOL", $prefs->prefs['societe']->invoice_top_line1);
// FPDF ne support pas l'UTF-8
$prefs->prefs['societe']->invoice_top_line1 = utf8_decode($prefs->prefs['societe']->invoice_top_line1);
$prefs->prefs['societe']->invoice_top_line1 = preg_replace("/EUROSYMBOL/", chr(128), $prefs->prefs['societe']->invoice_top_line1);
// Save the logo to a temp file since fpdf cannot read from a var
$tempfile_logo = tempnam(sys_get_temp_dir(), 'logo') . '.png';
$logo_tmp = fopen($tempfile_logo, "w");
fwrite($logo_tmp, $prefs->prefs['logo']);
fclose($logo_tmp);
// Logo
$pdf->Image($tempfile_logo, 90, 5, 25, 0, 'PNG');
// Display text headers
$pdf->SetFont('Arial', '', 5);
$logo_size = getimagesize($tempfile_logo);
$logo_height = $logo_size[1] * 25 / $logo_size[0];
$pdf->SetXY(10, $logo_height + 5);
$pdf->Cell(190, 5, $prefs->prefs['societe']->invoice_top_line1, 0, 0, "C");
$pdf->SetLineWidth(0.3);
$pdf->SetXY(10, $logo_height + 8);
$pdf->Cell(190, 5, utf8_decode($prefs->prefs['societe']->invoice_top_line2), "B", 0, "C");
// Address
$pdf->SetFont('Arial', 'B', 11);
$pdf->SetXY(115, 50);
$pdf->Cell(80, 5, $facture->nom_client, 0, 0);
$pdf->SetFont('Arial', '', 11);
$y = 54;
for ($i = 0; $i < 3; $i++) {
$n = sprintf("addr%d", $i + 1);
if ($facture->{$n} != "") {
$pdf->SetXY(115, $y);
$pdf->Cell(80, 5, $facture->{$n}, 0, 0);
$y += 5;
}
}
$pdf->SetXY(115, $y);
$pdf->Cell(80, 4, $facture->cp . " " . $facture->ville, 0, 0);
$pdf->SetXY(115, $y + 5);
$pdf->Cell(80, 4, $facture->pays, 0, 0);
// Donnees factures
$pdf->SetXY(10, 19 + $logo_height);
$pdf->SetFont('Arial', 'B', 14);
$pdf->Cell(60, 4, ucfirst($type_doc) . utf8_decode(_(' #')) . $facture->num_facture);
$pdf->SetFont('Arial', '', 9);
//.........这里部分代码省略.........
示例14: test
public function test()
{
// $rgb_arr = sscanf('rgb(243, 243, 243)', "rgb(%d, %d, %d)");
// print_r($this->rgbToCmyk($rgb_arr[0], $rgb_arr[1], $rgb_arr[2]));
// exit();
//
$img = new Imagick('test.jpg');
$img->resizeimage(1076, 720, Imagick::FILTER_LANCZOS, 1);
$img->setresolution(300, 300);
$img->setimageformat('pdf');
$img->writeimage('test.pdf');
include_once APPPATH . 'libraries/tcpdf/tcpdf.php';
include_once APPPATH . 'libraries/tcpdf/fpdi.php';
// создаём лист
$pdf = new FPDI('L', 'mm', array(91, 61), true, 'UTF-8', false);
$pdf->AddPage('L');
// загрузим ранее сохранённый шаблон
$pdf->setSourceFile('test.pdf');
$pdf->SetMargins(0, 0, 0, true);
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, null, null, 0, 0, true);
// установим опции для pdf
$pdf->SetMargins(0, 0, 0, true);
$pdf->setCellHeightRatio(1);
$pdf->setCellPaddings(0, 0, 0, 0);
$pdf->setCellMargins(1, 1, 1, 1);
$pdf->SetAutoPageBreak(false);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->Image('qwe.png', 30, 30, 20, '', '', '', '', false, 300);
$pdf->SetTextColor(0, 0, 0, 100);
$pdf->SetFont('helvetica', 'BI', 10, '', 'false');
$pdf->Text(12, 9, 'Black CMYK');
$pdf->Output($_SERVER['DOCUMENT_ROOT'] . '/uploads/fynal.pdf', 'F');
$im = new Imagick();
$im->setResolution(300, 300);
$im->readimage('uploads/fynal.pdf[0]');
$im->setImageFormat('jpeg');
$im->resizeimage(538, 360, Imagick::FILTER_LANCZOS, 1);
$im->writeImage('uploads/fynal.jpg');
$im->clear();
$im->destroy();
// include_once APPPATH . 'libraries/drawer.php';
//
// $drawer = new Drawer();
// $drawer->init();
// $drawer->setLayout();
// $drawer->setBackground('test.jpg');
// $drawer->drawImage('test.jpg', 10, 10, 30);
// $drawer->drawText('Maxim', 10, 10, 'TimesNewRoman', 20, 'rgb(77, 77, 77)');
// $drawer->savePdf($_SERVER['DOCUMENT_ROOT'] . '/1.pdf');
// $drawer->makePreview($_SERVER['DOCUMENT_ROOT'] . '/1.pdf', $_SERVER['DOCUMENT_ROOT'] . '/1.jpg');
}
示例15: FlyerRendering
function FlyerRendering($config, $inputFile, $outputPath, $outputPostfix, $anschnitt = 0.0)
{
// Breite der einzelnen Seiten
$wRechts = 99.0;
//mm
$wMitte = 98.0;
//mm
$wLinks = 97.0;
//mm
// Community Name
$communityNamePositionX = $wLinks + $wMitte + $config['communityNamePositionOffsetX'];
//mm
$communityNamePositionY = 12.2 + $config['communityNamePositionOffsetY'];
//mm
// Kontakt Titel
$kontaktTitelPositionX = $wLinks + 3.975;
//mm
$kontaktTitelPositionY = 10.425;
//mm
$kontaktTitelFontSize = 15.0;
//pt
// Kontakt Info
$kontaktInfoTextPositionX = $kontaktTitelPositionX + 25.0;
//mm
$kontaktInfoPositionY = $kontaktTitelPositionY + 7.0;
//mm
$kontaktInfoZeilenOffsetY = 4.7;
//mm
$kontaktInfoFontSize = 10.9;
//pt
// Kontakt Logo
$kontaktLogoPositionX = $wLinks + $wMitte / 2 - $config['kontaktLogoWidth'] / 2;
// Kontakt Footer
$kontaktFooterPositionX = $wLinks;
//mm
$kontaktFooterPositionY = 95.40000000000001;
//mm
$kontaktFooterWidth = $wMitte;
//mm
$kontaktFooterFontSize = 10.9;
//pt
// Output-Dasteiname zusammenbauen
$outputFile = $outputPath . DIRECTORY_SEPARATOR . $outputPostfix . '_' . basename($inputFile);
// initiate FPDI
$pdf = new FPDI();
echo 'Input: ' . basename($inputFile) . PHP_EOL;
$pageCount = $pdf->setSourceFile($inputFile);
// Importiere Vorder- und Rueckseite
$Vorderseite = $pdf->ImportPage(1);
$Rueckseite = $pdf->ImportPage(2);
// Seitenabmessungen holen
$size = $pdf->getTemplateSize($Vorderseite);
$dokumentBreite = round($size['w'], 2);
$dokumentHoehe = round($size['h'], 2);
echo 'Dokumenten Breite: ' . $dokumentBreite . 'mm' . PHP_EOL;
echo 'Dokumenten Hoehe: ' . $dokumentHoehe . 'mm' . PHP_EOL;
echo 'Anschnitt: ' . $anschnitt . 'mm' . PHP_EOL;
// Vorderseite uebernehmen
// Anfang eines bloeden Hacks wegen des FooterZeilen-Textes.
// Der Footertext laesst sich nur einfügen, wenn die Seite eine A4 Seite ist.
// Keine Ahnung warum!
$pdf->AddPage('L');
$tplVorderseite = $pdf->importPage(1);
$pdf->useTemplate($tplVorderseite);
//Margin ist wegen der Rand-Platzierung des Community Names wichtig.
$pdf->SetMargins(0, 0, 0);
// erstmal alle Fonts laden
echo 'Lade Fonts...' . PHP_EOL;
$pdf->AddFont('lato-bold');
$pdf->AddFont('lato-regular');
$pdf->AddFont('alternategothic');
// Rendern Titel Text
echo 'Verarbeite Titel Text...' . PHP_EOL;
$pdf->SetFont('lato-bold');
$pdf->SetFontSize($kontaktTitelFontSize);
$pdf->SetTextColor(0, 0, 0);
//schwarz
$pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktTitelPositionY + $anschnitt);
$pdf->Write(0, iconv('UTF-8', 'windows-1252', $config['kontaktTitelText']));
// Rendern Info Text
echo 'Verarbeite Info Text...' . PHP_EOL;
$pdf->SetTextColor(0, 0, 0);
//schwarz
$pdf->SetFontSize($kontaktInfoFontSize);
foreach ($config['kontaktInfoTexte'] as $a) {
$pdf->SetFont('lato-bold');
$pdf->SetXY($kontaktTitelPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt);
$pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[0]));
$pdf->SetFont('lato-regular');
$pdf->SetXY($kontaktInfoTextPositionX + $anschnitt, $kontaktInfoPositionY + $anschnitt);
$pdf->Write(0, iconv('UTF-8', 'windows-1252', $a[1]));
$kontaktInfoPositionY = $kontaktInfoPositionY + $kontaktInfoZeilenOffsetY;
}
// Rendern Community Logo
echo 'Verarbeite Logo...' . PHP_EOL;
$pdf->Image($config['kontaktLogoDateiName'], $kontaktLogoPositionX + $anschnitt, $config['kontaktLogoPositionY'] + $anschnitt, $config['kontaktLogoWidth'], 0);
// Rendern Fusszeilen Text
echo 'Verarbeite Fusszeile...' . PHP_EOL;
$pdf->SetFont('lato-regular');
$pdf->SetFontSize($kontaktFooterFontSize);
//.........这里部分代码省略.........