当前位置:网站首页>Page printing plug-in print js
Page printing plug-in print js
2022-07-02 05:57:00 【Want to eat pineapple crisp】
install
npm install print-js --save
introduce
import print from 'print-js'
Use
<div id="printRef"> ... </div>
<el-button @click="onPrintJs" size="default" type="primary"> Click to print the demo </el-button>
// Print Click
const onPrintJs = () => {
printJs({
printable: 'printRef',
type: 'html',
css: ['//at.alicdn.com/t/font_2298093_o73r8wjdhlg.css', '//unpkg.com/element-plus/dist/index.css'],
scanStyles: false,
style: `@media print{.mb15{margin-bottom:15px;}.el-button--small i.iconfont{font-size: 12px !important;margin-right: 5px;}}`,
});
};
API
| Parameters | The default value is | explain |
|---|---|---|
| printable | null | Document source :pdf Or image url,html Elemental id or json The object of the data |
| type | Printable type . Available printing options include :pdf,html,image,json and raw-html | |
| header | null | be used for HTML,Image or JSON Optional headers for printing . It will be placed at the top of the page . This property will accept text or raw HTML |
| headerStyle | ‘font-weight:300;’ | Optional Title style to apply to the title text |
| maxWidth | 800 | Maximum document width ( Pixels ). Change this item as needed . In print HTML, Image or JSON When using |
| css | null | This allows us to pass one or more that should be applied to what is being printed html Of css file URL. The value can contain a single URL String , It can also contain multiple URL Array of |
| style | null | This allows us to pass a string , This string should be applied to the html. |
| scanStyles | true | Set to false when , The library does not handle the... That is being printed html The style of . Use css Parameters are very useful . |
| targetStyle | null | By default , In print HTML Element time , The library only handles certain styles . This option allows you to pass an array of styles to process . for example :[‘padding-top’,‘border-bottom’] |
| targetStyles | null | And targetStyle identical , This will handle any series of styles .for example :[‘border’,‘padding’], Will include ’border-bottom’,‘border-top’,‘border-left’,‘border-right’,‘padding-top’ etc. . You can also pass [’*'] To handle all styles ignoreElements: [] Accept print parent html Elements should be ignored html Of id Array . |
| properties | null | In print JSON When using . These are object attribute names . |
| gridHeaderStyle | ‘font-weight:bold;’ | Print JSON Optional style of grid title when data . |
| gridStyle | ‘border: 1px solid lightgray; margin-bottom: -1px;’ | Print JSON Optional styles of grid rows when data |
| repeatTableHeader | true | In print JSON Data is used when . Set to false, The data table title is only displayed on the first page . |
| showModal | null | Enable this option to retrieve or process large PDF Show user feedback when file |
| modalMessage | ‘Retrieving Document…’ | When the message displayed to the user showModal Be set to true. |
| onLoadingStart | null | load PDF Functions to be performed when |
| onLoadingEnd | null | load PDF Functions to be performed after |
| documentTitle | ‘Document’ | Print html,image or json when , It will be displayed as the document title . If the user tries to save the print job as pdf file , It will also be the name of the document . |
| fallbackPrintable | null | Print pdf when , If the browser is not compatible ( Check the browser compatibility table ), The library will open in a new tab pdf. This allows you to pass on different to open pdf file , Not to printable The original document of .If you are in standby pdf Inject... Into the file javascript, This may be useful . |
| onPdfOpen | null | Print pdf when , If the browser is not compatible ( Check the browser compatibility table ), The library will open in a new tab pdf. You can pass the callback function here , This will be performed when this happens . Before you want to process the printing process , In some cases, such as updating the user interface , It can be very useful . |
| onPrintDialogClose | null | Execute the callback function after closing the browser Print dialog onError: error => throw error Callback function to execute when an error occurs . |
| base64 | false | Print as base64 Data transmission PDF Use... When documenting |
| frameId | null | print.js The content to be printed will be copied to a new Frame in , This parameter is frame Of id value |
边栏推荐
- [golang syntax] be careful with the copy of slices
- File contains vulnerabilities (II)
- 格式校验js
- 外部中断无法进入,删代码再还原就好......记录这个想不到的bug
- 1037 Magic Coupon
- Zzuli:1066 character classification statistics
- Lingyunguang rushes to the scientific innovation board: the annual accounts receivable reaches 800million. Dachen and Xiaomi are shareholders
- Alibaba: open source and self-developed liquid cooling data center technology
- Go 学习笔记整合
- LCD之MIPI协议的一些说明
猜你喜欢
![[C language] simple implementation of mine sweeping game](/img/f7/15d561b3c329847971cabd4708c851.png)
[C language] simple implementation of mine sweeping game

Grbl software: basic knowledge of simple explanation

3D 打印机 G 代码命令:完整列表和教程

Can't the dist packaged by vite be opened directly in the browser

文件包含漏洞(一)

51 single chip microcomputer - ADC explanation (a/d conversion, d/a conversion)

Lingyunguang rushes to the scientific innovation board: the annual accounts receivable reaches 800million. Dachen and Xiaomi are shareholders

Thunder on the ground! Another domestic 5g chip comes out: surpass Huawei and lead the world in performance?

Go language web development is very simple: use templates to separate views from logic

5g market trend in 2020
随机推荐
在uni-app中引入uView
How vite is compatible with lower version browsers
External interrupts cannot be accessed. Just delete the code and restore it Record this unexpected bug
TI毫米波雷达学习(一)
Lambda 表达式 和 方法引用
php获取cpu使用率、硬盘使用、内存使用
PHP development and testing WebService (soap) -win
Zzuli:1069 learn from classmate Z
Oled12864 LCD screen
TypeScript的泛型和泛型约束
1035 Password
Technologists talk about open source: This is not just using love to generate electricity
Common websites for Postgraduates in data mining
神机百炼3.52-Prim
Regular expression summary
使用HBuilderX的一些常用功能
php读文件(读取文件内含有某字符串的指定行)
Redis Key-Value数据库 【高级】
Stc8h8k series assembly and C51 actual combat - keys allow key counting (using falling edge interrupt control)
死磕大屏UI,FineReport开发日记