Cesium 动态打印插件 cesium-print is a plugin for cesium printing

Usage

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:

penColor

  • Default: red
  • Acceptable-Values: color string
  • Function Desc: pen Color

strokeWidth

  • Default: 1
  • Acceptable-Values: number
  • Function: stroke width ( unit px )

width

  • Default: 978
  • Acceptable-Values: number
  • Function: print width ( unit px )

height

  • Default: 650, creates a hidden iframe if no-vaild iframe selector is passed
  • Acceptable-Values: number
  • Function: print width ( unit px )

fontSize

  • Default: 32
  • Acceptable-Values: number
  • Function: print title font size ( unit px )

downLoadEnable

  • Default: true
  • Acceptable-Values: Boolean
  • Function: down load print file enable

title

  • Default: print, uses the host page title
  • Acceptable-Values: Any single-line string
  • Function: To change the printed title

Browsers

  • Google Chrome - v ...
  • Firefox - v ...

License

....

Demo

cesium plugin /demo

Code Demo

github.com/richard1015…

Other Cesium Plugin

cesium-navigation-es6 /github


Like our work? Get in touch 51844712@qq.com!

cesium-print 动态打印插件的更多相关文章

  1. Android插件简介

    /** * @actor Steffen.D * @time 2015.02.06 * @blog http://www.cnblogs.com/steffen */ Android插件简介 Andr ...

  2. python3下安装Selenium插件和驱动

    import sysimport osimport shutilimport time os.system('pip install selenium') file_name="IEDriv ...

  3. print.js继承原有样式

    npm install --save print-js import Print from 'print-js' 调用print.js插件 Print({ printable: 'printJS-fo ...

  4. 转:Cesium 和 Webpack

    原文地址:https://www.jianshu.com/p/85917bcc023f 注意:webpack 和 webpack-cli 的安装参考 https://www.cnblogs.com/m ...

  5. Cesium官方教程13--Cesium和Webpack

    原文地址:https://cesiumjs.org/tutorials/cesium-and-webpack/ Cesium 和 Webpack Webpack是非常强大非常流行的JavaScript ...

  6. Cesium参考资源

    Reference resources cesium官网 cesium 下载 cesium官方文档 APIs cesium-workshop github cesium 官方示例 cesium git ...

  7. Zabbix监控系统

    前言: 一个初略自动化运维平台,应该实现以下3个层面自动化: 1.操作系统层面自动化 如果想要万台服务器共舞,没有操作系统这个舞台还怎么舞? 1.1:物理环境: OS预备自动安装(Pxe/KickSt ...

  8. jquery 网页局部打印总结

    最近开发过程中遇到了js局部打印的功能,在网上找相关的资料,最终找到了juery.jqprint-0.3.js 和jquery.PrintArea.js两种. 最初使用的是jquery.jqprint ...

  9. Web打印连续的表格,自动根据行高分页

    拿到这个需求,我已经蛋碎了一地,经过N天的攻克,终于是把它搞定了,只是不知道会不会在某种情况下出现BUG.表示我心虚没有敢做太多的测试.... ---------------------------- ...

随机推荐

  1. IDEA中MyBatis插件的安装及使用

    这个插件的好处就在于能自动关联mapper类与xml,让你可以快速的互相跳转,还能帮助你做简单的排错. 安装方法: 1.File→Settings→Plugins,输入mybatis plugin,本 ...

  2. [LeetCode] 217. Contains Duplicate 包含重复元素

    Given an array of integers, find if the array contains any duplicates. Your function should return t ...

  3. 高级UI-Path和PathMeasure

    Path是一个工具类,用来记录线条的轨迹路径,然后通过绘制轨迹路径,可以得到各种各样的图案,而PathMeasure是用来对Path进行测量的工具,再Path的运用中,运用最多的就是贝塞尔曲线,也是本 ...

  4. Oracle spatial与arcsde 的关系

    有一些同事问过我下面这些问题: 我们用了oracle spatial sdo_geometry,是不是没用arcsde? 我们到底是使用oracle spatial还是arcsde,有点懵! 执行了c ...

  5. win10安装网络适配器

    上面这个有些叫Microsoft Loopback Adapter

  6. javascript添加到收藏夹写法

    javascript添加到收藏夹写法 <pre>function addFavorite2() { var url = window.location; var title = docum ...

  7. 12 Cookie、Session和JSP基础

    1.会话技术 (1)会话概念:一次会话中包含多次请求和响应.一次会话:浏览器第一次给服务器资源发送请求,会话建立,直到有一方断开为止 (2)会话功能:在一次会话的范围内的多次请求间,共享数据 (3)会 ...

  8. python-tkinter使用方法——转载(二)

    转载URL:https://www.cnblogs.com/yudanqu/p/9467803.html Tkinter模块("Tk 接口")是Python的标准Tk GUI工具包 ...

  9. Netty--索引

    Netty 入门示例 Netty原理架构解析 Netty 基本原理 Netty面试题 阿里的Netty知识点你又了解多少

  10. 【程序人生】Oracle正式公布裁员,1600人,补偿N+6

    早些时候Oracle内部员工透漏,Oracle中国研发中心(CDC)或彻底关闭,涉及约1600名工程师的命运. 今天甲骨文正式公布裁员,整个中国研发中心关闭,补偿是全员n+6,包括北京,苏州,南京,上 ...