Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress TCPDF错误:某些数据已经输出,can';t为我的xampp服务器发送PDF文件_Wordpress_Tcpdf - Fatal编程技术网

Wordpress TCPDF错误:某些数据已经输出,can';t为我的xampp服务器发送PDF文件

Wordpress TCPDF错误:某些数据已经输出,can';t为我的xampp服务器发送PDF文件,wordpress,tcpdf,Wordpress,Tcpdf,我试图通过我的wordpress插件生成pdf,但它重复了相同的错误。该问题的解决方案是什么? 我已经检查了php标记前后的空白 require_once(plugin_dir_path(__FILE__) . '/tcpdf/tcpdf.php'); // create new PDF document $pdf = new TCPD

我试图通过我的wordpress插件生成pdf,但它重复了相同的错误。该问题的解决方案是什么? 我已经检查了php标记前后的空白

       require_once(plugin_dir_path(__FILE__) . '/tcpdf/tcpdf.php');


                                    // create new PDF document
                                    $pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

                                    // set document information
                                    $pdf->SetCreator(PDF_CREATOR);
                                    //$pdf->SetAuthor('Our Code World');
                                    $pdf->SetTitle('First printed pdf!');
                                    // set default header data
                                    $pdf->SetHeaderData('', '', 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('helvetica');

                                    // set margins

                                    $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
                                    $pdf->SetMargins(PDF_MARGIN_LEFT, '5', PDF_MARGIN_RIGHT);
                                    $pdf->setPrintHeader(false);
                                    $pdf->setPrintFooter(false);
                                    // set auto page breaks
                                    $pdf->SetAutoPageBreak(TRUE, 10);
                                    //set font
                                    $pdf->SetFont('helvetica', '', 12);
                                    $pdf->AddPage();

                                    /*
                                     * content run from here
                                     */

                                    $content = '';
                                    $content .= '
                                        <table border="1" cellspacing="0" cellpadding="5">
                                            <tr>
                                                <th width="5%">ID</th>
                                                <th width="30%">Name</th>

                                            </tr>
                                    ';
                                    $content .= '
                                        <tr>
                                                <td>2574</td>
                                                <td>Rafiq</td>

                                            </tr>
                                    ';
                                    $content .= '</table>';


                                    $pdf->writeHTML($content);
                                    ob_end_clean();
                                    $pdf->Output("sample.pdf", "I");
require_once(plugin_dir_path(u文件).'/tcpdf/tcpdf.php');
//创建新的PDF文档
$pdf=新的TCPDF('P',pdf单元,pdf页面格式,真,'UTF-8',假);
//设置文档信息
$pdf->SetCreator(pdf\u CREATOR);
//$pdf->SetAuthor(“我们的代码世界”);
$pdf->SetTitle('First printed pdf!');
//设置默认标题数据
$pdf->SetHeaderData(“”,”,pdf\u标题\u标题,pdf\u标题\u字符串);
//设置页眉和页脚字体
$pdf->setHeaderFont(数组(pdf\u FONT\u NAME\u MAIN',pdf\u FONT\u SIZE\u MAIN));
$pdf->setFooterFont(数组(pdf字体名称数据),pdf字体大小数据);
//设置默认的单间距字体
$pdf->SetDefaultMonospacedFont('helvetica');
//设置边距
$pdf->SetFooterMargin(pdf\U MARGIN\U FOOTER);
$pdf->SetMargins(pdf_MARGIN_左,'5',pdf_MARGIN_右);
$pdf->setPrintHeader(假);
$pdf->setPrintFooter(false);
//设置自动分页符
$pdf->SetAutoPageBreak(TRUE,10);
//设置字体
$pdf->SetFont('helvetica','',12);
$pdf->AddPage();
/*
*内容从这里运行
*/
$content='';
$content.='
身份证件
名称
';
$content.='
2574
拉菲克
';
$content.='';
$pdf->writeHTML($content);
ob_end_clean();
$pdf->输出(“sample.pdf”,“I”);

我也面临类似的问题,我通过删除表标记的所有属性解决了这个问题。TCPDF只支持有限的属性,请尝试以下操作

    $content = '';
    $content .= '<table>
            <tr>
                <th>ID</th>
                <th>Name</th>
            </tr>';
    $content .= '<tr>
                <td>2574</td>
                <td>Rafiq</td>
            </tr>';
    $content .= '</table>';
$content='';
$content.='
身份证件
名称
';
$content.='
2574
拉菲克
';
$content.='';
包含“includes/session.php”;
$range=$\u POST['date\u range'];
$ex=爆炸('-',$range);
$from=日期('Y-m-d',标准时间($ex[0]);
$to=日期('Y-m-d',标准时间($ex[1]);
$sql=“选择*,总和(金额)作为扣除的总金额”;
$query=$conn->query($sql);
$drow=$query->fetch_assoc();
$扣减=$drow['总金额'];
$from_title=日期('md,Y',标准时间($ex[0]);
$to_title=日期('md,Y',标准时间($ex[1]);
需要一次('../tcpdf/tcpdf.php');
$pdf=新的TCPDF('P',pdf单元,pdf页面格式,真,'UTF-8',假);
$pdf->SetCreator(pdf\u CREATOR);
$pdf->SetTitle(“工资单:'.$from_title.-'.$to_title”);
$pdf->SetHeaderData(“”,”,pdf\u标题\u标题,pdf\u标题\u字符串);
$pdf->setHeaderFont(数组(pdf\u FONT\u NAME\u MAIN',pdf\u FONT\u SIZE\u MAIN));
$pdf->setFooterFont(数组(pdf字体名称数据),pdf字体大小数据);
$pdf->SetDefaultMonospacedFont('helvetica');
$pdf->SetFooterMargin(pdf\U MARGIN\U FOOTER);
$pdf->SetMargins(pdf_MARGIN_左,'10',pdf_MARGIN_右);
$pdf->setPrintHeader(假);
$pdf->setPrintFooter(false);
$pdf->SetAutoPageBreak(TRUE,10);
$pdf->SetFont('helvetica','',11);
$pdf->AddPage();
$contents='';
$sql=“SELECT*,总和(num\u hr)作为total_hr,Attention.employee_id作为empid,employees.employee_id作为employees中的员工离开加入员工。id=Attention.employee_id离开加入职位。id=employees.position_id,其中日期介于“$FROM”和“$to”之间,按考勤分组。员工id按员工排序。lastname ASC,employees.firstname ASC”;
$query=$conn->query($sql);
而($row=$query->fetch\u assoc()){
$empid=$row['empid'];
$casql=“选择*,SUM(amount)作为现金预付款中的现金金额,其中员工id=“$empid”,日期在“$FROM”和“$to”之间;
$caquery=$conn->query($casql);
$carow=$caquery->fetch_assoc();
$cashadvance=$carow['cashamount'];
$gross=$row['rate']*$row['total_hr'];
$total_Deception=$Deception+$cashadvance;
$净额=$总额-$扣除总额;
$contents.='
TechSoft IT解决方案
“.$从标题。”-“$到标题。”
员工姓名:
“.$row['firstname']”..$row['lastname']”
每小时收费:
“.number_格式($row['rate'],2)。”
员工ID:
“.$row['employee']”
总小时数:
“.number_格式($row['total_hr'],2)。”
include 'includes/session.php';

$range = $_POST['date_range'];
$ex = explode(' - ', $range);
$from = date('Y-m-d', strtotime($ex[0]));
$to = date('Y-m-d', strtotime($ex[1]));

$sql = "SELECT *, SUM(amount) as total_amount FROM deductions";
$query = $conn->query($sql);
$drow = $query->fetch_assoc();
$deduction = $drow['total_amount'];

$from_title = date('M d, Y', strtotime($ex[0]));
$to_title = date('M d, Y', strtotime($ex[1]));

require_once('../tcpdf/tcpdf.php');  
$pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);  
$pdf->SetCreator(PDF_CREATOR);  
$pdf->SetTitle('Payslip: '.$from_title.' - '.$to_title);  
$pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_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('helvetica');  
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);  
$pdf->SetMargins(PDF_MARGIN_LEFT, '10', PDF_MARGIN_RIGHT);  
$pdf->setPrintHeader(false);  
$pdf->setPrintFooter(false);  
$pdf->SetAutoPageBreak(TRUE, 10);  
$pdf->SetFont('helvetica', '', 11);  
$pdf->AddPage(); 
$contents = '';

$sql = "SELECT *, SUM(num_hr) AS total_hr, attendance.employee_id AS empid, employees.employee_id AS employee FROM attendance LEFT JOIN employees ON employees.id=attendance.employee_id LEFT JOIN position ON position.id=employees.position_id WHERE date BETWEEN '$from' AND '$to' GROUP BY attendance.employee_id ORDER BY employees.lastname ASC, employees.firstname ASC";

$query = $conn->query($sql);
while($row = $query->fetch_assoc()){
    $empid = $row['empid'];
                  
    $casql = "SELECT *, SUM(amount) AS cashamount FROM cashadvance WHERE employee_id='$empid' AND date_advance BETWEEN '$from' AND '$to'";
  
    $caquery = $conn->query($casql);
    $carow = $caquery->fetch_assoc();
    $cashadvance = $carow['cashamount'];

    $gross = $row['rate'] * $row['total_hr'];
    $total_deduction = $deduction + $cashadvance;
    $net = $gross - $total_deduction;

    $contents .= '
        <h2 align="center">TechSoft IT Solutions</h2>
        <h4 align="center">'.$from_title." - ".$to_title.'</h4>
        <table cellspacing="0" cellpadding="3">  
            <tr>  
                <td width="25%" align="right">Employee Name: </td>
                <td width="25%"><b>'.$row['firstname']." ".$row['lastname'].'</b></td>
                <td width="25%" align="right">Rate per Hour: </td>
                <td width="25%" align="right">'.number_format($row['rate'], 2).'</td>
            </tr>
            <tr>
                <td width="25%" align="right">Employee ID: </td>
                <td width="25%">'.$row['employee'].'</td>   
                <td width="25%" align="right">Total Hours: </td>
                <td width="25%" align="right">'.number_format($row['total_hr'], 2).'</td> 
            </tr>
            <tr> 
                <td></td> 
                <td></td>
                <td width="25%" align="right"><b>Gross Pay: </b></td>
                <td width="25%" align="right"><b>'.number_format(($row['rate']*$row['total_hr']), 2).'</b></td> 
            </tr>
            <tr> 
                <td></td> 
                <td></td>
                <td width="25%" align="right">Deduction: </td>
                <td width="25%" align="right">'.number_format($deduction, 2).'</td> 
            </tr>
            <tr> 
                <td></td> 
                <td></td>
                <td width="25%" align="right">Cash Advance: </td>
                <td width="25%" align="right">'.number_format($cashadvance, 2).'</td> 
            </tr>
            <tr> 
                <td></td> 
                <td></td>
                <td width="25%" align="right"><b>Total Deduction:</b></td>
                <td width="25%" align="right"><b>'.number_format($total_deduction, 2).'</b></td> 
            </tr>
            <tr> 
                <td></td> 
                <td></td>
                <td width="25%" align="right"><b>Net Pay:</b></td>
                <td width="25%" align="right"><b>'.number_format($net, 2).'</b></td> 
            </tr>
        </table>
        <br><hr>
    ';
}
$pdf->writeHTML($contents);  
$pdf->Output('payslip1.pdf', 'I');