lodop插件如何设置样式打印(去掉样式打印/引入样式打印)
功能介绍:利用lodop插件对页面实现有样式或无样式的打印!具体代码如下:
打印与显示样式一致
var LODOP; //声明为全局变量
function myPreview(){
LODOP = getLodop();
var strBodyStyle = "<style>"+document.getElementById("style").innerHTML+"</style>";
var strFormHtml = strBodyStyle+"<body>"+document.getElementById("form").innerHTML+"</body>";
LODOP.PRINT_INIT("");
LODOP.ADD_PRINT_TEXT(50,50,260,39,"打印与显示样式一致");
LODOP.ADD_PRINT_HTM(88,50,300,200,strFormHtml);
LODOP.PREVIEW();
};
无样式打印
var LODOP; //声明为全局变量
function myPreview(){
LODOP = getLodop();
var strFormHtml = document.getElementById("form").innerHTML;
LODOP.PRINT_INIT("");
LODOP.ADD_PRINT_TEXT(50,50,260,39,"无样式打印");
LODOP.ADD_PRINT_HTM(88,50,300,200,strFormHtml);
LODOP.PREVIEW();
};
style设置样式打印
var LODOP; //声明为全局变量
function myPreview(){
LODOP = getLodop();
var strBodyStyle = "<style>table,td { border: 1 solid #000000;border-collapse:collapse }</style>";
var strFormHtml = strBodyStyle+"<body>"+document.getElementById("form").innerHTML+"</body>";
LODOP.PRINT_INIT("");
LODOP.ADD_PRINT_TEXT(50,50,260,39,"style设置样式打印");
LODOP.ADD_PRINT_HTM(88,50,300,200,strFormHtml);
LODOP.PREVIEW();
};
引入link样式打印
var LODOP; //声明为全局变量
function myPreview(){
LODOP = getLodop();
var strStyleCSS = "<link href = 'style.css' type = 'text/css' rel = 'stylesheet'>";
var strFormHtml = strStyleCSS+"<body>"+document.getElementById("form").innerHTML+"</body>";
LODOP.PRINT_INIT("");
LODOP.ADD_PRINT_TEXT(50,50,260,39,"引入link样式打印");
LODOP.ADD_PRINT_HTM(88,50,300,200,strFormHtml);
LODOP.PREVIEW();
};
以上是编程学习网小编为您介绍的“lodop插件如何设置样式打印(去掉样式打印/引入样式打印)”的全面内容,想了解更多关于 前端知识 内容,请继续关注编程基础学习网。