artsoft/yii2-print-this

为 Yii Framework 2.0 通过选择器打印 html

安装: 15

依赖者: 1

建议者: 0

安全性: 0

星标: 0

关注者: 0

分支: 7

类型:yii2-extension

v1.0.2 2018-03-28 14:22 UTC

This package is auto-updated.

Last update: 2024-09-12 02:55:47 UTC


README

forked from Yii2Assets/yii2-print-this

安装

composer require artsoft/yii2-print-this "dev-master"

或者将此行添加到 composer.json 文件中

"artsoft/yii2-print-this": "dev-master"

使用方法

要使用此小部件,将以下代码插入到视图文件中

<?php
echo PrintThis::widget([
	'htmlOptions' => [
            'id' => ['print_info', 'print_body'],
            'btnOptions' => [
                'id' => 'btnId',
                'class' => 'btn btn-default btn-sm',
                'data-toggle' => 'tooltip',
                'data-container' => 'body',
                'data-placement' => 'top',
                'data-original-title' => 'Print',
            ]
            'btnText' => 'Print',
            'btnIcon' => 'fa fa-print'
        ],
	'options' => [
		'debug' => false,
		'importCSS' => true,
		'importStyle' => false,
		'loadCSS' => "path/to/my.css",
		'pageTitle' => "",
		'removeInline' => false,
		'printDelay' => 333,
		'header' => null,
		'formValues' => true,
	]
]);
?>

in view file for print area
```html
<div id="print_info">
Your Html code here
</div>
...
<div id="print_body">
Your Html code here
</div>

你可以添加 css 来禁用链接显示

@media print {
    .noprint {display:none !important;}
    a:link:after, a:visited:after {  
      display: none;
      content: "";    
    }
}

更多选项

https://github.com/jasonday/printThis