TCPDF仍然不适合我

问题描述 投票:2回答:1

我不确定我做错了什么。我正在尝试使用tcpdf从我的表单生成pdf。当我点击提交它只是打开一个空白的网页,我根本没有收到任何PDF格式。当我链接示例以查看它是否是安装问题时,它们可以完美地工作。有什么办法可以解决这个问题吗?

我的HTML

<h2>Proto/Addendum Form</h2>
<p>
<form method="post" action="pdfcreate.php">
Job #: <input type="text" name="jobnum">
<br>
Program: <input type="text" name="program"><br />
Ship Date: <input type="text" name="shipdate"><br />
Description: <input type="text" style="height:100px; width:85%" name="description"><br /><br />
Proto Verified By: <input type="text" name="name"><br /><br />
Additional Notes: <input type="text" style="height:100px; width:85%" name="notes"><br />
<br /><br />
<h2>White Stock</h2>
Filename<input type="text" name="filename1" style="width:85%"><br />
Doc size<input type="text" name="Docsize1" size="6">
FC<input type="checkbox" name="fc1" value="fc">
DC<input type="checkbox" name="dc1" value="dc">
Flip<input type="checkbox" name="flip1" value="flip">
Quantity<input type="text" name="quantity1" size="6">
Flip Quantity<input type="text" name="flipqty1" size="6">
<br />

<input type="submit" name="value" value="submit" />
</form>

我的PHP:

<?php


// Include the main TCPDF library 
//(search for installation path).

require_once('tcpdf_include.php');


// create new PDF document

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);


// set document information

$pdf->SetCreator(PDF_CREATOR);

$pdf->SetTitle('proto_addendum');

$pdf->SetSubject('jobnum');


// set default header data

$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 01', 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);


// ---------------------------------------------------------


// IMPORTANT: disable font subsetting to allow users editing the document

$pdf->setFontSubsetting(false);


// set font

$pdf->SetFont('helvetica', '', 10, '', false);


// add a page

$pdf->AddPage();


//data
$pdf->writeHTMLCell(0,0,0,0, "Job Number ". $_POST["jobnum"], $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true);

$pdf->writeHTMLCell(0,0,0,5, "Program ". $_POST["program"], $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true);

$pdf->writeHTMLCell(0,0,0,10, "Ship Date ". $_POST["shipdate"], $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true);

$pdf->writeHTMLCell(0,0,0,15, "Description ". $_POST["description"], $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true);

$pdf->writeHTMLCell(0,0,0,20, "Proto Verified By ". $_POST["name"], $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true);

$pdf->writeHTMLCell(0,0,0,25, "Additional Notes ". $_POST["notes"], $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true);

$pdf->writeHTMLCell(0,0,0,30, "File Name". $_POST["filename1"], $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true);

$pdf->writeHTMLCell(0,0,0,35, "Doc Siize ". $_POST["Docsize1"], $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true);

$pdf->writeHTMLCell(0,0,0,40, "FC ". $_POST["fc1"], $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true);

$pdf->writeHTMLCell(0,0,0,45, "DC ". $_POST["dc1"], $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true);

$pdf->writeHTMLCell(0,0,0,50, "Flip ". $_POST["flip1"], $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true);

$pdf->writeHTMLCell(0,0,0,55, "Quantity ". $_POST["quantity1"], $border=0, $ln=0, $fill=false, $reseth=true, $align='', $autopadding=true);

$pdf->writeHTMLCell(0,0,0,60, "Flip Quantity ". $_POST["flipqty1"], $border=0, $ln=0,   $fill=false, $reseth=true, $align='', $autopadding=true);




// Add Javascript code

$pdf->IncludeJS($js);


// ---------------------------------------------------------


//Close and output PDF document

$pdf->Output('job.pdf', 'D');

?>

编辑 - 谢谢......这是我收到的警告:警告:require_once(tcpdf_include.php):无法打开流:第26行的C:\ inetpub \ wwwroot \ intranet2 \ pdfcreate.php中没有此类文件或目录致命错误:require_once():在第26行的C:\ inetpub \ wwwroot \ intranet2 \ pdfcreate.php中打开所需的'tcpdf_include.php'(include_path ='。; C:\ php \ pear')失败

edit2 - 移动了一些东西,现在这是我收到的错误:致命错误:在第31行的C:\ inetpub \ wwwroot \ intranet2 \ pdfcreate.php中找不到类'TCPDF'

edit3任何人都可以帮忙吗?我卡住了。

edit4我可能会到达某个地方。将tcpdf_include.php更改为tcpdf.php然后:注意:未定义的索引:第117行的C:\ inetpub \ wwwroot \ intranet2 \ pdfcreate.php中的fc1注意:未定义的索引:C:\ inetpub \ wwwroot \ intranet2 \ pdfcreate中的dc1第119行的.php注意:未定义的索引:第13行的C:\ inetpub \ wwwroot \ intranet2 \ pdfcreate.php中的flip1 TCPDF错误:有些数据已经输出,无法发送PDF文件

我相信我的问题是复选框。有没有办法,如果他们没有设置,这将通过?

编辑5我修复了复选框问题,但我仍然得到“TCPDF错误:某些数据已经输出,无法发送PDF文件”

php tcpdf
1个回答
0
投票

要使用require_once查找错误,请尝试以下方法:

$filename = realpath('tcpdf_include.php');
var_dump($filename);

当出现问题时,它会输出bool(false)。

要检查是否只是保存pdf的问题,请尝试仅显示该文件:

$pdf->Output($pdfSavePathFilename, 'I');

要测试它是否是与访问权限相关的问题,请尝试:

fopen($pdfSavePathFilename,'w+');

要在测试期间禁用php警告,请使用:

error_reporting(0);
© www.soinside.com 2019 - 2024. All rights reserved.