function loadPage() { // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->titulo = $this->getPlan(); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Red de Universidades Anahuac'); $pdf->SetTitle('Plan Estrategico'); $pdf->SetSubject($this->getPlan()); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings //$pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', 'N', 11); // add a page $pdf->AddPage(); $pdf->SetY(5); $html = "\n<!-- EXAMPLE OF CSS STYLE -->\n<style> \n\ttd{\n\tborder:1px solid #666;\n\t}\n\t\n\ttd.title{\n\tbackground:#E5E5E5;\n\tpadding:10px;\n\t}\n \n</style> <br />"; $html .= $this->Model->getLineas(); // output the HTML content $pdf->writeHTML($html, true, false, true, false, ''); //Close and output PDF document $pdf->Output('plan_operativo.pdf', 'I'); }
$this->SetY(-15); // Set font $this->SetFont('helvetica', 'I', 8); $this->MultiCell(55, 5, "Fecha de impresion: ".date("d/m/Y g:i a"), 0, 'L', 0, 0, '', '', true); $this->MultiCell(55, 5, "", 0, 'C', 0, 0, '', '', true); $this->MultiCell(75, 5, 'Pagina '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, 'R', 0, 0, '', '', true); } } // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set default header data //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, "Casa San Francisco", "Log del sistema"); // set header and footer fonts $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
public function actionCreateAccount() { $params = self::accountCond(); $select1 = "OrderSN as No,CreateTime,Payment,BuyerID,RealPrice as Price,BuyerName"; $select2 = "ReturnNO as No,CreateTime,PayMethod as Payment,ServiceID as BuyerID,Price"; if ($params['type'] == 1) { $seaCon1 = "select {$select1} from pap_order t where t.Status=9"; $seaCon1 .= " and SellerID = {$params['OrganID']} and IsDelete = 0"; $seaCon1 .= " and t.CreateTime>={$params['starttime']} and t.CreateTime<{$params['endtime']}"; $seaCon1 .= " order by CreateTime DESC"; $data1 = Yii::app()->papdb->createCommand($seaCon1)->queryAll(); $count1 = Yii::app()->papdb->createCommand(str_replace($select1, 'sum(RealPrice)', $seaCon1))->queryScalar(); } else { if ($params['type'] == 2) { $seaCon2 = "select {$select2} from pap_return_order t where t.Status in(4,14)"; $seaCon2 .= " and DealerID = {$params['OrganID']}"; $seaCon2 .= " and t.CreateTime>={$params['starttime']} and t.CreateTime<{$params['endtime']}"; $seaCon2 .= " order by CreateTime DESC"; $data2 = Yii::app()->papdb->createCommand($seaCon2)->queryAll(); $count2 = Yii::app()->papdb->createCommand(str_replace($select2, 'sum(Price)', $seaCon2))->queryScalar(); } else { $seaCon1 = "select {$select1} from pap_order t where t.Status=9"; $seaCon1 .= " and SellerID = {$params['OrganID']} and IsDelete = 0"; $seaCon1 .= " and t.CreateTime>={$params['starttime']} and t.CreateTime<{$params['endtime']}"; $seaCon1 .= " order by CreateTime DESC"; $data1 = Yii::app()->papdb->createCommand($seaCon1)->queryAll(); $count1 = Yii::app()->papdb->createCommand(str_replace($select1, 'sum(RealPrice)', $seaCon1))->queryScalar(); $seaCon2 = "select {$select2} from pap_return_order t where t.Status in(4,14)"; $seaCon2 .= " and DealerID = {$params['OrganID']}"; $seaCon2 .= " and t.CreateTime>={$params['starttime']} and t.CreateTime<{$params['endtime']}"; $seaCon2 .= " order by CreateTime DESC"; $data2 = Yii::app()->papdb->createCommand($seaCon2)->queryAll(); $count2 = Yii::app()->papdb->createCommand(str_replace($select2, 'sum(Price)', $seaCon2))->queryScalar(); } } $count1 = $count1 ? $count1 : 0; $count2 = $count2 ? $count2 : 0; $gain = $count1 - $count2; $day = date('t', $params['starttime']); $organ = Organ::model()->findByPk($params['OrganID'], array('select' => 'OrganName'))->attributes; $html = '<div style="height:24px; line-height:24px; background-color:#1f76c8"> <div style="margin:0 auto; text-align:center"> <span style="font-family:微软雅黑; font-size:24px; color:#fff; word-spacing:8px; letter-spacing: 1.5px;">' . $params['uyear'] . '年' . $params['umonth'] . '月对账单</span> </div> </div> <div style="font-size:16px; color:#343434; line-height:16px"> <p style="margin:0px; ">亲爱的' . $organ['OrganName'] . ',您好!</p> <p style="margin:0px; ">感谢您使用由你配平台,以下是您' . $params['umonth'] . '月的平台交易明细:</p> </div> <div style="height:20px; line-height:18px; border-bottom:2px solid #c9c7c7; border-top:2px solid #c9c7c7; background-color:#f2f2f2; padding:0 30px"> <div style="font-size:16px; font-weight:bold; color:#565656; line-height:18px;float:left"> 本月净收益: <span style="color:#1f76c8">' . $gain . '</span> 元 </div> <div style="font-size:16px; line-height:18px;float:right"> <p style="margin:0px; line-height:15px"> 本月总收入: <span style="color:#1f76c8;font-size:14px">' . $count1 . '</span>元 本月总支出: <span style="color:#1f76c8;font-size:14px">' . $count2 . '</span>元</p> <p style="margin:0px; line-height:15px"> 账单周期:' . $params['uyear'] . '年' . $params['umonth'] . '月01日—' . $params['uyear'] . '年' . $params['umonth'] . '月' . $day . '日 </p> </div> </div>'; Yii::import('application.extensions.tcpdf.*'); // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // 设置文档信息 $pdf->SetCreator('--'); $pdf->SetAuthor('北京嘉配科技有限公司'); $pdf->SetTitle('由你配 - 对账单'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, PHP'); // 设置页眉和页脚信恿 $pdf->SetHeaderData('', 30, '', '', array(0, 64, 255), array(0, 64, 128)); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); // 设置页眉和页脚字使 $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // 设置默认等宽字体 $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // 设置间距 $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // 设置分页 $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // 设置字体 $pdf->SetFont('stsongstdlight', '', 14, true); // 添加页面 $pdf->AddPage(); // Image example with resizing $pdf->Image(F::themeUrl() . '/images/jpd/logo_account.jpg', 20, 28, 30, 18, 'JPG', '', '', true, 150, '', false, false, 0, false, false, false); // 设置字体阴影 //$pdf->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal')); // 输出HTML内容 $pdf->writeHTML($html, true, false, true, false, ''); if (!empty($data1)) { $html = '<p style="color:#1f76c8">订单明细:</p>'; $pdf->writeHTML($html, true, false, true, false, ''); // 表格标题 $header = array('时间', '交易类型', '修理厂名称', '订单编号', '收入(元)'); // data loading $data = array(); foreach ($data1 as $key => $val) { $data[$key][0] = date('Y-m-d', $val['CreateTime']); $data[$key][1] = $val['Payment'] == 2 ? '物流代收款' : '支付宝担保'; if (!$val['BuyerName']) { $val['BuyerName'] = Organ::model()->findByPk($val['BuyerID'], array('select' => 'OrganName'))->attributes['OrganName']; } $data[$key][2] = $val['BuyerName']; $data[$key][3] = $val['No']; $data[$key][4] = $val['Price']; } // 输出表格 $pdf->ColoredTable($header, $data); //换行 $pdf->Ln(); } if (!empty($data2)) { $html = '<p style="color:#1f76c8;">退货明细:</p>'; $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); // 表格标题 $header = array('时间', '退款方式', '修理厂名称', '退货单号', '支出(元)'); // 导入数据 $data = array(); foreach ($data2 as $key => $val) { $data[$key][0] = date('Y-m-d', $val['CreateTime']); $data[$key][1] = $val['Payment'] == 1 ? '物流代收款' : '支付宝担保'; $data[$key][2] = Organ::model()->findByPk($val['BuyerID'], array('select' => 'OrganName'))->attributes['OrganName']; $data[$key][3] = $val['No']; $data[$key][4] = $val['Price']; } // 输出表格 $pdf->ColoredTable($header, $data); } $pdf->Output('Account.pdf', 'I'); }
$fill = 0; foreach ($data as $row) { $this->Cell($w[0], 6, $row[0], 'LR', 0, 'L', $fill); $this->Cell($w[1], 6, $row[1], 'LR', 0, 'L', $fill); $this->Cell($w[2], 6, $row[2], 'LR', 0, 'R', $fill); $this->Cell($w[3], 6, $row[3], 'LR', 0, 'R', $fill); $this->Ln(); $fill = !$fill; } $this->Cell(array_sum($w), 0, '', 'T'); } } // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set default header data $pdf->SetHeaderData('logo.png', 15, "APYMECO", "Índice general de la construcción", array(0, 0, 0), array(0, 0, 0)); // set header and footer fonts $pdf->setHeaderFont(array('helvetica', '', 12)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(10); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font $pdf->SetFont('helvetica', '', 14, '', true);
// Set font $this->SetFont('helvetica', 'I', 8); // Page number $this->Cell(0, 10, 'Page ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); } } // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 003'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l);
public function setup_pdf() { //echo "setup_pdf"; $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Havering Carepoint'); $pdf->SetTitle($this->post_title); $pdf->SetSubject($this->post_title); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, '', ''); // // set header and footer fonts // $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); // $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // // set default monospaced font // $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // // set image scale factor // $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // // set font // $pdf->SetFont('dejavusans', '', 10); // add a page $pdf->AddPage(); // output the HTML content $html = '<h1>'.$this->post_title.'</h1>'.apply_filters('the_content', $this->post_content); $html .= '<br/><small>This PDF was downloaded from: <a href="'.get_permalink($this->post_id).'">'.get_permalink($this->post_id).'</a></small>'; if(get_field('nhs_choices', $this->post_id) != ""): $html .= '<style> .nhs-choices-label{ float: left; display: block; padding: 5px; margin-bottom: 20px; border: 3px solid #DFDFDF;} </style> <table class="nhs-choices-label"> <tr> <td> <small>This article is sourced from:</small> <img src="'.get_bloginfo("template_url").'/library/images/nhs-choices-logo.jpg" alt="NHS Choices"> </td> </tr> </table>'; endif; $pdf->writeHTML($html, true, false, true, false, ''); // reset pointer to the last page $pdf->lastPage(); //Close and output PDF document $pdf->Output($this->post_title.'.pdf', 'I'); }
function generate_pdf_file($id, $forceDownload = false) { $post = get_post(); $content = $post->the_content; if (has_shortcode($content, 'wpptopdfenh')) { if (!$this->options[$post->post_type]) { return false; } } // require_once(WPPTOPDFENH_PATH . '/tcpdf/config/lang/eng.php'); // to avoid duplicate function error if (!class_exists('TCPDF')) { require_once WPPTOPDFENH_PATH . '/tcpdf/tcpdf.php'; } if (!class_exists('MYPDF')) { require_once WPPTOPDFENH_PATH . '/wpptopdfenh_header.php'; } // to avoid duplicate function error ( conflict with Lightbox Plus v2.4.6 ) if (!class_exists('simple_html_dom')) { require_once WPPTOPDFENH_PATH . '/simplehtmldom/simple-html-dom.php'; } $filePath = WPPTOPDFENH_CACHE_DIR . '/' . $post->post_name . '.pdf'; // create new PDF document if (isset($this->options['pageSize'])) { $pagesize = $this->options['pageSize']; } else { $pagesize = PDF_PAGE_FORMAT; } if (isset($this->options['unitMeasure'])) { $unit = $this->options['unitMeasure']; } else { $unit = PDF_UNIT; } if (isset($this->options['orientation'])) { $orientation = $this->options['orientation']; } else { $unit = PDF_PAGE_ORIENTATION; } $pdf = new MYPDF($orientation, $unit, $pagesize, true, 'UTF-8', false); // Let other filter modify content if selected if (isset($this->options['otherPlugin'])) { $post->post_content = apply_filters('the_content', $post->post_content); } else { $post->post_content = wpautop($post->post_content); } // Process shortcodes if selected if (isset($this->options['processShortcodes'])) { $post->post_content = do_shortcode($post->post_content); } else { $post->post_content = strip_shortcodes($post->post_content); } // set document information $pdf->SetCreator('WP Post to PDF Enhanced plugin by Lewis Rosenthal (http://www.2rosenthals.net/wordpress/help/general-help/wp-post-to-pdf-enhanced/) with ' . PDF_CREATOR); $pdf->SetAuthor(get_bloginfo('name')); $pdf->SetTitle(apply_filters('the_title', $post->post_title)); // Count width of logo for better presentation if (isset($this->options['headerlogoImage'])) { $logo = PDF_HEADER_LOGO; $logodata = getimagesize(PDF_HEADER_LOGO); if (isset($this->options['headerlogoImageFactor'])) { $logowidth = (int) ($this->options['headerlogoImageFactor'] * $logodata[0] / $logodata[1]); } else { $logowidth = (int) (14 * $logodata[0] / $logodata[1]); } } // new feature under development: specify header/footer text/separator color // some addtional header data which should be set in the admin UI; for testing, we're hiding the separator line (note the RGB array) //$header_text_color = array( 0,0,0 ); //$header_line_color = array( 255,255,255 ); // some addtional footer data which should be set in the admin UI; for testing, we're hiding the separator line (note the RGB array) //$footer_text_color = array( 0,0,0 ); //$footer_line_color = array( 255,255,255 ); //$pdf->SetSubject('TCPDF Tutorial'); //$pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data, as appropriate for PHP 5.4 or below if (version_compare(phpversion(), '5.4.0', '<')) { $pdf->SetHeaderData($logo, $logowidth, html_entity_decode(get_bloginfo('name'), ENT_COMPAT | ENT_QUOTES), html_entity_decode(get_bloginfo('description') . "\n" . home_url(), ENT_COMPAT | ENT_QUOTES), $header_text_color, $header_line_color); } else { $pdf->SetHeaderData($logo, $logowidth, html_entity_decode(get_bloginfo('name'), ENT_COMPAT | ENT_HTML401 | ENT_QUOTES), html_entity_decode(get_bloginfo('description') . "\n" . home_url(), ENT_COMPAT | ENT_HTML401 | ENT_QUOTES), $header_text_color, $header_line_color); } // set header and footer fonts $pdf->setHeaderFont(array($this->options['headerFont'], '', $this->options['headerFontSize'])); $pdf->setFooterFont(array($this->options['footerFont'], '', $this->options['footerFontSize'])); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins if ($this->options['marginLeft'] > 0) { $pdf->SetLeftMargin($this->options['marginLeft']); } else { $pdf->SetLeftMargin(PDF_MARGIN_LEFT); } if ($this->options['marginRight'] > 0) { $pdf->SetRightMargin($this->options['marginRight']); } else { $pdf->SetRightMargin(PDF_MARGIN_RIGHT); } if ($this->options['marginTop'] > 0) { $pdf->SetTopMargin($this->options['marginTop']); } else { $pdf->SetTopMargin(PDF_MARGIN_TOP); } if ($this->options['marginHeader'] > 0) { $pdf->SetHeaderMargin($this->options['marginHeader']); } else { $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); } if ($this->options['marginFooter'] > 0) { $pdf->SetFooterMargin($this->options['marginFooter']); } else { $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); } //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor if ($this->options['imageScale'] > 0) { $pdf->setImageScale($this->options['imageScale']); } else { $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); } // --------------------------------------------------------- // Set the default LI image, if specified if (isset($this->options['liSymbol'])) { $lisymbol = 'img|' . $this->options['liSymbolType'] . '|' . $this->options['liSymbolWidth'] . '|' . $this->options['liSymbolHeight'] . '|' . WP_CONTENT_DIR . '/uploads/' . $this->options['liSymbolFile']; $pdf->setLIsymbol($lisymbol); } // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont($this->options['contentFont'], '', $this->options['contentFontSize'], '', true); // Add a page // This method has several options, check the source code documentation for more information. $pdf->AddPage(); // Apply global css, if set in config if ($this->options['applyCSS']) { $html .= '<style>' . $this->options['customCss'] . '</style>'; } // Set some content to print $html .= '<h1>' . html_entity_decode($post->post_title, ENT_QUOTES) . '</h1>'; // Display author name is set in config if (isset($this->options['authorDetail']) and !$this->options['authorDetail'] == '') { $author = get_the_author_meta($this->options['authorDetail'], $post->post_author); $html .= '<p><strong>Author : </strong>' . $author . '</p>'; } // Display category list is set in config if (isset($this->options['postCategories'])) { $categories = get_the_category_list(', ', '', $post); if ($categories) { $html .= '<p><strong>Categories : </strong>' . $categories . '</p>'; } } // Display tag list is set in config if (isset($this->options['postTags'])) { $tags = get_the_tags($post->the_tags); if ($tags) { $html .= '<p><strong>Tagged as : </strong>'; foreach ($tags as $tag) { $tag_link = get_tag_link($tag->term_id); $html .= '<a href="' . $tag_link . '">' . $tag->name . '</a>'; if (next($tags)) { $html .= ', '; } } $html .= '</p>'; } } // Display date if set in config if (isset($this->options['postDate'])) { $date = get_the_date($post->the_date); $html .= '<p><strong>Date : </strong>' . $date . '</p>'; } // Display featured image if set in config and post/page if (isset($this->options['featuredImage'])) { if (has_post_thumbnail($post->ID)) { $html .= get_the_post_thumbnail($post->ID); } } $html .= htmlspecialchars_decode(htmlentities($post->post_content, ENT_NOQUOTES, 'UTF-8', false), ENT_NOQUOTES); $dom = new simple_html_dom(); $dom->load($html); foreach ($dom->find('img') as $e) { // Try to respect alignment of images // This code is under heavy development, so well-commented // First, try to determine the desired alignment from the class attribute inserted by WP. // Note that as we're still working with HTML vs CSS, and HTML uses "middle" for center, we // have two variables to fill for that possibility. if (preg_match('/alignleft/i', $e->class)) { $imgalign = 'left'; } elseif (preg_match('/alignright/i', $e->class)) { $imgalign = 'right'; } elseif (preg_match('/aligncenter/i', $e->class)) { $imgalign = 'center'; $htmlimgalign = 'middle'; } else { $imgalign = 'none'; } // These options apply to all images. Remove any embedded class, which is ignored by TCPDF, anyway; // then set an align attribute inside the img tag (for HTML), and finally, a style tag (for CSS). $e->class = null; $e->align = $imgalign; if (isset($htmlimgalign)) { $e->style = 'float:' . $htmlimgalign; } else { $e->style = 'float:' . $imgalign; } // Try to identify SVG images vs JPG or PNG, so that we treat them correctly. Currently, we don't // handle these well, so we'll just swap them with placeholder links. // Note that we're still using div tags to (harshly) force images into some semblance of horizontal // position. This precludes text wrap, and ultimately (if we can get the above working) should be // replaced (unless we need the text link) with the CSS in the img tag (if TCPDF will respect it). if (strtolower(substr($e->src, -4)) == '.svg') { $e->src = null; $e->outertext = '<div style="text-align:' . $imgalign . '">[ SVG: ' . $e->alt . ' ]</div><br/>'; } else { $e->outertext = '<div style="text-align:' . $imgalign . '">' . $e->outertext . '</div>'; } } $html = $dom->save(); $dom->clear(); // Test TCPDF functions to include here. // Presently, we're working with trying to get PDF forms working. These options should go into the admin UI. // set default form properties $pdf->setFormDefaultProp(array('lineWidth' => 1, 'borderStyle' => 'solid', 'fillColor' => array(255, 255, 200), 'strokeColor' => array(255, 128, 128))); // Print text using writeHTML $pdf->writeHTML($html, true, 0, true, 0); // --------------------------------------------------------- // Close and output PDF document // This method has several options, check the source code documentation for more information. // Create directory if not exist if (!is_dir(WPPTOPDFENH_CACHE_DIR)) { mkdir(WPPTOPDFENH_CACHE_DIR, 0777, true); } if ($forceDownload) { $pdf->Output($filePath, 'FI'); } else { $pdf->Output($filePath, 'F'); } }
function checkStoreInvoice($orderDetails = 0) { JRequest::setVar('task', 'checkStoreInvoice'); $force = true; // @ini_set( 'max_execution_time', 5 ); $path = VmConfig::get('forSale_path', 0); if ($path === 0) { vmError('No path set to store invoices'); return false; } else { $path .= 'invoices' . DS; if (!file_exists($path)) { vmError('Path wrong to store invoices, folder invoices does not exist ' . $path); return false; } else { if (!is_writable($path)) { vmError('Cannot store pdf, directory not writeable ' . $path); return false; } } } $orderModel = VmModel::getModel('orders'); $invoiceNumberDate = array(); if (!$orderModel->createInvoiceNumber($orderDetails['details']['BT'], $invoiceNumberDate)) { return 0; } if (!empty($invoiceNumberDate[0])) { $invoiceNumber = $invoiceNumberDate[0]; } else { $invoiceNumber = FALSE; } if (!$invoiceNumber or empty($invoiceNumber)) { vmError('Cant create pdf, createInvoiceNumber failed'); return 0; } if (shopFunctions::InvoiceNumberReserved($invoiceNumber)) { return 0; } $path .= 'vminvoice_' . $invoiceNumber . '.pdf'; if (file_exists($path) and !$force) { return $path; } // $app = JFactory::getApplication('site'); //We come from the be, so we need to load the FE langauge $jlang = JFactory::getLanguage(); $jlang->load('com_virtuemart', JPATH_SITE, 'en-GB', true); $jlang->load('com_virtuemart', JPATH_SITE, $jlang->getDefault(), true); $jlang->load('com_virtuemart', JPATH_SITE, null, true); $this->addViewPath(JPATH_VM_SITE . DS . 'views'); $format = 'html'; $viewName = 'invoice'; $view = $this->getView($viewName, $format); $view->addTemplatePath(JPATH_VM_SITE . DS . 'views' . DS . 'invoice' . DS . 'tmpl'); $view->invoiceNumber = $invoiceNumberDate[0]; $view->invoiceDate = $invoiceNumberDate[1]; $view->orderDetails = $orderDetails; $view->uselayout = 'invoice'; ob_start(); $view->display(); $html = ob_get_contents(); ob_end_clean(); // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator('Invoice by VirtueMart 2, used library tcpdf'); $pdf->SetAuthor($view->vendor->vendor_name); $pdf->SetTitle(JText::_('COM_VIRTUEMART_INVOICE_TITLE')); $pdf->SetSubject(JText::sprintf('COM_VIRTUEMART_INVOICE_SUBJ', $view->vendor->vendor_store_name)); $pdf->SetKeywords('Invoice by VirtueMart 2'); //virtuemart.cloudaccess.net/index.php?option=com_virtuemart&view=invoice&layout=details&virtuemart_order_id=18&order_number=6e074d9b&order_pass=p_9cb9e2&task=checkStoreInvoice if (empty($view->vendor->images[0])) { vmError('Vendor image given path empty '); } else { if (empty($view->vendor->images[0]->file_url_folder) or empty($view->vendor->images[0]->file_name) or empty($view->vendor->images[0]->file_extension)) { vmError('Vendor image given image is not complete ' . $view->vendor->images[0]->file_url_folder . $view->vendor->images[0]->file_name . '.' . $view->vendor->images[0]->file_extension); vmdebug('Vendor image given image is not complete, the given media', $view->vendor->images[0]); } else { if (!empty($view->vendor->images[0]->file_extension) and strtolower($view->vendor->images[0]->file_extension) == 'png') { vmError('Warning extension of the image is a png, tpcdf has problems with that in the header, choose a jpg or gif'); } else { $imagePath = DS . str_replace('/', DS, $view->vendor->images[0]->file_url_folder . $view->vendor->images[0]->file_name . '.' . $view->vendor->images[0]->file_extension); if (!file_exists(JPATH_ROOT . $imagePath)) { vmError('Vendor image missing ' . $imagePath); } else { $pdf->SetHeaderData($imagePath, 60, $view->vendor->vendor_store_name, $view->vendorAddress); } } } } // set header and footer fonts $pdf->setHeaderFont(array('helvetica', '', 8)); $pdf->setFooterFont(array('helvetica', '', 10)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //TODO include the right file (in libraries/tcpdf/config/lang set some language-dependent strings $l = ''; $pdf->setLanguageArray($l); // set default font subsetting mode $pdf->setFontSubsetting(true); // Set font // dejavusans is a UTF-8 Unicode font, if you only need to // print standard ASCII chars, you can use core fonts like // helvetica or times to reduce file size. $pdf->SetFont('helvetica', '', 8, '', true); // Add a page // This method has several options, check the source code documentation for more information. $pdf->AddPage(); // Set some content to print // $html = // Print text using writeHTMLCell() $pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true); // Close and output PDF document // This method has several options, check the source code documentation for more information. $pdf->Output($path, 'F'); return $path; }
// create new PDF document //$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf = new MYPDF($oreientecaoPagina, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->setTxtNomeIgreja($nomeIgreja); $pdf->setTxtTitulo1($title1); $pdf->setTxtTitulo2($title2); $pdf->setTxtTitulo3($title3); $pdf->setTxtFooter($footertext); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('MS_INFORMATICA'); //$pdf->SetTitle('TCPDF Example 006'); //$pdf->SetSubject('TCPDF Tutorial'); //$pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(NULL, NULL, "Igreja Conectada", NULL); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l);
function ProcessRequest() { // $pdf = $this->Pdf; //============================================================+ // File name : example_003.php // Begin : 2008-03-04 // Last Update : 2013-05-14 // // Description : Example 003 for TCPDF class // Custom Header and Footer // // Author: Nicola Asuni // // (c) Copyright: // Nicola Asuni // Tecnick.com LTD // www.tecnick.com // info@tecnick.com //============================================================+ /** * Creates an example PDF TEST document using TCPDF * @package com.tecnick.tcpdf * @abstract TCPDF - Example: Custom Header and Footer * @author Nicola Asuni * @since 2008-03-04 */ // Include the main TCPDF library (search for installation path). // require_once('tcpdf_include.php'); // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Nicola Asuni'); $pdf->SetTitle('TCPDF Example 003'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set some language-dependent strings (optional) if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } // --------------------------------------------------------- // set font $pdf->SetFont('times', 'BI', 12); // add a page $pdf->AddPage(); // set some text to print $txt = <<<EOD TCPDF Example 003 Custom page header and footer are defined by extending the TCPDF class and overriding the Header() and Footer() methods. EOD; // print a block of text using Write() $pdf->Write(0, $txt, '', 0, 'C', true, 0, false, false, 0); // --------------------------------------------------------- //Close and output PDF document $pdf->Output('example_003.pdf', 'I'); //============================================================+ // END OF FILE //============================================================+ // $this->Save(); }
function creatNewPdf() { $agru = func_get_arg(0); $logo = $agru['logo']; $link = $agru['link']; $target = $agru['target']; $logoExtention = $agru['logo_extention']; $date = $agru['date']; $title = $agru['title']; $disc = $agru['description']; $image = $agru['image']; $content = $agru['content']; $copyright = $agru['copyright']; $fileName = $agru['file_name']; $pdfCreator = $agru['pdf_creator']; $pdfAuthor = $agru['pdf_author']; $pdfTitle = $agru['pdf_title']; $pdfSubject = $agru['pdf_subject']; $pdfKeywords = $agru['pdf_keywords']; // create new PDF document $pdf = new MYPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->setTempRTL('R'); $pdf->image_file = $logo; $pdf->href = $target; $pdf->link = $link; $pdf->copyright = $copyright; $this->extention = $logoExtention; # must included in each decument[Must Include] // appear in document properties $pdf->SetCreator($pdfCreator); $pdf->SetAuthor($pdfAuthor); $pdf->SetTitle($pdfTitle); $pdf->SetSubject($pdfSubject); $pdf->SetKeywords($pdfKeywords); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, ' ', ' ', array(0, 64, 255), array(0, 64, 128)); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); // header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // end of header # set default monospaced font[Must Include] $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); # set margins[Must Include] $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); // header & footer margin $pdf->SetHeaderMargin(50); $pdf->SetFooterMargin(20); $pdf->SetAutoPageBreak(TRUE, 30); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setFontSubsetting(true); //$pdf->SetFont('almohanad', '', 13); $pdf->setRTL(true); // cehck here if ar or en $pdf->startPageGroup(); $pdf->AddPage(); $lg = array(); $lg['a_meta_charset'] = 'UTF-8'; $lg['a_meta_dir'] = 'rtl'; $pdf->setLanguageArray($lg); $pdf->SetFont('almohanad', '', 13); $pdf->setRTL(true); // cehck here if ar or en $html = ' <div > <br/> <span id="date"style="color:#008080" > ' . $date . ' </span> <h3 id="title" style="color:#191970"> ' . $title . ' </h3> <h5 id="description" style="color:#6A5ACD"> ' . $disc . ' </h5> <img src="' . $image . '" alt="' . $title . '" /> <div style="align:justify"> ' . $content . ' </div> </div> '; // $pdf->writeHTML($html, true, false, false, true, ""); $pdf->writeHTMLCell($w = 170, $h = 0, $x = 0, $y = 0, $html, $border = 0, $ln = 0, $fill = false, $reseth = true, $align = "R"); $pdf->setRTL(true); #excute the file $pdf->Output(PDF_FILES . $fileName . '.pdf', 'F'); }
public function download_consolidated_pdf_report() { $user = JFactory::getUser(); $app = JFactory::getApplication(); $model = $this->getModel('survey'); $params = JComponentHelper::getParams(S_APP_NAME); $id = $app->input->getInt('id', 0); if (!$id || !$model->authorize_survey($id)) { CJFunctions::throw_error(JText::_('MSG_UNAUTHORIZED'), 401); } else { $wysiwyg = $user->authorise('core.wysiwyg', S_APP_NAME) ? true : false; $bbcode = $wysiwyg && $params->get('default_editor', 'bbcode') == 'bbcode'; $content = $params->get('process_content_plugins', 0) == 1; require_once JPATH_COMPONENT . '/helpers/reports.php'; $generator = new SurveyReports($wysiwyg, $bbcode, $content); $survey = $model->get_consolidated_report($id); $headStyles = array(); $headStyles[] = CJLIB_URI . '/bootstrap/css/bootstrap.min.css'; $headStyles[] = JURI::root(true) . '/media/' . S_APP_NAME . '/css/cj.surveys.min.css'; $headScripts = array(); $headScripts[] = CJLIB_URI . '/jquery/jquery.min.js'; $headScripts[] = CJLIB_URI . '/jquery/jquery.noconflict.js'; $headScripts[] = CJLIB_URI . '/bootstrap/js/bootstrap.min.js'; $headScripts[] = 'https://www.google.com/jsapi'; $headScripts[] = JURI::root(true) . '/media/' . S_APP_NAME . '/js/cj.surveys.min.js'; $html = '<html xmlns="http://www.w3.org/1999/xhtml" dir="' . JFactory::getDocument()->direction . '"><head>'; $html = $html . '<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta http-equiv="content-type" content="text/html; charset=utf-8" />'; // foreach ($headStyles as $style) // { // $html = $html . '<link rel="stylesheet" href="'.$style.'" type="text/css" />'; // } // foreach ($headScripts as $script) // { // $html = $html . '<script src="'.$script.'" type="text/javascript"></script>'; // } // $html .= '<script type="text/javascript">google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(SurveyFactory.draw_consolidated_charts);</script>'; $html .= '</head><body><div id="cj-wrapper" class="container-fuild"><div class="reports-wrapper margin-top-20">'; $html .= '<h2 class="page-header margin-bottom-10">' . CJFunctions::escape($survey->title) . '</h2>'; foreach ($survey->questions as $item) { switch ($item->question_type) { case 1: $html .= $generator->get_page_header_question($item, ''); break; case 2: case 3: case 4: case 11: case 12: $html .= $generator->get_choice_question($item, ''); break; case 5: case 6: $html .= $generator->get_grid_question($item, ''); break; } } $html .= '</div></div></body></html>'; // All validations done, write data now $fileName = 'survey_' . $id . '_' . date('dmYHis') . '.pdf'; // create new PDF document require_once JPATH_COMPONENT_SITE . '/helpers/tcpdf.php'; $pdf = new MYPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set default header data $pdf->SetHeaderData('logo.png', PDF_HEADER_LOGO_WIDTH, $survey->title, ''); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('corejoomla.com'); $pdf->SetTitle('Survey Report'); $pdf->SetSubject('Consolidated Report'); $pdf->SetKeywords('survey, report'); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // --------------------------------------------------------- // set font $pdf->SetFont('freesans'); $pdf->AddPage(); $pdf->writeHTML($html, true, false, true, false, ''); $pdf->lastPage(); $pdf->Output($fileName, $mode); jexit(); } }
<a href="http://www.tympaan.nl" style="text-decoration:none;color:#808080;" >Tympaan Instituut</a>- <a href="mailto:info@tympaan.nl" style="text-decoration:none;color:#808080;">info@tympaan.nl</a> EOD; $this->writeHTMLCell(300, 10, '', '', $footer, 0, 0, 0, false, '', false); $this->Cell(0, 0, $date, 0, false, 'R', 0, '', 0, false, 'T', 'M'); } } // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Tympaan Instituut'); $pdf->SetTitle('Transitiemonitor'); $pdf->SetSubject('Transitiemonitor'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, '', '', array(0, 0, 0), array(255, 255, 255)); // $pdf->setPrintHeader(false); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // set font
$this->SetFont('helvetica', 'I', 8); $this->MultiCell(0, 5, "Via Angelelli 14/a - 40013 Castel Maggiore (BO) Tel.: +39 051 6325815", 0, 'C', 0, 0, '', '', true, 0, false, true, 0, 'M'); // Page number $this->Cell(0, 5, 'Page ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); } } // create new PDF document $pdf = new MYPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Contract by neiroc_'); $pdf->SetTitle('PDF'); $pdf->SetSubject('PDF'); $pdf->SetKeywords('PDF'); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING, array(0, 64, 255), array(0, 64, 128)); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128)); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $pdf->SetMargins(PDF_MARGIN_LEFT, 40, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(160); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); // set default header data $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING, array(255, 64, 255), array(100, 64, 128)); $pdf->setFooterData(array(0, 64, 0), array(0, 64, 128));
// Set font $this->SetFont('helvetica', 'I', 10); $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); $this->SetY(-15); $this->Cell(0, 10,'('.''.$reportname->name.''.')', 0, false, 'C', 0, '', 0, false, 'T', 'M'); } } $doc = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $doc->setPrintHeader(true); $doc->setPrintFooter(true); // set default header data $doc->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 059', PDF_HEADER_STRING); // set header and footer fonts $doc->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $doc->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $doc->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); // set margins $doc->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $doc->SetHeaderMargin(PDF_MARGIN_HEADER); $doc->SetFooterMargin(PDF_MARGIN_FOOTER); // set auto page breaks $doc->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
function generatePdfReport($pdfData, $mode, $params, $fileName) { $countries = CJFunctions::get_country_names(); $responses = array(); $include_email_in_reports = $params->get('include_email_in_reports', 0); foreach ($pdfData->responses as $response) { $responses[$response->id] = new stdClass(); $responses[$response->id]->created_by = $response->created_by; $responses[$response->id]->created = $response->created; $responses[$response->id]->username = $response->username; $responses[$response->id]->name = $response->name; if ($include_email_in_reports == 1) { $responses[$response->id]->email = $response->email; } $responses[$response->id]->questions = array(); foreach ($pdfData->questions as $question) { $responses[$response->id]->questions[$question->id] = new stdClass(); $responses[$response->id]->questions[$question->id]->answer = ''; $responses[$response->id]->questions[$question->id]->question_type = $question->question_type; } } if (!empty($pdfData->entries)) { foreach ($pdfData->entries as $entry) { if (isset($responses[$entry->response_id]) && isset($responses[$entry->response_id]->questions[$entry->question_id])) { if (!empty($entry->answer)) { if (empty($responses[$entry->response_id]->questions[$entry->question_id]->answer)) { $responses[$entry->response_id]->questions[$entry->question_id]->answer = $entry->answer; } else { $responses[$entry->response_id]->questions[$entry->question_id]->answer .= '<br/>' . $entry->answer; } if (!empty($entry->answer_image) && JFile::exists(S_IMAGES_UPLOAD_DIR . '/' . $entry->answer_image)) { //$image = JHtml::image(JURI::root(true).'/media/communitysurveys/images/'.$entry->answer_image, $entry->answer); $image = '<img src="' . JURI::root(true) . '/media/communitysurveys/images/' . $entry->answer_image . '">'; $responses[$entry->response_id]->questions[$entry->question_id]->answer .= '<br/>' . $image; } } if (!empty($entry->answer2)) { if (empty($responses[$entry->response_id]->questions[$entry->question_id]->answer)) { $responses[$entry->response_id]->questions[$entry->question_id]->answer = $entry->answer2; } else { $responses[$entry->response_id]->questions[$entry->question_id]->answer .= '<br/>' . $entry->answer2; } } if (!empty($entry->free_text)) { // do special types formatting // if ($responses[$entry->response_id]->questions[$entry->question_id]->question_type == S_SPECIAL_NAME) { $names = explode('|', $entry->free_text); if (!empty($names)) { $entry->free_text = $names[0] . '. ' . $names[1] . ' ' . $names[2]; } else { $entry->free_text = ''; } } else { if ($responses[$entry->response_id]->questions[$entry->question_id]->question_type == S_SPECIAL_ADDRESS) { $parts = explode('|||', $entry->free_text); if (count($parts) == 7) { $entry->free_text = '<address><strong>' . CJFunctions::escape($parts[0]) . '</strong><br>'; $entry->free_text .= CJFunctions::escape($parts[1]) . '<br>'; if (!empty($parts[2])) { $entry->free_text .= CJFunctions::escape($parts[2]) . '<br>'; } $entry->free_text .= CJFunctions::escape($parts[3]) . ', ' . CJFunctions::escape($parts[4]) . ', ' . CJFunctions::escape($parts[6]) . '<br>'; $entry->free_text .= !empty($countries[$parts[5]]) ? $countries[$parts[5]]->country_name : CJFunctions::escape($parts[5]); } else { $entry->free_text = ''; } } } // do special types formatting // if (empty($responses[$entry->response_id]->questions[$entry->question_id]->answer)) { $responses[$entry->response_id]->questions[$entry->question_id]->answer = $entry->free_text; } else { $responses[$entry->response_id]->questions[$entry->question_id]->answer .= '<br/>' . $entry->free_text; } } } } } $response_rows = array(); foreach ($responses as $id => $response) { $string = '<table class="table table-striped" width="100%">'; $string = $string . '<tr><th width="30%"><strong>Response ID:</strong></th><td width="70%">' . $id . '</td></tr>'; $string = $string . '<tr><th><strong>Response Date:</strong></th><td>' . $response->created . '</td></tr>'; $string = $string . '<tr><th><strong>User ID:</strong></th><td>' . $response->created_by . '</td></tr>'; $string = $string . '<tr><th><strong>Username:</strong></th><td>' . $response->username . '</td></tr>'; $string = $string . '<tr><th><strong>User Display Name:</strong></th><td>' . $response->name . '</td></tr>'; if ($include_email_in_reports == 1) { $string = $string . '<tr><td><strong>Email:</strong></td><td>' . $response->email . '</td></tr>'; } foreach ($pdfData->questions as $question) { $string = $string . '<tr><td colspan="2"> <hr></td></tr>'; $string = $string . '<tr><th colspan="2"><h3>' . $question->title . '</h3></th></tr>'; if (!empty($question->description)) { $string = $string . '<tr><td colspan="2">' . $question->description . '</td></tr>'; } $string = $string . '<tr><td colspan="2"> </td></tr>'; $string = $string . '<tr><td colspan="2">' . $response->questions[$question->id]->answer . '</td></tr>'; } $string = $string . '</table>'; array_push($response_rows, $string); } // create new PDF document require_once JPATH_COMPONENT_SITE . '/helpers/tcpdf.php'; $pdf = new MYPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set default header data $pdf->SetHeaderData('logo.png', PDF_HEADER_LOGO_WIDTH, $pdfData->title, ''); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('corejoomla.com'); $pdf->SetTitle('Survey Report'); $pdf->SetSubject('Survey Responses Report'); $pdf->SetKeywords('survey, report'); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); // --------------------------------------------------------- // set font $pdf->SetFont('freesans'); foreach ($response_rows as $i => $response) { $pdf->AddPage(); $pdf->writeHTML($response, true, false, true, false, ''); $pdf->lastPage(); } $pdf->Output($fileName, $mode); }
} $result = array(); if ($resultdb = $mysqli->query($queryString)) { while ($record = $resultdb->fetch_assoc()) { array_push($result, $record); } $resultdb->close(); } // create new PDF document $pdf = new MYPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Rafael Barzotto'); $pdf->SetTitle('Export Chart'); $pdf->SetSubject('Mastering Ext JS Book'); $pdf->SetHeaderData(PDF_HEADER_LOGO, 80, 'SYSLOG VIEWER', 'Relatório Gerado: ' . $date . ' usuário: ' . $_SESSION['username'], array(0, 64, 255), array(0, 64, 128)); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins //$pdf->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(20); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // ---------------------------------------------------------
$this->Cell($w[2], 6, $materie[$orario_classe->getMateria($classe, "Ven", $i + 1)][0] != "Scegli" ? $materie[$orario_classe->getMateria($classe, "Ven", $i + 1)][0] : "--", 'LR', 0, 'C', $fill); $this->Cell($w[3], 6, $materie[$orario_classe->getMateria($classe, "Sab", $i + 1)][0] != "Scegli" ? $materie[$orario_classe->getMateria($classe, "Sab", $i + 1)][0] : "--", 'LR', 0, 'C', $fill); $this->Ln(); $fill = !$fill; } $this->Cell(array_sum($w), 0, '', 'T'); } } // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor($author); $pdf->SetTitle($_SESSION['__classe__']->to_string()); // set default header data $pdf->SetHeaderData("", 0, "Scuola Media Statale \"Arborea - Lamarmora\" - secondaria di primo grado", "Via Isonzo, 5 - Iglesias (CI)"); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', 8.0)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', 8.0)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l);
$this->Ln(10); } public function Footer() { $this->SetY(-15); $this->SetFont('helvetica', '', 8); $this->Cell(0, 10, 'Pagina ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M'); } } $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('http://www.ariepi.org'); $pdf->SetTitle('Reporte'); $pdf->SetSubject('Reporte General'); $pdf->SetKeywords('reporte, general, ariepi'); $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, 'ARIEPI', 'Reporte General'); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) { require_once dirname(__FILE__) . '/lang/eng.php'; $pdf->setLanguageArray($l); } $pdf->SetFont('helvetica', '', 9); $pdf->AddPage('P', 'A4'); ob_end_clean();
function pdfGen($group_name, $mode = NULL, $start_date, $end_date, $stats, $l, $title, $path_www) { global $centreon_path; // create new PDF document $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document information $pdf->SetCreator("PDF Reports Module"); $pdf->SetAuthor(getGeneralOptInfo("pdfreports_report_author")); //$pdf->SetAuthor('Fully Automated Nagios'); $pdfTitle = $title . " " . $group_name; //$pdfTitle = "Rapport de supervision du hostgroup ".$group_name; $pdf->SetTitle($pdfTitle); //$pdf->SetSubject('TCPDF Tutorial'); //$pdf->SetKeywords('TCPDF, PDF, example, test, guide'); // define default header data $header = $title . " " . $group_name; //$header = "Rapport de supervision du hostgroup ".$group_name; //$ip = $_SERVER['HOSTNAME']; $startDate = date("d/m/Y", $start_date); $time = time(); $endDate = date("d/m/Y", $time); $string = _("From") . " " . strftime("%A", $start_date) . " " . $startDate . " " . _("to") . " " . strftime("%A", $time) . " " . $endDate . "\n"; // set default header data $pdf->SetHeaderData('../../../img/headers/' . getGeneralOptInfo("pdfreports_report_header_logo"), PDF_HEADER_LOGO_WIDTH, $header, $string); // set header and footer fonts $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); // set default monospaced font $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); //set margins $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); //set auto page breaks $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); //set image scale factor $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set some language-dependent strings $pdf->setLanguageArray($l); // --------------------------------------------------------- // set font $pdf->SetFont('helvetica', '', 12); // add a page $pdf->AddPage(); //Column titles $header = array('Status', 'Time', 'Total Time', 'Mean Time', 'Alert'); // Pie chart Generation $piechart_img = pieGen($stats, $mode); //Data loading $data = $pdf->LoadData($stats); // print colored table //$pdf->ColoredTable($header, $data,$chart_img); if ($mode == "hgs") { // Hostgroup $pdf->ColoredTable($header, $data, $piechart_img, $path_www); } else { if ($mode == "sgs") { // Servicegroup $pdf->ServicesColoredTable($header, $data, $piechart_img, $path_www); } } // --------------------------------------------------------- //génération d'un nom de pdf $endDay = date("d", $time); $endYear = date("Y", $time); $endMonth = date("m", $time); $pdfDirName = getGeneralOptInfo("pdfreports_path_gen") . $endYear . $endMonth . $endDay . "/"; $pdfFileName = $pdfDirName . $endYear . "-" . $endMonth . "-" . $endDay . "_" . $group_name . ".pdf"; if (!is_dir($pdfDirName)) { mkdir($pdfDirName); } //Close and output PDF document $pdf->Output($pdfFileName, 'F'); return $pdfFileName; }
function topdf() { $this->service_id = $_POST['service_id']; $this->startTime = strtotime($_POST['startTime']); $this->endTime = strtotime($_POST['endTime']); $this->time_type = $_POST['time_type']; require_once Kohana::find_file('helpers', 'tcpdf/config/lang/eng'); require_once Kohana::find_file('helpers', 'tcpdf/mypdf'); $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); $pdf->SetCreator("uooly"); $pdf->SetAuthor('上海雍立信息科技有限公司'); $pdf->SetTitle('雍立ASM应用安全审计报表'); $pdf->SetSubject('雍立ASM应用安全审计报表'); $logo_img = '../../../../assets/images/logo.png'; $logo_width = 15; $header_title = "雍立ASM应用安全审计"; $header_string = "2010年度报表"; $pdf->SetHeaderData($logo_img, $logo_width, $header_title, $header_string); $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN)); $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA)); $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); $pdf->setLanguageArray($l); $pdf->AddPage(); $pdf->SetFont('stsongstdlight', '', 10); if (!$this->client_ip) { $client_ip = "所有IP地址"; } if (!$this->user_name) { $user_name = "所有用户"; } if (!$this->criticality) { $criticality = "所有严重级别"; } if (!$this->operation) { $operation = "所有操作"; } $startTime = date("Y-m-d H:i:s", $this->startTime); $endTime = date("Y-m-d H:i:s", $this->endTime); switch ($this->time_type) { case "day": $chart_type = "日报"; break; case "week": $chart_type = "周报"; break; case "month": $chart_type = "月报"; break; case "year": $chart_type = "年报"; break; } $tbl = "<h1>hello world</h1>"; $tbl = "<div>"; $tbl .= '<table border="1" id="summary_table">'; $tbl .= '<tr>'; $tbl .= '<th colspan=2>统计条件</th>'; $tbl .= '</tr>'; $tbl .= '<tr>'; $tbl .= '<td>时间段包含</td>'; $tbl .= "<td>{$startTime} 至 {$endTime}</td>"; $tbl .= '</tr>'; $tbl .= '<tr>'; $tbl .= '<td>客户端包括</td>'; $tbl .= "<td>{$client_ip}</td>"; $tbl .= '</tr>'; $tbl .= '<tr>'; $tbl .= '<td><font color="red">用户名包括</font></td>'; $tbl .= "<td>{$user_name}</td>"; $tbl .= '</tr>'; $tbl .= '<tr>'; $tbl .= '<td>操作包括</td>'; $tbl .= "<td>{$operation}</td>"; $tbl .= '</tr>'; $tbl .= '<tr>'; $tbl .= '<td>紧急程度</td>'; $tbl .= "<td>{$criticality}</td>"; $tbl .= '</tr>'; $tbl .= '</table>'; $tbl .= "</div>"; $tbl .= "<div>"; $tbl .= '<img src="assets/export/stacked.jpg" width="500" height="310">'; $tbl .= "</div>"; $tbl .= "<div>"; $tbl .= '<img src="assets/export/1_clientip_column2d.jpg" width="500" height="310">'; $tbl .= "</div>"; $tbl .= "<div>"; $tbl .= '<img src="assets/export/1_username_column2d.jpg" width="500" height="310">'; $tbl .= "</div>"; $tbl .= "<div>"; $tbl .= '<img src="assets/export/1_operation_column2d.jpg" width="500" height="310">'; $tbl .= "</div>"; $pdf->writeHTML($tbl, true, false, false, false, ''); $pdf->Output('example_038.pdf', 'I'); }