用JavaScript(JSON)生成pdf、docx、png、svg、flash等,带中文、图形、图片、超链接...
2015-12-05 23:31
609 查看
运行效果: http://sandbox.runjs.cn/show/rdhbtfbw
规范说明见:http://xdoc.sinaapp.com
规范说明见:http://xdoc.sinaapp.com
<script type="text/javascript" src="http://xdoc.sinaapp.com/xdoc.js"></script> <script type="text/javascript"> var obj = { "version": "9.8.1", "meta": { "author": "xdoc" }, "paper": { "margin": "10" }, "body": { "sizeType": "autosize", "items": [ { "Class": "para", "lineSpacing": "4", "align": "center", "items": [ { "Class": "img", "height": "230", "src": "http://img1.imglafaso.com/images/product/000/000/001/742/463/1742463_0_b.jpg", "width": "230" } ] }, { "Class": "para", "align": "center", "items": [ { "Class": "text", "fontName": "黑体", "fontColor": "#ffffff", "backColor": "#ff9900", "text": " 包邮 " }, { "Class": "text", "fontName": "标宋", "text": " 静佳Jplus全身瘦最强攻略3件套装" } ] }, { "Class": "para", "backColor": "#f0f0f0", "align": "center", "lineSpacing": "6", "items": [ { "Class": "text", "valign": "center", "fontName": "标宋", "fontSize": "21", "text": "¥168" }, { "Class": "rect", "padding": "0", "height": "37", "width": "107", "color": "", "items": [ { "Class": "para", "items": [ { "Class": "path", "fillColor": "#800000", "height": "18", "width": "40", "shape": "M 389 190 L 389 1 L 101 1 L 101 131 L 40 189 Z", "color": "", "items": [ { "Class": "para", "align": "right", "items": [ { "Class": "text", "fontColor": "#ffffff", "fontSize": "10", "text": "4.4折" } ] } ] } ] }, { "Class": "para", "items": [ { "Class": "text", "fontColor": "#808080", "fontStyle": "throughline", "valign": "center", "text": "¥390.0" } ] } ] }, { "Class": "rect", "fillColor": "#800000", "gradual": "6", "arc": "8", "fillColor2": "#ff0000", "href": "http://product.lefeng.com/pklist/1742463.html?productId=1742463", "align": "center", "color": "", "valign": "center", "items": [ { "Class": "para", "align": "center", "items": [ { "Class": "text", "fontColor": "#ffffff", "fontStyle": "bold", "valign": "center", "text": "立即疯抢" } ] } ] } ] } ] } }; XDoc.to(obj, "pdf"); //XDoc.to(obj, "docx"); //XDoc.to(obj, "png"); //XDoc.to(obj, "svg"); //XDoc.to(obj, "flash"); </script>
相关文章推荐
- 用JavaScript生成PDF、word。。。
- Ajax 上传文件,返回JSON字符串在FireFox下解析带有<pre>标签的解决办法
- JavaScript变量作用域和变量提升解释(JavaScript Variable Scope and Hoisting Explained)
- JavaScript跨域
- 轻松学习JavaScript十一:JavaScript基本类型(包含类型转换)和引用类型
- js发送post请求下载文件
- 通过 File API 使用 JavaScript 读取文件
- JavaScript中的作用域
- 鼠标滚动插件smoovejs和wowjs
- 常规功能和模块自定义系统 (cfcmms)—021自定义grid列(5附件列)
- JavaScript-DOM编程
- js对象的引用
- JS面向对象的学习
- extjs里的viewport 和window的理解,
- JavaScript事件
- jsp基础
- JS性能优化的那点事
- jsp页面跳转方式
- MyEclipse中修改jsp和servlet模板代码的方法
- js简单登录弹窗