android網頁列印,安卓網頁列印,h5頁面列印,瀏覽器列印,js列印工具

来源:https://www.cnblogs.com/xyblog/archive/2018/07/21/9346564.html
-Advertisement-
Play Games

Android設備列印比較麻煩,一般設備廠商都提供原生app開發的SDK,我們web開發者為難了,不會原生開發啊 給大家提供一個思路,實現web加殼,利用列印瀏覽器實現 簡單來說就是把我們的web頁面嵌入瀏覽器中 web頁面的列印功能通過js與瀏覽器互動 瀏覽器通過調用硬體SDK實現列印 1、機器安 ...


 

Android設備列印比較麻煩,一般設備廠商都提供原生app開發的SDK,我們web開發者為難了,不會原生開發啊

給大家提供一個思路,實現web加殼,利用列印瀏覽器實現

簡單來說就是把我們的web頁面嵌入瀏覽器中

web頁面的列印功能通過js與瀏覽器互動

瀏覽器通過調用硬體SDK實現列印

 

1、機器安裝最新SDK,已安裝請忽略

2、下載安裝本頁下載連接中的列印瀏覽器並安裝

3、對照下方事例代碼,修改web頁面列印功能

4、列印瀏覽器中打開web頁面,測試列印功能

5、預設主頁可以在SD卡根目錄修改homepage.txt中的網址

 

*以上所有步驟必須在智谷聯產品上使用,詳情咨詢銷售工程師

 

 

軟體支持android網頁列印工具,安卓網頁列印工具,h5頁面列印,瀏覽器列印,js列印工具

 

web頁面按照如下事例,修改列印函數代碼,調用列印API即可完成列印功能

 

 

<html>
<head>
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
    <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
    <script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <style type="text/css">
        div {
            margin: 5px 0;
        }

        input {
            width: 49%;
            height: 45 px;
            margin-right: 1%;
            margin-bottom: 1%;
        }

        #tipinfo {
            font-size: 15px;
            color: rgb(255,0,0);
            font-style: italic;
            height: auto;
        }
    </style>
    <script type="text/javascript">

        function javacalljs() {
            document.getElementById("tipinfo").innerHTML =
                "<br\>JAVA調用了JS的無參函數";
        }

        function javacalljswith(arg) {
            document.getElementById("tipinfo").innerHTML = (arg);
        }
    </script>
</head>
<body>
    <header class="bar bar-nav">
        <h1 class='title'>網頁列印演示</h1>
    </header>
    <div class="content">
        <div class="content-padded grid-demo">

            <div id="tipinfo">印表機狀態</div>
            <div class="item-content">
                <div class="item-media"><i class="icon icon-form-comment"></i></div>
                <div class="item-inner">
                    <div class="item-title label">輸入列印內容</div>
                    <div class="item-input">
                        <textarea id="inputtxt">列印內容測試,一維碼生成請輸入數字</textarea>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-50">
                    <input type="button" class="button button-fill" value="生成二維碼" onclick="window.android.createQRCode(document.getElementById('inputtxt').value)" />
                </div>
                <div class="col-50">
                    <input type="button" class="button button-fill" value="生成條碼" onclick="window.android.createBarCode(document.getElementById('inputtxt').value)" />
                </div>
            </div>
            <div class="row">
                <div class="col-50">
                    <input type="button" class="button button-fill" value="列印文本" onclick="window.android.printText(document.getElementById('inputtxt').value)" />
                </div>
                <div class="col-50">
                    <input type="button" class="button button-fill" value="列印Unicode" onclick="window.android.printUnicode('hello, begin to smart print!')" />
                </div>
            </div>
            <div class="row">
                <div class="col-50">
                    <input type="button" class="button button-fill" value="選擇圖片" onclick="window.android.selectPic()" />
                </div>
                <div class="col-50">
                    <input type="button" class="button button-fill" value="列印圖片" onclick="window.android.printPic()" />
                </div>
            </div>
            <div class="row">
                <div class="col-50">
                    <input type="button" class="button button-fill" value="列印網路圖片" onclick="window.android.printNetPic()" />
                </div>
                <div class="col-50">
                    <input type="button" class="button button-fill" value="列印模板二" onclick="window.android.printStyleTwo()" />
                </div>
            </div>
            <div class="row">
                <div class="col-50">
                    <input type="button" class="button button-fill" value="列印模板一" onclick="window.android.printStyleOne()" />
                </div>
                <div class="col-50">
                    <input type="button" class="button button-fill" value="列印模板三" onclick="window.android.printStyleThree()" />
                </div>
            </div>
            <div class="row">
                <div class="col-50">
                    <input type="button" class="button button-fill" value="獲取印表機狀態" onclick="window.android.getPrintStatus()" />
                </div>
            </div>
        </div>
    </div>
</body>
</html>

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 目前市面上的Hive可視化客戶端工具,大都是C/S模式的,安裝使用都不是太方便,目前有一款基於WEB的可視化工具TreeSoft,通過瀏覽器就可以訪問使用了,並且可以同時管理、維護、監控MySQL,Oracle等關係資料庫,值得一用。 1、配置資料庫的連接參數,可以Hive,MySQL同時配置,方便 ...
  • 最近公司要從SqlServer轉到MySql,期間在安裝環境和數據遷移的過程中,遇到了一些不大不小問題,比如怎麼重置密碼、怎麼設置大小寫敏感等等。 這些問題都比較細比較雜,這邊解決完可能過幾天就忘了,所以專門開了一個專題,就當給自己作為備忘記錄吧。 BTW,我的操作系統是Win,MySql版本是8. ...
  • 學習SQL Server 2012編程入門經典(第4版)的筆記 1.事務日誌 任意資料庫的更改起初不進入資料庫本身,而是不斷地被寫入到事務日誌。 日誌是數據進入磁碟上的最先位置。 2.表 資料庫中實際的數據都存在表中。表有行有列。 2.1索引 索引是在特定表或視圖框架記憶體在的對象。索引的功能類似於目 ...
  • Preface I got an replication error 1236 when I modified the password of a user without starting slave threads of replication.Further more,the user was ...
  • 眾所周知資料庫連接的過程,但是最近面試的人(菜面菜),都說用的SSM框架,但是我問了一下,mybatis是怎麼連接上mysql的,基本上都會說:配置好的,直接用了,今天我來拋磚引玉一下,歡迎拍磚!願你有情人終成眷屬,願你有個有趣的靈魂,願你拍我一磚! ...
  • 我的hiveserver2一直不能啟動,命令行一直卡住不動,然後我就想是不是配置文件沒有配置相關的參數,然後就來修改hive-site.xml 最終修改完後的hive-site.xml: 配置成功後,hiveserver2就能啟動成功了。 ...
  • 轉自:http://www.maomao365.com/?p=6679 摘要: 下文將分享使用sql腳本輸出交替變換的不同背景顏色的sql腳本的方法分享,如下所示: 實驗環境:sqlserver 2008 R2 例: 下文 首先採用 over() row_number 函數生成的行編號, 然後對每行 ...
  • Ionic 需要Node.js 環境,官網下載:http://nodejs.org/,node 命令預設將安裝到 /usr/bin https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distri ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...