print.js打印

cs 复制代码
<body>
<form id="form1" runat="server">
打印内容
</form>
<body>
function print(){
     var printStyle = '\
    @page { size: A4; margin: 10mm; } \
    @media print { \
     /* 使打印 iframe 的 body 居中内容区 */ \
       body { display: -webkit-box !important; display: -webkit-flex !important; display:          -ms-flexbox !important; display: flex !important; justify-content: center !important; align-items: flex-start !important; } \
/* 其他样式用来自定义 */ \
        html, body { margin: 0; padding: 0; -webkit-print-color-adjust: exact; } \
        form#form1 { width: 80mm; margin: 0 auto; font-size: 25pt !important; } \
        .dash { border-top: 1px dashed #000; border-bottom: 1px dashed #000; } \
        .title {font-weight: bold;text-align: center;p
    }';//样式
            printJS({ printable: 'form1', type: 'html', style: printStyle });
}

注意此插件不能更改字体大小需要把print.js的内容改一下

javascript 复制代码
elementStyle += 'max-width: ' + params.maxWidth + 'px !important; font-size: ' + params.font_size + ' !important;';

改为

javascript 复制代码
elementStyle += 'max-width: ' + params.maxWidth + 'px !important;';
相关推荐
橙序员小站2 小时前
Agent Skill 是什么?一文讲透 Agent Skill 的设计与实现
前端·后端
炫饭第一名4 小时前
速通Canvas指北🦮——基础入门篇
前端·javascript·程序员
王晓枫5 小时前
flutter接入三方库运行报错:Error running pod install
前端·flutter
符方昊5 小时前
React 19 对比 React 16 新特性解析
前端·react.js
ssshooter5 小时前
又被 Safari 差异坑了:textContent 拿到的值居然没换行?
前端
曲折5 小时前
Cesium-气象要素PNG色斑图叠加
前端·cesium
Forever7_5 小时前
Electron 淘汰!新的桌面端框架 更强大、更轻量化
前端·vue.js
Angelial5 小时前
Vue3 嵌套路由 KeepAlive:动态缓存与反向配置方案
前端·vue.js
jiayu6 小时前
Angular学习笔记24:Angular 响应式表单 FormArray 与 FormGroup 相互嵌套
前端
jiayu6 小时前
Angular6学习笔记13:HTTP(3)
前端