【发布时间】:2016-04-14 06:21:40
【问题描述】:
您好,我正在使用带有组件 DomPDF 的框架 yii2 从 GridView::widget 生成 pdf,以生成带有引导程序的表。但我的 pdf 看起来不像引导表,我不知道为什么,请有人帮助我 我使用这个模板:
<?php
/* @var $this \yii\web\View */
/* @var $content string */
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
/*
* Variáveis Globais
*/
$tituloPrincipal = $this->params['tituloPrincipal'];
//$tituloSecundario = $this->params['tituloSecundario'];
//$utilizador = $this->params['utilizador'];
//$breadcrumb = $this->params['breadcrumb'];
/*
* *** *** ***
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!-- <style>
#footer2 { position: fixed; left: 0px; bottom: -60px; right: 0px; height: 50px; font-size: 8pt; font-family: Helvetica, sans-serif; }
#footer2 .page:after { contentor: counter(page, upper-roman); }
</style> -->
<link href="<?php echo Yii::$app->request->baseUrl; ?>/css/styleImpressoes.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="<?php echo Yii::$app->request->baseUrl; ?>/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<!-- font Awesome -->
<link href="<?php echo Yii::$app->request->baseUrl; ?>/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id ="cabecalho" style="padding-top: -20px; height: 30px; border-bottom: 1px solid black;">
<table id="cabecalho" width="100%">
<tr>
<!-- <td>
<div style="text-align: left;">
<img src="./img/logotipo-vfa2.png" height="75" />
</div>
</td>-->
<td>
<div style="text-align: left;">
<?php echo $tituloPrincipal; ?>
</div>
</td>
</tr>
</table>
</div>
<div id="contentor" style="width: 100%;">
<div class="contentRelatorioTemplate">
<?php
echo $content;
?>
</div>
</div>
<!-- <div id="footer2" style="border-top: 1px solid black;width: 100%;text-align: right;">
<div style="margin-right: 18px;margin-top: 4px;">Pág. </div>
</div>-->
<script type="text/php">
if ( isset($pdf) ) {
$pdf->line(34,770,580,770,array(0,0,0),1);
$font = Font_Metrics::get_font("helvetica");
$pdf->page_text(545, 775, utf8_encode("Pág. {PAGE_NUM} / {PAGE_COUNT}"),
$font, 8, array(0,0,0));
$dataImp = date("Y-m-d");
$pdf->page_text(250, 775, "Impresso em: " . $dataImp,
$font, 8, array(0,0,0));
$pdf->page_text(35, 775, "Visionsoft",
$font, 8, array(0,0,0));
}
</script>
</body>
</html>
观点:
<div class="cliente-view">
<h1><?= Html::encode($this->title) ?></h1>
<?php // var_dump($dataProvider);die; ?>
<?=
GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'assunto_r',
'descricao_r',
],
'showFooter' => true,
'tableOptions' =>['class' => 'table table-striped table-bordered'],
]);
?>
</div>
控制器:
$pdfGen->render('impressao/impressaoAssuntoA4', [
'dataProvider' => $dataProvider,
]);
【问题讨论】:
-
分享你的尝试
-
我在评论中添加了我的代码。似乎 dompdf 不适用于 bootstrap
-
我替换: For: 现在得到这个错误: Illegal string offset 'hex'
标签: twitter-bootstrap yii2 pdf-generation dompdf