代码拉取完成,页面将自动刷新
Cesium 动态打印插件 cesium-print is a plugin for cesium printing
Include it in your code after importing npm, like:
npm install cesium-print -dev
Use it like:
import CesiumPrint from "cesium-print";
viewer = new Cesium.Viewer("cesiumContainer", {
contextOptions: {
id: "cesiumCanvas",//must
webgl: {
preserveDrawingBuffer: true
}
}
}
//打印cesium canvas dom
CesiumPrint.drawArea("cesiumCanvas", {
penColor: "yellow", //画笔颜色
strokeWidth: 1 //单位 px
})
.then(base64url => {
//base64url is images
//print drawArea dom
CesiumPrint.print(base64url);
})
.catch(error => {
console.error(error);
});
You can submit the options object like:
//打印cesium canvas dom
CesiumPrint.drawArea("cesiumCanvas", {
penColor: "yellow", //画笔颜色
strokeWidth: 1 //单位 px
})
.then(base64url => {
//自定义打印(设置纸张大小,打印标题)
// 高 宽
// A0:1189mm * 841mm
// A1:841mm * 594mm
// A2:594mm * 420mm
// A3:420mm * 297mm
// A4:297mm * 210mm
// 页边距: 0.75 inch
// A1: 23.39x33.11 inch
// 打印机DPI:300DPI
// 屏幕DPI : 96DPI
// width = (23.39 - 0.75 * 2) * 96 = 2101 px
// height = (33.11 - 0.75 * 2)* 96 = 3034 px
// A4: 8.27x11.69 inch
// 打印机DPI:300DPI
// 屏幕DPI : 96DPI
// width = (8.27 - 0.75 * 2) * 96 = 650 px
// height = (11.69 - 0.75 * 2)* 96 = 978 px
// 所以,当<table> 的width=650px, height=978px时,用IE 打印时,刚好能打印一页的A4纸.
// //a1横向打印尺寸
// var a1 = { width: "3034", height: "2101" };
// //a4横向打印尺寸
var a4 = { width: "978", height: "650" };
let printOptions = {
title: "打印标题(print title)",
width: a4.width,
height: a4.height,
fontSize: "30",
downLoadEnable: true //是否下载打印文件
};
CesiumPrint.print(base64url, printOptions);
});
})
.catch(error => {
console.error(error);
});
Currently this plugin supports the following options:
red
1
978
650
, creates a hidden iframe if no-vaild iframe selector is passed32
true
print
, uses the host page title....
https://github.com/richard1015/cesium-vue-example /(cesium-print,cesium-navigation-es6)
Like our work? Get in touch 51844712@qq.com!
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。