2
Yiiフレームワーク2を使用して、kartik\mpdf\Pdf
クラスを使用して、私のHTMLページをPDF形式でブラウザに返信します。以下は私の設定です。テキストがYiiフレームワーク2のkartik/mpdfで長すぎると、フォントサイズが小さくなります。これを修正する方法は?
$pdf = new kartik\mpdf\Pdf([
// set to use core fonts only
'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' => $htmlContent,
// 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} .page-break{ page-break-after:always; } li { list-style:none; }',
// set mPDF properties on the fly
'options' => ['title' => 'My title'],
// call mPDF methods on the fly
'methods' => [
'SetHeader'=>['My_header_ ' . date('d-m-Y')],
'SetFooter'=>['{PAGENO}'],
],
]);
// return the pdf output as per the destination setting
return $pdf->render();
HTMLページ内に変数があり、長い文字列を返し、そのテキストが小さくなる場合を除いて、すべてが完全に機能します。どうすれば解決できますか?
あなたのHTMLは何ですか?それはテーブルを含んでいますか? – Finwe
はい長い文字列がセルテーブルに存在するため、テーブル全体のフォントサイズが小さくなります。私は代わりにDIVを使用しています。ただ今解決してください。しかし、まだ私がテーブルで作業したい場合に備えて、解決策を探したい。 –
@OConnorと同様の問題がすでにいくつか投稿されており、私はその解決策に答えました。チェックしてください。それは助けるかもしれません - http://stackoverflow.com/questions/26179403/how-to-prevent-table-resizing-in-pdf-using-mpdf-and-php –