33

Web ページから Zebra プリンタにバーコードを印刷しようとしています。

おそらくWebフォントを使用して、プリンター独自のフォントを使用してそれらを印刷する方法があるかどうか、または使用されているフォント名を知っているかどうか疑問に思っていますか?

基本的にバーコードを含む画像を生成するphpバーコードジェネレーターを使用しようとしています。実際、私はこのアプローチをすでに数日間試していますが、成功していません.

問題は、それらを印刷すると、スキャナーで読み取れないことです。プリンターの解像度(203dpi)に合わせて画像の解像度を変更しようとしましたが、画像のサイズと形式をいじってみましたが、印刷後のバーコードはまだスキャンできません。

それで、誰もこれを経験したことがありますか?

プリンター: ゼブラ TLP 2844

ページごとに必要なバーコード:

  • 01 Code39 横 (非常に特定のサイズとブラウザーで印刷された場合にのみスキャン可能)
  • 01 Code128 垂直 (まだ機能しない。印刷は常に非常にぼやけており、スキャンされない)

===========

このプリンターが EPL2 言語をサポートしていることがわかったので、それを使用してバーコードを印刷しようとしています。

最初に、パス スルー モードを有効にする必要がありました。これは、[プリンター オプション] > [詳細設定] > [その他] で行いました。

これで、次のコマンドを使用して、プリンターの組み込みフォント :D を使用してバーコードを完璧に印刷できるようになりました。

ZPL: B10,10,0,1,2,2,60,N,"TEXT-GOES-HERE" :ZPL

しかし、メモ帳からしか印刷できません。ブラウザからこれを印刷することはまだできません...おそらく、LFがCR + LFに置き換えられていることに問題があります...

この問題を克服するには??

===========

私が印刷しようとしているラベルには、実際にはバーコードの前にテキストが少しあり、いくつかの HTML テーブルが適切にフォーマットされています。したがって、これを最初に印刷する必要があり、途中で素敵なラベルを貼り付けてから、さらにテキストを追加する必要があります。

したがって、純粋な EPL2 を使用してすべてを印刷することはできません。目標を達成するために html + EPL2 + html の両方を使用できるかどうか疑問に思っていますか、それとも許可されていませんか?? =/

4

8 に答える 8

26

あなたはいくつかの障害に直面しています:

1) OS がインストールされたプリンタ ドライバを介して印刷する場合、プリンタ ドライバは送信されたデータを取得し、出力デバイス (Zebra プリンタ) 用に (再) ラスタライズまたはスケーリングしようとします。プリンターの解像度は 203dpi と比較的低いため、バーコードの品質の整合性を失うためにプリンター ドライバーが実行する必要のあるスケーリングにそれほど時間はかかりません。これが、ダイレクト ZPL コマンドを使用して生成されたバーコードがはるかに信頼性が高い理由です。

2) Web ブラウザーが意図的にクライアント コンピューターへのアクセスを許可しないことによって提供するセキュリティのため、クライアントに接続されたプリンターと直接通信することはできません。このサンドボックスは、悪意のある Web サイトがクライアント マシンにファイルを書き込んだり、プリンターなどのデバイスに出力を直接送信したりできないように、ユーザーをマルウェアから保護するのに役立ちます。そのため、ブラウザーを介してクライアントに接続されたプリンターに ZPL コマンドを直接送信することはできません。

ただし、あなたが説明したことを行う方法があります。通常、必要な手順は、Zebra プリンタに印刷しようとしているサイトにアクセスするクライアント コンピュータをある程度制御できる場合にのみ役立ちます。たとえば、これは、会社のネットワーク上のマシン、または作成する必要がある小さなアプリケーションをインストールするクライアントによってのみ使用されます。これを行うには、次の手順を確認する必要があります。

A) 独自のカスタム MIME タイプを作成する必要があります。これは基本的に、登録されている MIME タイプと衝突しない、使用したい任意の名前です。

B) 次に、カスタム MIME タイプにマップするファイル拡張子を定義します。これを行うには、通常、定義する新しい MIME タイプと、これらのタイプのファイルに使用されるファイル拡張子を許可するように、Web サーバーを構成する必要があります (この手順は、使用している Web サーバーによって異なります)。

C) 次に、Web アプリケーションで ZPL データを出力する場合、新しい MIME タイプにマップされたファイル名拡張子を使用してファイルに書き込みます。ファイルが生成されたら、そのファイルへの HTML リンクを提供するか、クライアント ブラウザをファイルにリダイレクトできます。この時点で、作成したファイルを raw プリンター ポートに手動で直接コピーすることにより、ファイルが正しく機能しているかどうかをテストできます。

D) 次に、クライアントにインストールできる小さなアプリケーションを作成する必要があります。アプリケーションをインストールしたら、カスタム MIME タイプの有効な消費アプリケーションとしてそれ自体を登録する必要があります。指定された MIME タイプのファイル用のアプリケーションがインストールされていることをブラウザが検出した場合、ブラウザはそのファイルをクライアント マシンの一時ディレクトリに書き込み、同じ登録済み MIME タイプのアプリケーションを一時ファイルとして起動しようとします。アプリケーションへのパラメーター。したがって、アプリケーションはブラウザから渡されたファイルを読み取るだけで、それを直接プリンタにダンプしようとします。

これは、説明していることを達成するために必要なことの概要です。特定の手順の一部は、使用している Web サーバーの種類とクライアント マシンの OS によって異なります。しかし、これはあなたが試みていることを達成するための高レベルの概要です。

于 2012-06-11T22:44:08.823 に答える
8

Java アプレットのロードを検討する場合、qz-print (以前の jzebra) は、説明したことを正確に行うことができ、コメントに記載されている LP2844 とうまく連携します。

https://code.google.com/p/jzebra/

于 2014-01-26T20:27:41.653 に答える
5

Web アプリで行ったこと:

1) 無料の printfile アプリをダウンロードhttp://www.lerup.com/printfile/

「PrintFile は、ファイルをすばやく簡単に印刷できるようにするフリーウェアの MS Windows ユーティリティ プログラムです。このプログラムは、プレーン テキスト、PostScript、Encapsulated PostScript (EPS)、およびバイナリ形式を認識します。このプログラムを使用すると、大量の用紙を節約できるため、貴重な天然資源を節約します。」

PrintFile を初めて実行するときは、詳細オプションに移動し、「プリンターに直接送信」を有効にします。

2) Windows で ZEBRA プリンターを Generic Text Printer としてセットアップします。

2) web アプリで file.prt ファイルを生成します。これはプレーン テキストの EPL ファイルです。

3) ダウンロードしたファイルをダブルクリックすると、すぐにバーコードが印刷されます。魅力のように機能します。GUI が表示されないように PrintFile をセットアップすることもできます。

于 2015-06-12T16:37:55.163 に答える
4

また、ZPL コマンドをテキスト ファイルで送信し (複数のラベルを 1 つのファイルにまとめることができます)、ユーザーに Windows のメモ帳でファイルを開いて印刷させることもできます。唯一の注意点は、デフォルトのヘッダーとフッターを削除する必要があることです ([ファイル] --> [ページ設定])。

ちょっとしたユーザー トレーニングですが、クライアント マシンを制御できない場合は問題ないかもしれません。

于 2012-12-17T18:17:57.600 に答える
3

私はここで似たようなものを開発しています。webapp から LP2844 で印刷する必要があります。問題は、私の webapp がクラウド (Amazon EC2) のリモート サーバーにあり、プリンターが倉庫のデスクにあることです。

私の解決策: webapp はバーコード付きのラベルのEPL2 コードを生成し、 PubNub メッセージを発行します。プリンターが接続されているコンピューターで実行される小さな C# プログラムを作成しました。プログラムはメッセージを受信し、コードをプリンターに送信します。

于 2012-10-14T20:04:50.520 に答える
2

私は、「Tres Finocchiaro」が提案したアイデアに従い、以下に基づいてアプリケーションを作成しました。

  1. ASP.NET 4.0
  2. IIS
  3. Chrome、IExplorer、Firefox
  4. ゼブラ TLP 2844
  5. EPLプロトコル

残念ながら、現在のブラウザのセキュリティの問題により、 jzebraが正しく機能するにはいくつかの改善が必要です。

jzebra のインストール

jzebdra をダウンロードし、dist ディレクトリからディレクトリにコピーします (例mydir: ):

  • ウェブ
    • mydir
      • js
        • ..
        • deployJava.js
      • ライブラリ
        • ..
      • qz-print.jar
      • qz-print_jnlp.jnlp

print.html を作成します

<html>
<script type="text/javascript" src="js/deployJava.js"></script>
<script type="text/javascript">
    /**
    * Optionally used to deploy multiple versions of the applet for mixed
    * environments.  Oracle uses document.write(), which puts the applet at the
    * top of the page, bumping all HTML content down.
    */
    deployQZ();

    /** NEW FUNCTION **/
    function initPrinter() {
        findPrinters();
        useDefaultPrinter();
    }

    /** NEW FUNCTION **/    
    function myalert(txt) {
        alert(txt);
    }


    /**
    * Deploys different versions of the applet depending on Java version.
    * Useful for removing warning dialogs for Java 6.  This function is optional
    * however, if used, should replace the <applet> method.  Needed to address 
    * MANIFEST.MF TrustedLibrary=true discrepency between JRE6 and JRE7.
    */
    function deployQZ() {
        var attributes = {id: "qz", code:'qz.PrintApplet.class', 
            archive:'qz-print.jar', width:1, height:1};
        var parameters = {jnlp_href: 'qz-print_jnlp.jnlp', 
            cache_option:'plugin', disable_logging:'false', 
            initial_focus:'false'};
        if (deployJava.versionCheck("1.7+") == true) {}
        else if (deployJava.versionCheck("1.6+") == true) {
            delete parameters['jnlp_href'];
        }
        deployJava.runApplet(attributes, parameters, '1.5');
    }

    /**
    * Automatically gets called when applet has loaded.
    */
    function qzReady() {
        // Setup our global qz object
        window["qz"] = document.getElementById('qz');
        var title = document.getElementById("title");
        if (qz) {
            try {
                title.innerHTML = title.innerHTML + " " + qz.getVersion();
                document.getElementById("content").style.background = "#F0F0F0";
            } catch(err) { // LiveConnect error, display a detailed meesage
                document.getElementById("content").style.background = "#F5A9A9";
                alert("ERROR:  \nThe applet did not load correctly.  Communication to the " + 
                    "applet has failed, likely caused by Java Security Settings.  \n\n" + 
                    "CAUSE:  \nJava 7 update 25 and higher block LiveConnect calls " + 
                    "once Oracle has marked that version as outdated, which " + 
                    "is likely the cause.  \n\nSOLUTION:  \n  1. Update Java to the latest " + 
                    "Java version \n          (or)\n  2. Lower the security " + 
                    "settings from the Java Control Panel.");
          }
      }
    }

    /**
    * Returns whether or not the applet is not ready to print.
    * Displays an alert if not ready.
    */
    function notReady() {
        // If applet is not loaded, display an error
        if (!isLoaded()) {
            return true;
        }
        // If a printer hasn't been selected, display a message.
        else if (!qz.getPrinter()) {
           /** CALL TO NEW FUNCTION **/
            initPrinter();
            return false;
        }
        return false;
    }

    /**
    * Returns is the applet is not loaded properly
    */
    function isLoaded() {
        if (!qz) {
            alert('Error:\n\n\tPrint plugin is NOT loaded!');
            return false;
        } else {
            try {
                if (!qz.isActive()) {
                    alert('Error:\n\n\tPrint plugin is loaded but NOT active!');
                    return false;
                }
            } catch (err) {
                alert('Error:\n\n\tPrint plugin is NOT loaded properly!');
                return false;
            }
        }
        return true;
    }

    /**
    * Automatically gets called when "qz.print()" is finished.
    */
    function qzDonePrinting() {
        // Alert error, if any
        if (qz.getException()) {
            alert('Error printing:\n\n\t' + qz.getException().getLocalizedMessage());
            qz.clearException();
            return; 
        }

        // Alert success message
        alert('Successfully sent print data to "' + qz.getPrinter() + '" queue.');
    }

    /***************************************************************************
    * Prototype function for finding the "default printer" on the system
    * Usage:
    *    qz.findPrinter();
    *    window['qzDoneFinding'] = function() { alert(qz.getPrinter()); };
    ***************************************************************************/
    function useDefaultPrinter() {
        if (isLoaded()) {
            // Searches for default printer
            qz.findPrinter();

            // Automatically gets called when "qz.findPrinter()" is finished.
            window['qzDoneFinding'] = function() {
                // Alert the printer name to user
                var printer = qz.getPrinter();
                myalert(printer !== null ? 'Default printer found: "' + printer + '"':
                    'Default printer ' + 'not found');

                // Remove reference to this function
                window['qzDoneFinding'] = null;
            };
        }
    }

    /***************************************************************************
    * Prototype function for finding the closest match to a printer name.
    * Usage:
    *    qz.findPrinter('zebra');
    *    window['qzDoneFinding'] = function() { alert(qz.getPrinter()); };
    ***************************************************************************/
    function findPrinter(name) {
        // Get printer name from input box
        var p = document.getElementById('printer');
        if (name) {
            p.value = name;
        }

        if (isLoaded()) {
            // Searches for locally installed printer with specified name
            qz.findPrinter(p.value);

            // Automatically gets called when "qz.findPrinter()" is finished.
            window['qzDoneFinding'] = function() {
                var p = document.getElementById('printer');
                var printer = qz.getPrinter();

                // Alert the printer name to user
                alert(printer !== null ? 'Printer found: "' + printer + 
                    '" after searching for "' + p.value + '"' : 'Printer "' + 
                    p.value + '" not found.');

                // Remove reference to this function
                window['qzDoneFinding'] = null;
            };
        }
    }

    /***************************************************************************
    * Prototype function for listing all printers attached to the system
    * Usage:
    *    qz.findPrinter('\\{dummy_text\\}');
    *    window['qzDoneFinding'] = function() { alert(qz.getPrinters()); };
    ***************************************************************************/
    function findPrinters() {
        if (isLoaded()) {
            // Searches for a locally installed printer with a bogus name
            qz.findPrinter('\\{bogus_printer\\}');

            // Automatically gets called when "qz.findPrinter()" is finished.
            window['qzDoneFinding'] = function() {
                // Get the CSV listing of attached printers
                var printers = qz.getPrinters().split(',');
                for (i in printers) {
                    myalert(printers[i] ? printers[i] : 'Unknown');      
                }

                // Remove reference to this function
                window['qzDoneFinding'] = null;
            };
        }
    }

    /***************************************************************************
    * Prototype function for printing raw EPL commands
    * Usage:
    *    qz.append('\nN\nA50,50,0,5,1,1,N,"Hello World!"\n');
    *    qz.print();
    ***************************************************************************/
    function print() {
        if (notReady()) { return; }

        // Send characters/raw commands to qz using "append"
        // This example is for EPL.  Please adapt to your printer language
        // Hint:  Carriage Return = \r, New Line = \n, Escape Double Quotes= \"
        qz.append('\nN\n');            
        qz.append('q609\n');
        qz.append('Q203,26\n');
        qz.append('B5,26,0,1A,3,7,152,B,"1234"\n');
        qz.append('A310,26,0,3,1,1,N,"SKU 00000 MFG 0000"\n');
        qz.append('A310,56,0,3,1,1,N,"QZ PRINT APPLET"\n');
        qz.append('A310,86,0,3,1,1,N,"TEST PRINT SUCCESSFUL"\n');
        qz.append('A310,116,0,3,1,1,N,"FROM SAMPLE.HTML"\n');
        qz.append('A310,146,0,3,1,1,N,"QZINDUSTRIES.COM"');

        // Append the rest of our commands
        qz.append('\nP1,1\n');

        // Tell the applet to print.
        qz.print();
     }

    /***************************************************************************
    * Prototype function for logging a PostScript printer's capabilites to the
    * java console to expose potentially  new applet features/enhancements. 
    * Warning, this has been known to trigger some PC firewalls
    * when it scans ports for certain printer capabilities.
    * Usage: (identical to appendImage(), but uses html2canvas for png rendering)
    *    qz.setLogPostScriptFeatures(true);
    *    qz.appendHTML("<h1>Hello world!</h1>");
    *    qz.printPS();
    ***************************************************************************/ 
    function logFeatures() {
        if (isLoaded()) {
            var logging = qz.getLogPostScriptFeatures();
            qz.setLogPostScriptFeatures(!logging);
            alert('Logging of PostScript printer capabilities to console set to "' + !logging + '"');
        }
    }

    /***************************************************************************
    ****************************************************************************
    * *                          HELPER FUNCTIONS                             **
    ****************************************************************************
    ***************************************************************************/

    function getPath() {
        var path = window.location.href;
        return path.substring(0, path.lastIndexOf("/")) + "/";
    }

    /**
    * Fixes some html formatting for printing. Only use on text, not on tags!
    * Very important!
    *   1.  HTML ignores white spaces, this fixes that
    *   2.  The right quotation mark breaks PostScript print formatting
    *   3.  The hyphen/dash autoflows and breaks formatting  
    */
    function fixHTML(html) {
        return html.replace(/ /g, "&nbsp;").replace(/’/g, "'").replace(/-/g,"&#8209;"); 
    }

    /**
    * Equivelant of VisualBasic CHR() function
    */
    function chr(i) {
        return String.fromCharCode(i);
    }

    /***************************************************************************
    * Prototype function for allowing the applet to run multiple instances.
    * IE and Firefox may benefit from this setting if using heavy AJAX to
    * rewrite the page.  Use with care;
    * Usage:
    *    qz.allowMultipleInstances(true);
    ***************************************************************************/ 
    function allowMultiple() {
      if (isLoaded()) {
        var multiple = qz.getAllowMultipleInstances();
        qz.allowMultipleInstances(!multiple);
        alert('Allowing of multiple applet instances set to "' + !multiple + '"');
      }
    }
</script>

    <input type="button" onClick="print()" />
    </body>
</html>

提供されるコードは、「jzebra_installation/dist/sample.html」に基づいています。

于 2014-11-20T20:03:05.960 に答える