当前位置: 首页>>代码示例>>PHP>>正文


PHP FPDI::setPageOrientation方法代码示例

本文整理汇总了PHP中FPDI::setPageOrientation方法的典型用法代码示例。如果您正苦于以下问题:PHP FPDI::setPageOrientation方法的具体用法?PHP FPDI::setPageOrientation怎么用?PHP FPDI::setPageOrientation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FPDI的用法示例。


在下文中一共展示了FPDI::setPageOrientation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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++;
     }
 }
开发者ID:saliih,项目名称:yasmine-print,代码行数:36,代码来源:PrintCommand.php

示例2: 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');
 }
开发者ID:saliih,项目名称:yasmine-print,代码行数:82,代码来源:CRUDController.php

示例3: 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("");
 }
开发者ID:saliih,项目名称:yasmine-print,代码行数:71,代码来源:AjaxController.php


注:本文中的FPDI::setPageOrientation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。