|
|
|
Error การสั่งปริ้นไฟล์ pdf ทางเบราเซอร์ แล้วสามารถสั่งปริ้นได้สูงสุดแค่ 4 หน้า หรือ ข้อมูลได้แค่ 4 ข้อมูล |
|
|
|
|
|
|
|
เนื่องจากผมเขียนโค๊ดแล้วต้องการสั่งปริ้น pdf ให้มันมีหลายหน้า ตอนโชว์ใน browser แต่มันเกิด error
ตัวอย่างเช่น ผมมีข้อมูลลูกค้า 10 คน ผมสั่ง Checkbox ทั้งหมด หน้าชื่อลูกค้าทุกคน แล้วกด สั่งปริ่น
จะให้มันไปโชว์อีกหน้าครับ เป็นไฟล์ pdf แต่มันสามารถแสดงข้อมูลได้สูงสุดแค่ 4 ข้อมูลหรือ 4หน้า
มีพี่ๆเนะนำมาว่าต้องใช้การคำนวน Header ผมไม่เข้าใจครับ ตัวอย่างข้างล่างคือโค๊ดครับ
Code (PHP)
<?php
ini_set("session.gc_maxlifetime","3600");
session_start();
/*error_reporting(E_ALL);*/
set_time_limit(1800);
/*$Delay = rand(1,3);
sleep($Delay);*/
include("../../_class/adodb/adodb.inc.php");
include("../../_conf/_mltTourConf.php");
include("../../_conf/_Define.php");
include("../../_utils/_DBase_outbound.php");
include("../../_utils/_DBase.php");
include("../../_utils/_Utils.php");
include("../../_utils/Func.php");
include("../../_utils/CreateLogs.php");
include 'class.ezpdf.php';
# outbound db #
$conn_outb = NewADOConnection($dbDriver);
$conn_outb->Connect($myDSN, $dbUser ,$dbPass, $OutboundDb);
if (!$conn_outb) {
print $conn_outb->ErrorMsg();
echo MessageBox( "Error:", "Can't connect to Database." );
exit;
}
$conn_outb->debug = false;
$conn_outb->SetFetchMode(ADODB_FETCH_ASSOC);
# mtlttour db #
$conn = NewADOConnection($dbDriver);
$conn->Connect($myDSN, $dbUser ,$dbPass, $myDb);
if (!$conn) {
print $conn->ErrorMsg();
echo MessageBox( "Error:", "Can't connect to Database." );
exit;
}
$conn->debug = false;
$conn->SetFetchMode(ADODB_FETCH_ASSOC);
##################################
$id = $_GET['id'];
$pdf =&new Cezpdf('a4','landscape');
for($i=0;$i<count($_POST['checkall']);$i++){
$sql = "select c.*, g.* , DATE_FORMAT(g.periodfrom,'%d/%m/%Y') AS 'periodfrom' "
.", DATE_FORMAT(g.periodto,'%d/%m/%Y') AS 'periodto'"
.", DATE_FORMAT(c.birth ,'%d') AS 'd_birth' "
.", DATE_FORMAT(c.birth ,'%m') AS 'm_birth' "
.", DATE_FORMAT(c.birth ,'%Y') AS 'y_birth' "
.", DATE_FORMAT(c.passport_expried ,'%d-%m-%Y') AS 'passport_expried' ";
$sql .= " FROM outbound.product_main AS g "
." LEFT JOIN outbound.outbound_seat AS s ON s.outb_id = g.outb_id "
." LEFT JOIN outbound.customer AS c ON c.cus_id = s.cus_id "
." where g.outb_id = ".$id." AND c.cus_id = ".$_POST['checkall'][$i]." ";
$char =&$conn_outb->Execute($CHARSET) or die('Invalid query: ');
$rs = $conn_outb->Execute($sql );
if(!$rs){ $error .= "can not show data on product id ".$id."";}
$outb_id = $rs->fields['outb_id'];
$gateway = $rs->fields['gateway'];
$name = $rs->fields['name'];
$periodfrom = $rs->fields['periodfrom'];
$periodto = $rs->fields['periodto'];
$departure = $rs->fields['departure_flightname'];
$arrival = $rs->fields['arrival_flightname'];
$airline = $rs->fields['airline_name'];
$hotel = $rs->fields['hotel'];
$bus = $rs->fields['bus'];
$create_by = $rs->fields['create_by'];
$create_date = $rs->fields['create_date'];
$passport_expried = $rs->fields['passport_expried'];
$passport_expried = explode("-", $passport_expried);
$firstname[$i] = $rs->fields['firstname'];
$lastname[$i] = $rs->fields['lastname'];
$title[$i] = $rs->fields['title'];
$passportno[$i] = $rs->fields['passportno'];
$provincebirth[$i] = getProvinceLocation($rs->fields['province_id']);
$birth[$i] = $rs->fields['birth'];
$d_birth[$i] = $rs->fields['d_birth'];
$m_birth[$i] = $rs->fields['m_birth'];
$y_birth[$i] = $rs->fields['y_birth'];
$countrybirth[$i] = getCourntry($rs->fields['country_id']);
$nation[$i] = GateNation($rs->fields['nationality']);
$idcard[$i] = $rs->fields['idcard'];
$district_id[$i] = $rs->fields['district_id'];
$lastcity[$i] = $rs->fields['lastcity'];
$lastcountry[$i] = $rs->fields['lastcountry'];
$nextcity[$i] = $rs->fields['nextcity'];
$nextcountry[$i] = $rs->fields['nextcountry'];
$hotel_id[$i] = $rs->fields['hotel_id'];
if($hotel_id){$hotel_address= Gethotel($hotel_id); }else{ $hotel_address= 'N/A';}
$day = $rs->fields['day'];
if($district_id){ $district_name = getDistrict($district_id);}else{ $district_name = 'N/A';}
###################################
$col1 = 220;
$pdf->addText(20, $col1, 9, $lastname[$i]);
$col1 = $col1 - 15;
$pdf->addText(20, $col1, 9, $firstname[$i]);
$pdf->addText(20, 172, 9, $passportno[$i]);
$pdf->addText(20, 145, 9, $passport_expried[0]);
$pdf->addText(50, 145, 9, $passport_expried[1]);
$pdf->addText(80, 145, 9, $passport_expried[2]);
if($title==1){
$pdf->addText(152, 150, 9, "/");
}else{
$pdf->addText(152, 140, 9, "/");
}
$pdf->addText(20, 100, 9, "THAI");
$pdf->addText(20, 75, 9, $d_birth[$i]);
$pdf->addText(50, 75, 9, $m_birth[$i]);
$pdf->addText(80, 75, 9, $y_birth[$i]);
$pdf->addText(145, 75, 9, $provincebirth[$i]);
$pdf->addText(20, 50, 9, $provincebirth[$i]);
$pdf->addText(20, 28, 9, $countrybirth[$i]);
$col2 = 300-70;
$pdf->addText(375, $col2, 9, "/");
$col2 = 300-100;
$pdf->addText(415, $col2, 9, "/");
$col2 = 300-120;
$pdf->addText(285, $col2, 9, "/");
$col2 = 300-175;
$pdf->addText(285, $col2, 9, "/");
$col3 = 220;
$pdf->addText(520, $col3, 9, $firstname[$i]);
$pdf->addText(610, $col3, 9, $lastname[$i]);
$col3 = 191;
$pdf->addText(520, $col3, 9, $passportno[$i]);
$col3 = 167;
$pdf->addText(520, $col3, 9, "THAI");
$pdf->ezStream();
$pdf->ezNewPage();
}
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2012-08-22 15:51:53 |
By :
นายเจเจ |
View :
1229 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สรุปคือมันได้แค่ 4 หน้าเหรอครับ ลองใช้ FPDF ดูหรือยังครับ หรือ TCPDF
|
|
|
|
|
Date :
2012-08-22 22:02:16 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|