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. 使用Termux,在手机上做nodejs编程,运行nodejs程序。

    如果你是一名nodejs开发者,是否想过以下问题:在手机上运行nodejs程序?用手机当nodejs服务器?在手机上做nodejs编程?YES!使用Termux,以上都可以做到! 下面展示如何实现这个 ...

  2. 最新 浩德钢圈java校招面经 (含整理过的面试题大全)

    从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿.浩德钢圈等10家互联网公司的校招Offer,因为某些自身原因最终选择了浩德钢圈.6.7月主要是做系统复习.项目复盘.Leet ...

  3. SpringMVC的基本概念

    1.1关于三层架构和MVC 1.1.1 三层架构 我们的开发架构一般都是基于两种形式,一种是 C/S 架构,也就是客户端/服务器,另一种是 B/S 架构,也就 是浏览器服务器.在 JavaEE 开发中 ...

  4. Windows 反弹 Shell

    NC 反弹 shell 攻击场景: Victim IP: 192.168.2.10 Attacker IP:192.168.2.11 正向 Shell 我们想要弹回Victim的Shell,使用如下命 ...

  5. JIRA学习

    Jira是Atlassian公司出品的一款事务管理软件.无论是“需求”,还是“BUG”,或是“任务”,都是“事务”的一种,所以Jira可以胜任非常多的角色:需求管理.缺陷跟踪.任务管理等等……因为Ji ...

  6. TCP/IP学习笔记2--协议分层与OSI参考模型

    协议的分层: 为解决不同计算机之间的通信,ISO(International Organization for Standards)指定了一个国际标准OSI(Open Systems Intercon ...

  7. LeetCode 103. 二叉树的锯齿形层次遍历(Binary Tree Zigzag Level Order Traversal)

    103. 二叉树的锯齿形层次遍历 103. Binary Tree Zigzag Level Order Traversal 题目描述 给定一个二叉树,返回其节点值的锯齿形层次遍历.(即先从左往右,再 ...

  8. 《Mysql - 自增主键为何不是连续的?》

    一:自增主键是连续的么? - 自增主键不能保证连续递增. 二:自增值保存在哪里? - 当使用 show create table `table_name`:时,会看到 自增值,也就是 AUTO_INC ...

  9. MySQL直方图

    MySQL8.0开始支持索引之外的数据分布统计信息可选项 我们知道,在DB中,优化器负责将SQL转换为很多个不同的执行计划,完了从中选择一个最优的来实际执行.但是有时候优化器选择的最终计划有可能随着D ...

  10. java.lang.IllegalArgumentException: Expected authority at index 7: http:// 异常的原因

    今天遇到个错误,异常信息  java.lang.IllegalArgumentException: Expected authority at index 7: http://  ,中文意思就是说参数 ...