|
sysPrintPlus 封装了Android系统打印、iOS系统AirPrint,支持ipad、打印图片 pdf webView文档
- <!DOCTYPE html>
- <html>
- <head>
- <title>Module Develop</title>
- <meta charset="utf-8">
- <meta name="viewport"
- content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
- <style type="text/css">
- html,
- body {
- height: 100%
- }
- body {
- background-color: #fff;
- margin: 0;
- }
- #wrap {
- height: 100%;
- position: relative;
- }
- #header {
- padding-top: 20px;
- background-color: #5082c2;
- height: 44px;
- position: relative;
- }
- #header h1 {
- font-size: 20px;
- height: 44px;
- line-height: 44px;
- margin: 0em;
- color: #fff;
- margin-left: 100px;
- margin-right: 100px;
- text-align: center;
- }
- #main {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-box-pack: center;
- }
- a.button {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-box-pack: center;
- -webkit-box-align: center;
- height: 32px;
- margin: 8px;
- background-color: rgba(240, 240, 240, 1.0);
- border-color: rgba(220, 220, 220, 1.0);
- border-width: 2px;
- border-style: solid;
- }
- a.active {
- background-color: rgba(240, 240, 240, 0.7);
- }
- </style>
- </head>
- <body>
- <div id="wrap">
- <div id="main">
- <br />
- <a class="button" tapmode="active" onclick="toSystemPrintPage()" >跳转系统打印设置页面</a>
- <a class="button" tapmode="active" onclick="printPdf()" >打印pdf</a>
- <a class="button" tapmode="active" onclick="printWebPage()" >打印web</a>
- <a class="button" tapmode="active" onclick="printHtml()" >打印html</a>
- <a class="button" tapmode="active" onclick="printImg()" >打印图片</a>
- <a class="button" tapmode="active" onclick="hasPrintService()" >判断是否有打印服务</a>
- <br />
- </div>
- </div>
- </body>
- <script type="text/javascript">
- var demo = null;
- apiready = function () {
- demo = api.require('sysPrintPlus');
- if (!demo) {
- alert("请添加模块后编译");
- return;
- }
- }
- function toSystemPrintPage() {
- demo.toSystemPrintPage();
- }
- function printPdf() {
- demo.printPdf({
- filePath: 'widget://res/XF_appsFlyer.pdf',
- }, function (ret, err) {
- //alert(JSON.stringify(ret));
- });
- }
- function printWebPage() {
- demo.printWebPage({
- url: 'https://**.**/Android',
- }, function (ret, err) {
- //alert(JSON.stringify(ret));
- });
- }
- function printHtml() {
- demo.printHtml({
- html: '<html><body><h1>TPS Report for: {{reportDate}}</h1><p>Here are the contents of this week\'s TPS report:</p><p>{{message}}</p><p>If you have any questions regarding this report, pleasedo <b>not</b> ask Mark Murphy.</p></body></html>',
- }, function (ret, err) {
- //alert(JSON.stringify(ret));
- });
- }
- function printImg() {
- demo.printImg({
- filePath: 'widget://res/cloud_pic.png',
- }, function (ret, err) {
- //alert(JSON.stringify(ret));
- });
- }
- function hasPrintService() {
- var ret = demo.hasPrintService();
- alert(JSON.stringify(ret));
- }
- </script>
- </html>
复制代码
|
|