yii2 pdf yangi listga chop qilish

+1 ovoz
85 marta ko‘rilgan
so‘radi 23 oktabr, 18 google (122 bal)
Yii2 da qanday qilib pfd ga chop qilinayotgan malumotni yangi listga chiqarish mumkun .

masalan birinchi malumot birinchi listga ikkinchisi ikkinchi listga
izoh qoldirdi 25 oktabr, 18 Sardor Dushamov (1,593 bal)
pdf ga chop qilish uchun nima extension ishlatyapsiz
izoh qoldirdi 25 oktabr, 18 MrHope (666 bal)
kartik\mpdf\Pdf
izoh qoldirdi 25 oktabr, 18 Sardor Dushamov (1,593 bal)
$mpdf->AddPage();  shu method bilan yangi page qo'shsa bo'larkan. Va yana danniyni array qilib ham alohida page ga qo'ysa bo'larkan
https://mpdf.github.io/paging/page-breaks.html
https://mpdf.github.io/reference/mpdf-functions/addpagebyarray.html

2 Javoblar

0 ovoz
javob berdi 12 yanvar user_best (125 bal)
ko‘rsatildi 13 yanvar Saidolim
 
Eng yaxshi javob
public function actionPrintlist($school_id,$type)
    {
        $fio= School::find()->where(['id'=>$school_id])->one();
        $searchModel = new AnnualEventsSearch();
        $dataProvider = $searchModel->searchByAnnual(Yii::$app->request->queryParams,$school_id);
        $dataProvider->pagination = ['pageSize' => 1000,];
        $dataProvider = $dataProvider->getModels();

        Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
        $headers = Yii::$app->response->headers;
        $headers->add('Content-Type', 'application/pdf');

        $content = $this->renderPartial('@app/views/annual-events/print_annual',[
            'dataProvider' => $dataProvider,
        ]);

        $pdf = new Pdf([
            'mode' => Pdf::MODE_CORE,
                // A4 paper format
            'format' => Pdf::FORMAT_A4,
                // portrait orientation
            'orientation' => Pdf::ORIENT_PORTRAIT,
                // stream to browser inline
            'destination' => Pdf::DEST_BROWSER,
                // your html content input
            'content' => $content,  
                // format content from your own css file if needed or use the
                // enhanced bootstrap css built by Krajee for mPDF formatting
            'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css',
                // any css to be embedded if required
            'cssInline' => '.kv-heading-1{font-size:18px}',
                // set mPDF properties on the fly
            'options' => ['title' => 'Krajee Report Title'],
                // call mPDF methods on the fly
            'methods' => [
                'SetHeader'=>[$fio->name.'-Maktab'],
                'SetFooter' => ['|{PAGENO}/{nbpg}'],
            ]
        ]);
        if($type == 2)
        {
            $mpdf = $pdf->api; // fetches mpdf api
            $mpdf->SetHeader($fio->name.'-Maktab'); // call methods or set any properties
            $mpdf->SetFooter('|{PAGENO}');
            $mpdf->WriteHtml($content); // call mpdf write html
            echo $mpdf->Output('file.pdf', 'D'); // call the mpdf api output as needed            
        }
        return $pdf->render();
    }
0 ovoz
javob berdi 25 oktabr, 18 MrHope (666 bal)
tahrirlandi 13 yanvar Saidolim
$content = $this->renderPartial('_reportView');
// setup kartik\mpdf\Pdf component
$pdf = new Pdf([
    // set to use core fonts only
    'mode' => Pdf::MODE_UTF8,
    // A4 paper format
    'format' => Pdf::FORMAT_A4,
    // portrait orientation
    'orientation' => Pdf::ORIENT_PORTRAIT,
    // stream to browser inline
    'destination' => Pdf::DEST_BROWSER,
    // your html content input
    'content' => $content,

    'methods' => [
        //'SetHeader'=>[''],
        'SetFooter'=>['{PAGENO}'],
    ]
]);

_reportView view ochib uni ichiga joylashtirsa bo'ladi.

joylashtirmoqchi bo'lgan hujjatizni word da veb document qilib saqlab html codeni 

_reportView ko'chirib o'tkazib qo'ysaz bo'ladi. Shunda o'ziz xohlagan ko'rinishda chiqara olasiz

Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.

Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin.

Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Telegram kanal YordamUzRss

...