【问题标题】:Prinout Extension in Yii, how to remove header, footer and anchor tags?Yii中的Printout Extension,如何删除页眉,页脚和锚标签?
【发布时间】:2015-10-18 19:24:51
【问题描述】:

这是我的视图代码

<?php 
$this->widget('application.extensions.print.printWidget', array(                   
               'cssFile' => 'print.css',
               'coverElement' => '#wrapper',
               'printedElement'=>'#summary',
               )
             ); 
?>
<div id="summary">

<?php $this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'attributes'=>array(
    'name',
    'date_created',
    'medical_treatment',
    'remarks',
),
)); ?>
<br><br>
<center>____________________________</center>
<center>Doctor's Signature</center>
</div>

我的控制器/动作

     public function actionPrescription($id) 
{
    $this->render('printprescription', array(
    'model'=>$this->loadModel($id),
    ));
}

我只想打印 div id="summary" 的内容 扩展确实让我这样做,但它首先用页眉和页脚打印出整个页面

我认为 coverElement 可以将其移除,但我想不会?

谁能帮忙?

【问题讨论】:

  • 我没有尝试过特定的扩展,但你是否添加了规则(在 print.css 中),例如:@media print { #header, #footer { display: none; } }
  • 是的,但它仍然存在:/
  • 显示你的相关控制器/动作和你的相关视图
  • 我真的不认为控制器或相关视图与此有任何关系...我认为扩展名是问题...我正在使用打印输出扩展名跨度>

标签: php html css yii printing


【解决方案1】:

在 CSS 中添加打印媒体应该会有所帮助。 您可以尝试将页眉和页脚的选择器直接添加到扩展代码中。

    echo CHtml::css("
        .printWidgetScreenCover {display: none;}
        .printWidgetPrintedElement {display: block; margin: 20px;}
        #header {display: none;}
        #footer{display: none;}
        ",
        "print"
    );

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 2021-01-29
    • 2012-01-03
    • 2015-10-01
    相关资源
    最近更新 更多