Jump to content

FPDF Class problem


aeroswat

Recommended Posts

I am trying to get a multi-page report to print correctly on all printers regardless of the manufacturer. I am having lots of issues with this task though and also having problems with getting the correct spacing. I want to divide the document into 3 partitions per page where it shows the exact same thing (aside from the number in the top right) for each partition. I need everything to fit on the page and i need the most printing area possible available to me. Here is what I have so far...

 

if($result) {
$pdf=new FPDF();
$pdf->SetAutoPageBreak(0);
if(mysql_num_rows($result)!=0) {			
	while($res=mysql_fetch_array($result)) {
		$pdf->AddPage();
		$pdf->SetMargins(0, 0, 0);
		$pdf->SetXY(0,0);
		$qryCode = "SELECT * FROM tblCodes WHERE Code='" . $res['Code'] . "'";
		$resultCode = mysql_query($qryCode);
		$resCode = mysql_fetch_array($resultCode);
		$qry2 = "SELECT StudentName FROM tblStudents WHERE StudentNumber=" . $res['StudentNumber'];
		$result2 = mysql_query($qry2);
		$res2 = mysql_fetch_array($result2);

		for($i=1;$i<4;$i++){
			$pdf->SetFont('Times','B',14);
			$pdf->Cell(120,5,'Alabama Instructional Resource Center for the Blind');
			$pdf->Cell(80,5,'ORDER ACKNOWLEDGEMENT');
			$pdf->Cell(3,5,$i);
			$pdf->Ln(7);
			$pdf->SetFont('Times','B',12);
			$pdf->Cell(100,0,'Alabama Institute for the Deaf and Blind');
			$pdf->SetFont('Times','',12);
			$pdf->Cell(65,0,"Process Date: " . $res['FDateOrdered']);
			$pdf->Cell(50,0,"Ship Date: " . $res['FShipDate']);
			$pdf->Ln(5);
			$pdf->SetFont('Times','B',12);
			$pdf->Cell(100,0,"P.O. Box 698, Talladega, AL 35161");
			$pdf->SetFont('Times','',12);
			$pdf->Cell(65,0,"Order Number: " . $res['OrderNumber']);
			$pdf->Cell(25,0,"Line Number: " . $res['Line']);
			$pdf->Ln(5);
			$pdf->SetFont('Times','B',12);
			$pdf->Cell(100,0,"1-256-761-3262 or 1-256-761-3337");
			$pdf->SetX(100);
			$pdf->SetFont('Times','',12);
			$pdf->MultiCell(100,4,"Title: " . wordwrap($res['BookTitle'],60,"\n"));
			$pdf->SetXY(0,21+(95*($i-1)));
			$pdf->MultiCell(100,5,wordwrap($resCode['Definition'],35,"\n"));
			$pdf->Ln(5*(3-ceil(strlen($resCode['Definition'])/30.00)));
			$pdf->SetX(100);
			$pdf->Cell(100,0,"ISBN#: " . $res['ISBNten']);
			$pdf->Ln(5);
			$pdf->Cell(70,0,$res['SchoolSystem']);
			$pdf->Cell(30,0,"Code: " . $res['Code']);
			$pdf->Cell(75,0,"Publisher: " . $res['Publisher']);
			$pdf->Cell(50,0,"Copyright: " . $res['Copyright']);
			$pdf->Ln(10);
			$pdf->SetX(5);
			$pdf->Cell(95,0,"Student: " . $res2['StudentName']);
			$pdf->Cell(70,0,"AIRCB#: " . $res['AIRCBNum']);
			$pdf->Ln(5);
			$pdf->SetX(10);
			$pdf->Cell(90,0,$res['ShipAttention']);
			$pdf->Cell(75,0,"Item#: " . $res['ItemNum']);
			$pdf->Cell(50,0,"Value: \$" . number_format($res['Cost'],2));
			$pdf->Ln(5);
			$pdf->SetX(10);
			$pdf->Cell(90,0,$res['ShipName']);
			$pdf->Cell(40,0,"Format: " . $res['FormatNeeded']);
			$pdf->Cell(35,0,"Grade: " . $res['StudentGrade']);
			$pdf->Cell(40,0,"Record #: " . $res['OrderYearNum']);
			$pdf->Ln(5);
			$pdf->SetX(10);
			$pdf->Cell(90,0,$res['ShipAddress']);
			$pdf->SetFont('Times','I',12);
			$pdf->Cell(100,0,"Upon receipt of item, please sign and return.");
			$pdf->Ln(5);
			$pdf->SetX(10);
			$pdf->SetFont('Times','',12);
			$pdf->Cell(105,0,$res['ShipCity'] . ", " . $res['ShipState'] . " " . $res['ShipZip']);
			$pdf->Ln(5);
			$pdf->SetX(100);
			$pdf->SetFont('Times','I',12);
			$pdf->Cell(70,0,"Signature_________________________");
			$pdf->Cell(40,0,"Date_________________");
			$pdf->Ln(10);
			$pdf->SetFont('Times','BI',12);
			$pdf->Cell(220,0,"All items MUST be returned to AIRCB ASAP at the completion of each course.",0,0,'C');
			$pdf->Ln(10);
		}
	}
}else{
	$pdf->SetFont('Times','B',20);
	$pdf->Cell(220,5,'There are no unfilled orders!',0,0,'C');
}
}
$pdf->Output();

 

I have printed this to 2 printers here without problems but the third is proving difficult. It cuts off the left edge. Does anyone know the issue I am having? The page setup also seems to be the exact same for both computers (Fit to printable area, Choose paper source by pdf page size, auto rotate and center)

Link to comment
https://forums.phpfreaks.com/topic/189037-fpdf-class-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.