本文介绍了我正在使用此代码的html到pdf,但它的显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 ob_start(); if(!defined('BASEPATH'))exit('不允许直接访问脚本'); class Payment extends CI_Controller { 函数__construct() { parent :: __ construct(); $ this-> load-> library('form_validation'); $ this-> load-> library('session'); $ this-> load-> helper('form'); $ this-> load-> helper('url'); $ this- > load-> library('cart'); $ this-> load-> database(); $ this-> load-> ; model('user_model'); $ this-> load-> helper('string'); $ this-> load-> library ('email'); $ this-> load-> library(pdf); } 公共职能pdf(){ $ pdf =新TCPDF(PDF_PAGE_ORIENTATION,PDF_UNIT,PDF_PAGE_FORMAT,true,'UTF-8',false); $ pdf-> SetCreator(PDF_CREATOR); $ pdf-> Se tAuthor('Nicola Asuni'); $ pdf-> SetTitle('TCPDF示例061'); $ pdf-> SetSubject('TCPDF Tutorial') ; $ pdf-> SetKeywords('TCPDF,PDF,示例,测试,指南'); //设置默认标题数据 $ pdf-> SetHeaderData(PDF_HEADER_LOGO,PDF_HEADER_LOGO_WIDTH,PDF_HEADER_TITLE。'061',PDF_HEADER_STRING); //设置标题和页脚字体 $ pdf-> setHeaderFont(数组(PDF_FONT_NAME_MAIN,'',PDF_FONT_SIZE_MAIN)); $ pdf-> setFooterFont(数组(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); // se t自动分页符 $ 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','',10); //添加页面 $ pdf-> AddPage(); $ html = <<< eof> < style> body {margin:0 auto;填充:0;背景:#f1f2f4; } img {border:0;} .ie8 {backgound:#f1f2f4;} 。凭证{ font-family:Arial,Helvetica,sans-serif; font-size:26px; text-decoration:none; font-weight:normal; 颜色:#000; padding-left:20px; text -shadow:1px 1px 1px #FFF; } .work { float:left; width :48%; 身高:汽车; 保证金权利:20px; } .work1 { 浮动:左; 宽度:48%; 身高:自动; } .work1_head { 浮动:左; 宽度:100%; 身高:自动; margin-bottom:10px; } .work1_head1 { float:left; width: auto; height:auto; margin-right:10px; margin-top:10px; } .work1_head2 { float:left; 宽度:230px; 身高:自动; font-size:13px; font-family:Arial,Helvetica,sans-serif; font-weight:normal; color: #000; 行高:20px; } .back { background-color:# 000; 颜色:#FFF; text-align:center; 填充:5px 10px 5px 10px; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; } < / style> < body> <! - 开始顶线 - > <! - 结束顶线 - > <! - 起始页 - > ; <! - Start Logo - > <! - End Logo - > <! - 开始最新消息 - > <! - 开始最新消息 - > <! - 开始最新消息 - 标题 - > < img src =images / side.jpgwidth =100%/> > 保龄球世界:2小时的保龄球和2个比萨饼。ob_start();if ( ! defined('BASEPATH')) exit('No direct script access allowed');class Payment extends CI_Controller {function __construct(){parent::__construct();$this->load->library('form_validation');$this->load->library('session');$this->load->helper('form');$this->load->helper('url');$this->load->library('cart');$this->load->database();$this->load->model('user_model');$this->load->helper('string');$this->load->library('email');$this->load->library("Pdf");}public function pdf(){$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);$pdf->SetCreator(PDF_CREATOR);$pdf->SetAuthor('Nicola Asuni');$pdf->SetTitle('TCPDF Example 061');$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.' 061', 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('helvetica', '', 10);// add a page$pdf->AddPage();$html = <<<eof><style>body { margin: 0 auto; padding: 0; background: #f1f2f4; }img {border: 0;}.ie8 {backgound: #f1f2f4;}.voucher {font-family:Arial, Helvetica, sans-serif;font-size:26px;text-decoration:none;font-weight:normal;color:#000;padding-left:20px;text-shadow:1px 1px 1px #FFF;}.work {float:left;width:48%;height:auto;margin-right:20px;}.work1 {float:left;width:48%;height:auto;}.work1_head {float:left;width:100%;height:auto;margin-bottom:10px;}.work1_head1 {float:left;width:auto;height:auto;margin-right:10px;margin-top:10px;}.work1_head2 {float:left;width:230px;height:auto;font-size:13px;font-family:Arial, Helvetica, sans-serif;font-weight:normal;color:#000;line-height:20px;}.back {background-color:#000;color:#FFF;text-align:center;padding:5px 10px 5px 10px;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;}</style><body><!-- Start Top Line --><!-- End Top Line --><!-- Start Page --><!-- Start Logo --><!-- End Logo --><!-- Start Last News --><!-- Start Last News --><!-- Start Last News - Title --><img src="images/side.jpg" width="100%"/>World of Bowling: 2 hours of bowling and pizza for two. Lorem Ipsum只是虚拟文本 Lorem Ipsum只是虚拟文本 Lorem Ipsum只是印刷和排版行业的虚拟文本。 Lorem Ipsum只是虚拟文本。 问题? 联系: Problem? Get in contact: [email protected] 凭证 Loremipsum示例文本,loremipsum示例文本loremipsum示例文本.Loremipsum示例文本,loremipsum示例文本loremipsum示例文本.Loremipsum示例文本,loremipsum示例文本loremipsum示例文本。 Loremipsum示例文本,loremipsum示例文本loremipsum示例文本。 Loremipsum sample text, loremipsum sample text loremipsum sample text.Loremipsum sample text, loremipsum sample text loremipsum sample text.Loremipsum sample text, loremipsum sample text loremipsum sample text.Loremipsum sample text, loremipsum sample text loremipsum sample text. Loremipsum示例文本。 Loremipsum示例文本。 Loremipsum示例文本。 Loremipsum示例文本。 Loremipsum示例文本。 Loremipsum示例文本。 您可以在我们向您发出优惠券之日起七个工作日内取消您购买此优惠,前提是此优惠券尚未兑换商户。 b $ b You may cancel your purchase of this deal within seven working days following the date on which we issued you the voucher provided that the voucher has not yet been redeemed with the merchant. 要取消您的优惠券并收到退款,请发送电子邮件至 [email protected] ,告知我们您的决定和理由取消后面。 To cancel your voucher and receive your refund, please email [email protected] informing us of your decision and your reason behind cancellation. 如果凭证未兑换且您在凭证发出后的7个工作日内要求退款,我们很乐意给您退款。 Provided that the voucher has not been redeemed and you have requested your refund within 7 working days of the voucher being issued, we will happily give you a refund. 推荐答案 this-> load-> library('form_validation'); this->load->library('form_validation'); this-> load-> ; library('session'); this->load->library('session'); this-> load-> helper('form'); this->load->helper('form'); 这篇关于我正在使用此代码的html到pdf,但它的显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-18 17:28