我正在使用fpdf库为我的系统设计一些销售报告。我这个图书馆没问题 直到现在我创建了第一个报告。
正在发生的事情是,我必须在每天结束时创建一个包含所有销售信息的报告。这个 信息保存在数据库中,因此要创建pdf文档,我首先需要进行一些查询才能获取数据。 我这样做没有问题。当创建的pdf文档有很多页面时,麻烦就开始了。的设计 当信息必须在下一页继续时,文档中断。
在此图像上,您可以看到我想说的话:
如您所见,发生分页符时,信息不会转到新页面的开头,并且不会保留 相同的设计。相反,信息以错误的方式放在不同的页面中。
这是我创建pdf的PHP代码:
require('../fpdf17/fpdf.php');
include ("PrintTickets2.php");
Connection::open_db();
function generateRandomString($length) {
return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
}
$status = "Processed";
$poststatus = "Finished";
$id = intval($_GET['id']);
$AllIngredients = "";
$Result = PrintTickets2::CheckOrderToPrint(Connection::GetConnection(), $id);
$date_timeOrder= $Result[8];
if($Result)
{
$orderNum = $Result[0];
$Result2 = PrintTickets2::GlobalGetGeneral(Connection::GetConnection(), 1);
$restaurent = $Result2[2];
$adresse = $Result2[4];
$adresse = str_replace("<br>", "", $Result2[4]);
$celphone = $Result2[5];
$email = $Result2[6];
$coin = $Result2[3];
$IDRest = "YG84784FOSJD-00";
$Result3 = PrintTickets2::GetCustomerOrders(Connection::GetConnection(), $Result[1]);
$name = $Result3[1] ." ". $Result3[2];
$telefone = $Result3[8];
$emailCos = $Result3[9];
$ID_Client = $Result3[0];
$Result4 = PrintTickets2::CheckPreOrderToPrint(Connection::GetConnection(), $Result[1]);
$type_orders = $Result4[5];
if ($type_orders == "TAKE_OVER")
{
$type_orders = "TAKE OVER";
}
else if ($type_orders == "DELIVERY")
{
$type_orders = "DELIVERY";
}
$ResultPayment = PrintTickets2::GetPaymentInformations(Connection::GetConnection(), $id);
$paymentMethod = $ResultPayment[6];
$paymentName = "";
if ($paymentMethod == "Cash")
{
$paymentName = "Cash";
}
else
{
$paymentName = $paymentMethod;
}
$order_date_and_time = "";
$address786876786 = [];
if ($type_orders == "TAKE_OVER")
{
$Result15 = PrintTickets2::GetAllTakeOverDetailsByID(Connection::GetConnection(), $id);
$originalDate = $Result15[0][2];
$newDate = date("d.m.Y", strtotime($originalDate));
$order_date_and_time = "Date/Time: ". $newDate ."/". $Result15[0][3];
}
else if ($type_orders == "DELIVERY")
{
$Result16 = PrintTickets2::GetAllDeliveryDetailsByID(Connection::GetConnection(), $id);
$originalDate2 = $Result16[0][3];
$newDate2 = date("d.m.Y", strtotime($originalDate2));
$address786876786 = explode(" ", $Result16[0][2]);
$order_date_and_time = "Date/Hour: ". $newDate2 ."/". $Result16[0][4] ."\n"."Address: ".utf8_decode($address786876786[0]) ."PLZ. " . $address786876786[1] . " Ort. " . $address786876786[2];
}
$pdf = new FPDF($orientation='P', $unit='mm', 'A4');
$pdf->AddPage();
$pdf->SetFont('Arial','B',12); //Arial, (Bold), tam. 20
$pdf->SetTextColor(255, 255, 255);
$pdf->setX(30);
$pdf->Image("logo_company.JPEG",52,0,50,10);
$pdf->setY(11);
$pdf->setX(30);
$pdf->Multicell(90,5,".:: ".$restaurent." ::.", 1,"C", 1);
$pdf->SetFont('Arial','B',10);
$pdf->setX(30);
$pdf->Multicell(90,5,"Tel. " .$celphone."\n"."E-Mail: ".$email, 1,"C", 1);
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(0, 0, 0);
$pdf->setX(10);
$pdf->Multicell(126,5,"Date/Hour: " . date('d.m.Y H:i:s')."\n"."Customer: ".utf8_decode($name)."\n"."Order ID: ".$orderNum."\n"."Order Type: ".$type_orders."\n".$order_date_and_time."\n"."Payment Type: ".utf8_decode($paymentName), 0,"C", 0);
$pdf->setX(10);
$pdf->SetFillColor(202, 0, 0);
$pdf->Multicell(126,1," ",0,"C", 1);
//--------------------------------------------HEADER-----------------------------------------------------
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(0, 0, 0);
$y = $pdf->GetY();
$pdf->SetY($y);
$pdf->SetFont('Arial','B',10);
$y = $pdf->GetY();
$pdf->MultiCell(15,5,"QNT.",0,'L',0);
$pdf->SetXY(25,$y);
$y = $pdf->GetY();
$pdf->MultiCell(81,5,"PRODUCT",0,'L',0);
$pdf->SetXY(106,$y);
$y = $pdf->GetY();
$pdf->MultiCell(30,5,"PRICE",0,'L',0);
//---------------------------------------------HEADER--------------------------------------
$pdf->SetFont('Arial','B',10);
$pdf->SetTextColor(0, 0, 0);
//----------------------------------------------------------------------------------------
$dish_details = "";
$Result6 = PrintTickets2::CheckOrderDetailsToPrint(Connection::GetConnection(), $Result[0]);
$DISHES_NUM = count($Result6);
$subtotalPrice = $Result[2];
$totalRabatt = $Result[3];
$total = $Result[5]; //$Result[2];
for ($i=0; $i < count($Result6); $i++)
{
$price = 0;
$Result5 = PrintTickets2::CheckOrderDishesToPrint(Connection::GetConnection(), $Result6[$i][2]);
//print_r($Result5);
if ($type_orders == "LIEFERN")
{
$Result10 = PrintTickets2::GetAllMenuDetailsByID(Connection::GetConnection(), $Result5[0][0], $Result6[$i][4]);
for ($j=0; $j < $Result6[$i][3]; $j++)
{
$price = ($price + $Result10[0][4]);
}
}
else if ($type_orders == "ABHOLEN")
{
$Result10 = PrintTickets2::GetAllMenuDetailsByID(Connection::GetConnection(), $Result5[0][0], $Result6[$i][4]);
for ($j=0; $j < $Result6[$i][3]; $j++)
{
$price = ($price + $Result10[0][3]);
}
}
$y = $pdf->GetY();
$pdf->SetY($y+2);
$pdf->SetFont('Arial','B',10);
$y = $pdf->GetY();
$pdf->MultiCell(15,4,$Result6[$i][3],0,'L',0);
$pdf->SetXY(25,$y);
$y = $pdf->GetY();
$pdf->MultiCell(81,4,utf8_decode($Result5[0][6]). " " .utf8_decode($Result5[0][2]). " (".$Result6[$i][4] .") Valor de Y: " .$y,0,'L',0);
$pdf->SetXY(106,$y);
$y = $pdf->GetY();
$pdf->MultiCell(30,4,number_format($price, 2, ".", "") . " ".$coin,0,'L',0);
//FREE ITEMS-------------------------------------------------------------------------------
$Result110 = PrintTickets2::GetAllIngredientsDishInOrder(Connection::GetConnection(), $Result[0]);
if ($Result110)
{
for ($r=0; $r < count($Result110); $r++)
{
if (intval($Result110[$r][6]) == intval($Result5[0][0]) && intval($Result110[$r][8]) == intval($Result6[$i][6]) && $Result6[$i][5] == $Result110[$r][7])
{
$AllIngredients = $AllIngredients.", ".utf8_decode($Result110[$r][5]);
}
else
{
}
}
$AllIngredients = trim($AllIngredients, ", ");
$y = $pdf->GetY();
$pdf->SetY($y);
$pdf->SetFont('Arial','B',8);
$y = $pdf->GetY();
$pdf->MultiCell(15,4,"",0,'L',0);
$pdf->SetXY(25,$y);
$y = $pdf->GetY();
$pdf->MultiCell(81,4,$AllIngredients,0,'L',0);
$pdf->SetXY(106,$y);
$y = $pdf->GetY();
$pdf->MultiCell(30,4,"",0,'L',0);
}
$AllIngredients = "";
//EXTRA ITEMS--------------------------------------------------------------------------------------
$Result11 = PrintTickets2::GetAllExtraToPrintOrders(Connection::GetConnection(), $Result[0], $Result6[$i][2], $Result6[$i][6]);
if ($Result11)
{
for ($k=0; $k < count($Result11); $k++)
{
$y = $pdf->GetY();
$pdf->SetY($y);
$pdf->SetFont('Arial','B',8);
$y = $pdf->GetY();
$pdf->MultiCell(15,4,"",0,'L',0);
$pdf->SetXY(25,$y);
$y = $pdf->GetY();
$pdf->MultiCell(81,4,$Result11[$k][4] . "x (XXOUT43) " . utf8_decode($Result11[$k][6]),0,'L',0);
$pdf->SetXY(106,$y);
$y = $pdf->GetY();
$pdf->MultiCell(30,4,$Result11[$k][5]. " ".$coin,0,'L',0);
}
}
} //for result6
//-------------------------------------------------------
$pdf->setX(10);
$pdf->SetFillColor(202, 0, 0);
$pdf->Multicell(126,1," ",0,"C", 1);
//---------------------------------------------------------subtotal
$y = $pdf->GetY();
$pdf->SetY($y+3);
$pdf->SetFont('Arial','B',10);
$y = $pdf->GetY();
$pdf->MultiCell(15,5,"",0,'L',0);
$pdf->SetXY(25,$y);
$y = $pdf->GetY();
$pdf->MultiCell(81,5,"Subtotal",0,'L',0);
$pdf->SetXY(106,$y);
$y = $pdf->GetY();
$pdf->MultiCell(30,5,$subtotalPrice." ".$coin,0,'L',0);
//------------------------------------------------------------discount
$y = $pdf->GetY();
$pdf->SetY($y);
$pdf->SetFont('Arial','B',10);
$y = $pdf->GetY();
$pdf->MultiCell(15,5,"",0,'L',0);
$pdf->SetXY(25,$y);
$y = $pdf->GetY();
$pdf->MultiCell(81,5,"Discount",0,'L',0);
$pdf->SetXY(106,$y);
$y = $pdf->GetY();
$pdf->MultiCell(30,5,$totalRabatt." ".$coin,0,'L',0);
//--------------------------------------------------------------total
$y = $pdf->GetY();
$pdf->SetY($y);
$pdf->SetFont('Arial','B',10);
$y = $pdf->GetY();
$pdf->MultiCell(15,5,"",0,'L',0);
$pdf->SetXY(25,$y);
$y = $pdf->GetY();
$pdf->MultiCell(81,5,"Total to Pay",0,'L',0);
$pdf->SetXY(106,$y);
$y = $pdf->GetY();
$pdf->MultiCell(30,5,$total." ".$coin,0,'L',0);
$url_pdf = "documents/SalesDetails".date('d-m-y').".pdf";
$pdf->output($url_pdf,"F");
}
else
{
echo "No information available.";
}
Connection::close_db();
此库中是否有解决此问题的方法?