<?PHP
$id=$_GET['number'];$uploaddir = 'download/';
$Date = date("YmdHis");
$filenamepdf = $uploaddir."HK_print".$Date.".pdf";
$filenamepdfjp=$uploaddir."JP_print".$Date.".pdf";require_once('tcpdf/config/lang/eng.php');
require_once('tcpdf/tcpdf.php');
include("conn.php");$pdf = new TCPDF('L', 'mm', 'BUSINESS_CARD_JP', true, 'UTF-8', false);
//$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
//取消Header
$pdf->setPrintHeader(false);
//取消footer
$pdf->setPrintFooter(false);
$pdf->SetFont('arialunicid0', '', 10);
$pdf->SetMargins(1,1,1);
$pdf->setFooterMargin(1);
//$pdf->SetAutoPageBreaks(true, 5);
$pdf->SetAutoPageBreak( true, 1 );
 $Sql_hkpdf = "SELECT * , group_concat(if(`quantity-purchased`> 1, '****' , '  ') , concat_ws( ' X ', `sku` , `quantity-purchased` ) , '  ' ),group_concat('  ' , `order_id` , '  ') FROM ( select * from `sale_orders` order by `sku`) T WHERE `shipments` =0 AND `number` =$id AND `delivery_areas` ='HK' GROUP BY `recipient-name` , `ship-address-1` ORDER BY length(group_concat( ' ' , concat_ws( ' X ', `sku` , `quantity-purchased` ) , ' ' )) DESC,`sku`"; 
 $Result = mysql_query($Sql_hkpdf);
  while($rs = mysql_fetch_array($Result) ){
 
$ship_address=$rs['ship-address-1'].$rs['ship-address-2'].$rs['ship-address-3'];
$sku=$rs["group_concat(if(`quantity-purchased`> 1, '****' , '  ') , concat_ws( ' X ', `sku` , `quantity-purchased` ) , '  ' )"];
$ship_postal_code="〒".$rs['ship-postal-code'];$ship_city=$rs['ship-state']." ".$rs['ship-city'];
$recipient_name=$rs['recipient-name']." 樣";
$buyer_phone_number="電話番號:".$rs['buyer-phone-number'];
//$hkdizhi='From : Unit A1 , 7/F,Cheung Kong Factory Bldg , 6 Cheung Yee Street , Lai Chi Kok , Hong Kong';
$pdf->AddPage();
$pdf->SetFont('arialunicid0', '', 8);
$pdf->Write(0, $sku, '', 0, 'R', true, 0, false, false, 0);
$yy=$pdf->GetY();
$xx=$pdf->GetX();
$style = array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0));
$pdf->Line(2, $yy+0.3, 89, $yy+0.3, $style);
$pdf->SetFont('arialunicid0', '', 10);
$pdf->Write(0, $ship_postal_code, '', 0, 'L', true, 0, false, false, 0);
$pdf->Write(0, "\n", '', 0, 'L', true, 0, false, false, 0);
$pdf->Write(0, $ship_city, '', 0, 'L', true, 0, false, false, 0);
$pdf->Write(0, $ship_address, '', 0, 'L', true, 0, false, false, 0);
$pdf->Write(0, "\n", '', 0, 'L', true, 0, false, false, 0);
$pdf->SetFont('arialunicid0', '', 12);
$pdf->Write(0, $recipient_name, '', 0, 'C', true, 0, false, false, 0);
$pdf->SetFont('arialunicid0', '', 10);
$pdf->Write(0, $buyer_phone_number, '', 0, 'C', true, 0, false, false, 0);
$pdf->Write(0, "\n", '', 0, 'L', true, 0, false, false, 0);
$pdf->Line(2, 49, 89, 49, $style);
$pdf->SetXY(3,50);
$pdf->SetFont('arialunicid0', '', 7);
$pdf->Image('../amazonnew/dizhi.png',3,49.5,88,4.5,'', '', '', true, 400, '', false, false, 0, false, false, false);
//$pdf->Image('amazonnew/dizhi.jpg',3,40,80,3,'', '', '', true, 150, '', false, false, 0, false, false, false);
//$pdf->Write(0, 'From : Unit A1 , 7/F,Cheung Kong Factory Bldg , 6 Cheung Yee Street , Lai Chi Kok , Hong Kong', '', 0, 'L', true, 0, false, false, 0);
//$pdf->Write(0, $hkdizhi, '', 0, 'L', true, 0, false, false, 0);
$style1 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0));
$pdf->Line(1, 1, 90, 1, $style1);
$pdf->Line(1, 54, 90, 54, $style1);
$pdf->Line(1, 1, 1, 54, $style1);
$pdf->Line(90, 1, 90, 54, $style1);
}$pdf->Output($filenamepdf, 'F');//---------------------------------------------------------------------------------------------------------------------------$pdfjp = new TCPDF('L', 'mm', 'BUSINESS_CARD_JP', true, 'UTF-8', false);
//$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
//取消Header
$pdfjp->setPrintHeader(false);
//取消footer
$pdfjp->setPrintFooter(false);
$pdfjp->SetFont('arialunicid0', '', 10);
$pdfjp->SetMargins(1,1,1);
$pdfjp->setFooterMargin(1);
//$pdf->SetAutoPageBreaks(true, 5);
$pdfjp->SetAutoPageBreak( true, 1 );
 $Sql_jppdf = "SELECT * , group_concat(if(`quantity-purchased`> 1, '****' , '  ') , concat_ws( ' X ', `sku` , `quantity-purchased` ) , '  ' ),group_concat('  ' , `order_id` , '  ') FROM ( select * from `sale_orders` order by `sku`) T WHERE `shipments` =0 AND `number` =$id AND `delivery_areas` ='JP' GROUP BY `recipient-name` , `ship-address-1` ORDER BY length(group_concat( ' ' , concat_ws( ' X ', `sku` , `quantity-purchased` ) , ' ' )) DESC,`sku`";
$Resultjp = mysql_query($Sql_jppdf);while($rs = mysql_fetch_array($Resultjp) ){
 
$ship_address=$rs['ship-address-1'].$rs['ship-address-2'].$rs['ship-address-3'];
$sku=$rs["group_concat(if(`quantity-purchased`> 1, '****' , '  ') , concat_ws( ' X ', `sku` , `quantity-purchased` ) , '  ' )"];
$ship_postal_code="〒".$rs['ship-postal-code'];$ship_city=$rs['ship-state']." ".$rs['ship-city'];
$recipient_name=$rs['recipient-name']." 樣";
$buyer_phone_number="電話番號:".$rs['buyer-phone-number'];
 
$pdfjp->AddPage();
$pdfjp->SetFont('arialunicid0', '', 8);
$pdfjp->Write(0, $sku, '', 0, 'R', true, 0, false, false, 0);
$yy=$pdfjp->GetY();
$xx=$pdfjp->GetX();
$stylejp = array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0));
$pdfjp->Line(2, $yy+0.3, 89, $yy+0.3, $stylejp);
$pdfjp->SetFont('arialunicid0', '', 10);$pdfjp->Write(0, $ship_postal_code, '', 0, 'L', true, 0, false, false, 0);
$pdfjp->Write(0, "\n", '', 0, 'L', true, 0, false, false, 0);
$pdfjp->Write(0, $ship_city, '', 0, 'L', true, 0, false, false, 0);
$pdfjp->Write(0, $ship_address, '', 0, 'L', true, 0, false, false, 0);$pdfjp->Write(0, "\n", '', 0, 'L', true, 0, false, false, 0);
$pdfjp->SetFont('arialunicid0', '', 12);
$pdfjp->Write(0, $recipient_name, '', 0, 'C', true, 0, false, false, 0);
$pdfjp->SetFont('arialunicid0', '', 10);
$pdfjp->Write(0, $buyer_phone_number, '', 0, 'C', true, 0, false, false, 0);
$pdfjp->Write(0, "\n", '', 0, 'L', true, 0, false, false, 0);
$pdfjp->Line(2, 50, 89, 50, $stylejp);
$pdfjp->SetXY(3,50);
$pdfjp->SetFont('arialunicid0', '', 7);
$pdfjp->Write(0, 'From : 240-0035 神奈川県横浜市保土ヶ谷区今井町142-1STコーポ 1C', '', 0, 'L', true, 0, false, false, 0);
$stylejp1 = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0));
$pdfjp->Line(1, 1, 90, 1, $stylejp1);
$pdfjp->Line(1, 54, 90, 54, $stylejp1);
$pdfjp->Line(1, 1, 1, 54, $stylejp1);
$pdfjp->Line(90, 1, 90, 54, $stylejp1);}$pdfjp->Output($filenamepdfjp, 'F');echo '<script>location.href="download_pdf.php?file_pdf='.$filenamepdf.'&file_pdfjp='.$filenamepdfjp.'"</script>';
?>执行数量1000条记录以上就报错500,请问怎么解决这个问题????

解决方案 »

  1.   

    你这是生成两个pdf文件吧?
    那么 1000条记录以上 是指一个 pdf 1000条,还是两个文件累计 1000条?$pdf 用完了,为何不销毁掉?
      

  2.   

    我加了
    unset($pdf);
    也没用,还是那样,多了就报500错误
      

  3.   

    分几次???那我把两个文件PDF文件分两个页面做。
    不过请问是什么原因呢?是因为内存还是因为执行时间
      

  4.   

    我把php.ini参数改了一下,把最大执行时间改成0,内存改成128M...不过感觉执行效率很低
      

  5.   

    请问以下代码怎么自动换行,出超出纸的规格,一部分内容看不到
    $pdf->Write(0, $ship_address, '', 0, 'L', true, 0, false, false, 0);