Php – TCPDF still not working for me

PHPtcpdf

I am unsure at what I am doing wrong. I am trying to use tcpdf to generate a pdf from my form. When I click submit It just brings up a blank webpage and I do not receive any pdf at all. When I link the examples to see if it is an install problem they work flawlessly. is there anything I can do to fix this?

My 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>

my 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');

?>

edit
thanks… This is the warning that I recieve: Warning: require_once(tcpdf_include.php): failed to open stream: No such file or directory in C:\inetpub\wwwroot\intranet2\pdfcreate.php on line 26 Fatal error: require_once(): Failed opening required 'tcpdf_include.php' (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\intranet2\pdfcreate.php on line 26

edit2 – moved some stuff around and now this is the error i am receiving: Fatal error: Class 'TCPDF' not found in C:\inetpub\wwwroot\intranet2\pdfcreate.php on line 31

edit3 can anyone help? im stuck.

edit4 I might be getting somewhere. changed tcpdf_include.php to just tcpdf.php then:
Notice: Undefined index: fc1 in C:\inetpub\wwwroot\intranet2\pdfcreate.php on line 117 Notice: Undefined index: dc1 in C:\inetpub\wwwroot\intranet2\pdfcreate.php on line 119 Notice: Undefined index: flip1 in C:\inetpub\wwwroot\intranet2\pdfcreate.php on line 121 TCPDF ERROR: Some data has already been output, can't send PDF file

I believe that my problem is the check boxes. is there a way if they are not set that this will go through?

edit 5 i fixed the checkbox issue but i am still getting "TCPDF ERROR: Some data has already been output, can't send PDF file"

Best Answer

To find errors with require_once try something like:

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

It outputs bool(false) when something went wrong.

To check whether it's just a problem with saving the pdf try just to display the file for a try:

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

To test whether it's an access-rights related problem try:

fopen($pdfSavePathFilename,'w+');

To disable php warnings during tests use:

error_reporting(0);