TCPDF: иногда добавляется новая страница, затем содержимое следующей страницы переполняетсяPhp

Кемеровские программисты php общаются здесь
Ответить Пред. темаСлед. тема
Anonymous
 TCPDF: иногда добавляется новая страница, затем содержимое следующей страницы переполняется

Сообщение Anonymous »

Мне нужно создать один PDF-файл с использованием библиотеки tcpdf. Я столкнулся с проблемой переполнения контента на следующей странице. когда-нибудь добавьте новую страницу, а затем содержимое следующей страницы переполнится. эта проблема возникает на нескольких страницах.

МОЙ PHP-КОД

Код: Выделить всё

public function getPdfToAllEmpReport(){

//header("Content-type:application/pdf");
$user_id = Auth::user()->get()->id;
$company_id = Auth::user()->get()->company_id;
$input = Input::all();
if(!isset($input) && empty($input)){
$input = array();
}

// Company based Userlist
$userData = CompanyUser::getCompanyUserList()->toArray();
$userRewardsData = $this->getUsersRewards($userData,$input);

$company = CompanyMaster::getCompanyDetails()->toArray();
$search_string = "";
if(!empty($company) &&  !empty($userRewardsData)){

PDF::SetTitle($company['company_name']." - All Employee Report");

PDF::SetHeaderMargin(5);
PDF::SetFooterMargin(10);

PDF::SetFont('','',10);
PDF::SetHeaderData('', '', $company['company_name']." - All Employee Report", $search_string);
PDF::SetMargins(10, 20, 10);

PDF::AddPage();

$w = array(50,20,20,20,19,19,19,23);
$sw = array(60,56,27,27,20);
$h = 5;

$total_height = 0;
PDF::Ln();
PDF::SetFillColor(128, 0, 96);
PDF::SetTextColor(255, 255, 255);
PDF::SetFont('','B',9);
// Data
PDF::MultiCell($w[0], 10, "Worker Name", 'LRB', 'L' , 1, 0);
PDF::MultiCell($w[1], 10, "Applause Received", 'RB', 'L', 1, 0);
PDF::MultiCell($w[2], 10, "Drumbeat Received", 'RB', 'L' , 1, 0);
PDF::MultiCell($w[3], 10, "Ding Received", 'RB', 'L' , 1, 0);
PDF::MultiCell($w[4], 10, "Shoutout Sent", 'RB', 'L' , 1, 0);
PDF::MultiCell($w[5], 10, "Rally Response", 'RB', 'L' , 1, 0);
PDF::MultiCell($w[6], 10, "Project Reward", 'RB', 'L' , 1, 0);
PDF::MultiCell($w[7], 10, "Engagement Donation", 'RB', 'L' , 1, 0);
PDF::Ln();
$i=1;

$total_height = 10;
foreach ($userRewardsData['finalData'] as $user) {
PDF::SetFillColor(38, 115, 38);

PDF::SetTextColor(255,255,255);
PDF::SetFont('','B',9);
PDF::MultiCell($w[0], $h, $user['user_info']['full_name'], 'LRB', 'L', 1, 0);
PDF::MultiCell($w[1], $h, number_format($user['applauseData']['count']), 'RB', 'L', 1, 0);
PDF::MultiCell($w[2], $h, number_format($user['dingData']['count']), 'RB', 'L', 1, 0);
PDF::MultiCell($w[3], $h, number_format($user['drumbeatData']['count']), 'RB', 'L', 1, 0);
PDF::MultiCell($w[4], $h, number_format($user['shoutoutData']['count']), 'RB', 'L', 1, 0);
PDF::MultiCell($w[5], $h, number_format($user['rallyResponceData']['count']), 'RB', 'L', 1, 0);
PDF::MultiCell($w[6], $h, number_format($user['projectData']['count']), 'RB', 'L', 1, 0);
PDF::MultiCell($w[7], $h, number_format($user['engagementData']['count']), 'RB', 'L', 1, 0);
PDF::Ln();
PDF::SetFont('','',9);
PDF::SetTextColor(0,0,0);
$total_height = $this->setNewPage($total_height,$h,$search_string);
if(!empty($user['applauseData']['data'])){
PDF::SetFillColor(180, 180, 180);
PDF::MultiCell($sw[0], $h, "Applause - Reward Name", 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, "Issued by", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "Active / Inactive", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, "Issue date", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, "Points", 'RB', 'L', 1, 0);
PDF::Ln();

$total_height = $this->setNewPage($total_height,$h,$search_string);
foreach ($user['applauseData']['data'] as $data) {
PDF::SetFillColor(255, 255, 255);
PDF::MultiCell($sw[0], $h, $data['reward_name'], 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, $data['from_user'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "YES", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, $data['attaboy_date'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, number_format($data['points']), 'RB', 'L', 1, 0);
PDF::Ln();
$total_height = $this->setNewPage($total_height,$h,$search_string);
}
}

if(!empty($user['dingData']['data'])){
PDF::SetFillColor(180, 180, 180);
PDF::MultiCell($sw[0], $h, "Ding - Reward Name", 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, "Issued by", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "Active / Inactive", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, "Issue date", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, "Points", 'RB', 'L', 1, 0);
PDF::Ln();
$total_height = $this->setNewPage($total_height,$h,$search_string);
foreach ($user['dingData']['data'] as $data) {
PDF::SetFillColor(255, 255, 255);
PDF::MultiCell($sw[0], $h, $data['reward_name'], 'LRB', 'L', 1,  0);
PDF::MultiCell($sw[1], $h, $data['from_user'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "YES", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, $data['attaboy_date'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, number_format($data['points']), 'RB', 'L', 1, 0);
PDF::Ln();
$total_height = $this->setNewPage($total_height,$h,$search_string);
}
}

if(!empty($user['drumbeatData']['data'])){
PDF::SetFillColor(180, 180, 180);
PDF::MultiCell($sw[0], $h, "Drumbeat - Reward Name", 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, "Issued by", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "Active / Inactive", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, "Issue date", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, "Points", 'RB', 'L', 1, 0);
PDF::Ln();
$total_height = $this->setNewPage($total_height,$h,$search_string);
foreach ($user['drumbeatData']['data'] as $data) {
PDF::SetFillColor(255, 255, 255);
PDF::MultiCell($sw[0], $h, $data['reward_name'], 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, $data['from_user'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "YES", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, $data['attaboy_date'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, number_format($data['points']), 'RB', 'L', 1, 0);
PDF::Ln();
$total_height = $this->setNewPage($total_height,$h,$search_string);
}
}

if(!empty($user['shoutoutData']['data'])){
PDF::SetFillColor(180, 180, 180);
PDF::MultiCell($sw[0], $h, "Shoutout - Reward Name", 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, "Issued by", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "Active / Inactive", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, "Issue date", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, "Points", 'RB', 'L', 1, 0);
PDF::Ln();
$total_height = $total_height+$h;
if($total_height%260==0){
PDF::AddPage();
$total_height =0;
}
foreach ($user['shoutoutData']['data'] as $data) {
PDF::SetFillColor(255, 255, 255);
PDF::MultiCell($sw[0], $h, $data['reward_name'], 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, $data['from_user'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "YES", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, $data['attaboy_date'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, number_format($data['points']), 'RB', 'L', 1, 0);
PDF::Ln();
$total_height = $this->setNewPage($total_height,$h,$search_string);
}
}

if(!empty($user['rallyResponceData']['data'])){
PDF::SetFillColor(180, 180, 180);
PDF::MultiCell($sw[0], $h, "Rally Responce - Reward Name", 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, "Issued by", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "Active / Inactive", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, "Issue date", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, "Points", 'RB', 'L', 1, 0);
PDF::Ln();
$total_height = $this->setNewPage($total_height,$h,$search_string);
foreach ($user['rallyResponceData']['data'] as $data) {
PDF::SetFillColor(255, 255, 255);
PDF::MultiCell($sw[0], $h, $data['reward_name'], 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, $data['from_user'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "YES", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, $data['attaboy_date'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, number_format($data['points']), 'RB', 'L', 1,  0);
PDF::Ln();
$total_height = $this->setNewPage($total_height,$h,$search_string);
}
}

if(!empty($user['projectData']['data'])){
PDF::SetFillColor(180, 180, 180);
PDF::MultiCell($sw[0], $h, "Project - Reward Name", 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, "Issued by", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "Active / Inactive", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, "Issue date", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, "Points", 'RB', 'L', 1, 0);
PDF::Ln();
$total_height = $this->setNewPage($total_height,$h,$search_string);
foreach ($user['projectData']['data'] as $data) {
PDF::SetFillColor(255, 255, 255);
PDF::MultiCell($sw[0], $h, $data['reward_name'], 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, $data['from_user'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "YES", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, $data['display_issued_date'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, number_format($data['points']), 'RB', 'L', 1, 0);
PDF::Ln();
$total_height = $this->setNewPage($total_height,$h,$search_string);
}
}

if(!empty($user['engagementData']['data'])){
PDF::SetFillColor(180, 180, 180);
PDF::MultiCell($sw[0], $h, "Engagement - Reward Name", 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, "Issued by", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "Active / Inactive", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, "Issue date", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, "Points", 'RB', 'L', 1, 0);
PDF::Ln();
$total_height = $this->setNewPage($total_height,$h,$search_string);
foreach ($user['engagementData']['data'] as $data) {
PDF::SetFillColor(255, 255, 255);
PDF::MultiCell($sw[0], $h, $data['reward_name'], 'LRB', 'L', 1, 0);
PDF::MultiCell($sw[1], $h, $data['from_user'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[2], $h, "YES", 'RB', 'L', 1, 0);
PDF::MultiCell($sw[3], $h, $data['display_issued_date'], 'RB', 'L', 1, 0);
PDF::MultiCell($sw[4], $h, number_format($data['points']), 'RB', 'L', 1, 0);
PDF::Ln();
$total_height = $this->setNewPage($total_height,$h,$search_string);
}
}
$i++;

$total_height = $this->setNewPage($total_height,$h,$search_string);
}
PDF::Output('hello_world.pdf','I');
}
}

private function setNewPage($total_height,$height,$search_string){
$total_height = $total_height+$height;
if($total_height%275==0){
PDF::AddPage();
$total_height =10;
}
return $total_height;
}
МОЙ ВЫВОД
[img]https://i.sstatic.net /jMiC9.png[/img]


Подробнее здесь: https://stackoverflow.com/questions/353 ... -overflows
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Php»