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


PHP FPDI::setFontSubsetting方法代码示例

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


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

 function Output($type)
 {
     $type = strtolower($type);
     //Initialize PDF object so all subclasses can access it.
     //Loop through all objects and combine the output from each into a single document.
     if ($type == 'pdf') {
         if (!class_exists('tcpdf')) {
             require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $this->tcpdf_dir . DIRECTORY_SEPARATOR . 'tcpdf.php';
         }
         if (!class_exists('fpdi')) {
             require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . $this->fpdi_dir . DIRECTORY_SEPARATOR . 'fpdi.php';
         }
         $pdf = new FPDI('P', 'pt');
         $pdf->setMargins(0, 0, 0, 0);
         $pdf->SetAutoPageBreak(FALSE);
         $pdf->setFontSubsetting(FALSE);
         foreach ($this->objs as $obj) {
             $obj->setPDFObject($pdf);
             $obj->Output($type);
         }
         return $pdf->Output('', 'S');
     } elseif ($type == 'efile') {
         foreach ($this->objs as $obj) {
             return $obj->Output($type);
         }
     } elseif ($type == 'xml') {
         //Since multiple XML sections may need to be joined together,
         //We must pass the XML object between each form and  build the entire XML object completely
         //then output it all at once at the end.
         $xml = NULL;
         $xml_schema = NULL;
         foreach ($this->objs as $obj) {
             if (is_object($xml)) {
                 $obj->setXMLObject($xml);
             }
             $obj->Output($type);
             if (isset($obj->xml_schema)) {
                 $xml_schema = $obj->getClassDirectory() . DIRECTORY_SEPARATOR . 'schema' . DIRECTORY_SEPARATOR . $obj->xml_schema;
             }
             if ($xml == NULL and is_object($obj->getXMLObject())) {
                 $xml = $obj->getXMLObject();
             }
         }
         if (is_object($xml)) {
             $output = $xml->asXML();
             $xml_validation_retval = $this->validateXML($output, $xml_schema);
             if ($xml_validation_retval !== TRUE) {
                 Debug::text('XML Schema is invalid! Malformed XML!', __FILE__, __LINE__, __METHOD__, 10);
                 //$output = FALSE;
                 $output = $xml_validation_retval;
             }
         } else {
             Debug::text('No XML object!', __FILE__, __LINE__, __METHOD__, 10);
             $output = FALSE;
         }
         return $output;
     }
 }
开发者ID:alachaum,项目名称:timetrex,代码行数:58,代码来源:GovernmentForms.class.php

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