M
M
Monitorkin2017-04-26 17:41:03
Yii
Monitorkin, 2017-04-26 17:41:03

How to output PDF document with landscape orientation?

Please help me figure it out, using kartik-v/yii2-mpdf I'm trying to display the document in PDF, it is formed and displayed in the browser, but no matter what I do, the sheet orientation is always ORIENT_PORTRAIT, how to make the ORIENT_LANDSCAPE orientation?

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

$order = ...::find()->...->one();
$vendor = ...::find(1)->...->one();
    
//генерируем PDF
$PDFcontent = $this->renderPartial('@app/modules/biz/views/html/nakladnaya', ['vendor' => $vendor, 'order' => $order]);
    $pdf =  new Yii::$app->pdf;
    $pdf->destination = 'I';
    $pdf->orientation ='L';
    $pdf->cssFile = '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css';
    $pdf->content = $PDFcontent;
    return $pdf->render();

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question