TCPDF faylini ishlab chiqarishni tezlashtirish

HTMLni HTML ga aylantirish uchun TCPDF dan foydalanmoqdaman.

Bir betlik hisob-fakturaning 5 sekundda yaratilganligini hisoblayman va 7 soniya hisob-fakturani 55 sekundda yaratganim sababli men buni bilmayman.

Men so'nggi TCPDF versiyasini ishlatyapman, va men ushbu echimdan foydalanishni sinab ko'rdim va setFontSubsetting (FALSE) ni o'rnatdim, ammo bu echimlarning hech biri TCPDF fayllarini asta-sekin ishlab chiqarishni yaxshilamadi.

Dasturning to'liq kodi:

    <?php
set_time_limit(0);
require('modifyDate.php');
require('createQuery.php');

//GET FORM DATA
if(isset($_POST['submitMeshavek']))
{
$saleStart=$_POST['saleStart'];
$saleEnd=$_POST['saleEnd'];
$saleWeek=$_POST['weekId'];
$growerId=$_POST['growerId'];
$reportType=$_POST['reportType'];
}

//REQUIRE TCPDF
require_once('tcpdf/config/lang/eng.php');
require_once('tcpdf/config/lang/heb.php');
require_once('tcpdf/tcpdf.php');

class MYPDF extends TCPDF {

    //Page header
    public function Header() {
       //Set font
        $this->SetFont('helvetica', 'B', 20);
       //Title
        $this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
    }

   //Page footer
    public function Footer() {
       //Position at 15 mm from bottom
        $this->SetY(-15);
       //Set font
        $this->SetFont('helvetica', 'I', 8);
       //Page number
        $this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
    }
}



// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);

// set document information
/*
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Nicola Asuni');
$pdf->SetTitle('TCPDF Example 018');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
*/
// SET CUSTOMIZED DATE INCLUDED HEADER
$headerSDate=reverseLongDate($saleStart);
$headerEDate=reverseLongDate($saleEnd);
$header="";
$header.="\t";
$header.=Date("d-m-Y h:m:s");
$header.="\n";
$header.='מועדון המגדלים יוסי חותה פירות וירקות';
$header.="\n";
$header.='דו"ח שיווק ללקוח לתאריכים '.$headerSDate." עד ".$headerEDate;

$pdf->SetHeaderData("","" ,"",$header); 
//$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);



// set header and footer fonts
$pdf->setHeaderFont(Array("dejavusans", '', "15"));
$pdf->setFooterFont(Array("dejavusans", '', "12"));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

// set some language dependent data:
$lg = Array();
$lg['a_meta_charset'] = 'UTF-8';
$lg['a_meta_dir'] = 'rtl';
$lg['a_meta_language'] = 'fa';
$lg['w_page'] = 'page';

//set some language-dependent strings
$pdf->setLanguageArray($lg);

// ---------------------------------------------------------

// set font
$pdf->SetFont('dejavusans', '', 12);

// add a page
$pdf->AddPage();
// -----------------------------------------------------------------------------




/*
$regularSaleStart=reverseDate($saleStart);
$regularSaleEnd=reverseDate($saleEnd);
$header='

מועדון מגדלים יוסי חותה פירות וירקות

';
$header.="דוח שיווק ללקוח לתאריכים                 ".$regularSaleEnd." ".$regularSaleStart;

 public function Header() {
       //Set font
        $this->SetFont('dejavusans', '', 10);
       //Title
        $this->Cell(0, 15, '<< TCPDF Example 003 >>', 0, false, 'C', 0, '', 0, false, 'M', 'M');
    }
*/

if($reportType=='customer')
{
    include('reportType/customer.php');
}
else
    if($reportType=='newCustomer')
    {
        include('reportType/customerNew.php');
    }
    else 
        if($reportType=='collection')
            {
            include('reportType/collect.php');
            }
                else 
                    if($reportType=='grower')
                    {
                        include('reportType/grower.php');
                    }

ob_clean();
//$pdf->writeHTML($html, true, false, false, false, '');
$pdf->writeHTML($html, true, 0, true, 0);
//Close and output PDF document
$pdf->Output('example_048.pdf', 'I');

$pdf->writeHTML($html, true, 0, true, 0);
//Close and output PDF document
$pdf->Output('examp.pdf', 'I');


?>

Men TCPDF ni tezroq ishlashi uchun mumkin bo'lgan hamma narsani qilishga urinib ko'rganman, har qanday taklifni qadrlayman, oldindan rahmat!

0

1 javoblar

HTMLni ishlatmaslikka harakat qiling, bu statik PDF-mahalliy usullarni ishlatib, sekinroq, biz uchun pdf yuklanish vaqtini 50% gacha qisqartiramiz.

$pdf->multiCell($a-lot-of-params);

Tezlik haqida qayg'urayotgan bo'lsangiz, matningizni ko'rsatish uchun ...

Umid qilamanki yordam beradi.

0
qo'shib qo'ydi
PhP |BotsUz
PhP |BotsUz
93 ishtirokchilar

Phpni o'rganishni Hohlasangiz https://t.me/joinchat/AAAAAE-KRc5dd5tPMmGmWA A'zo bo'lin