0

を使用して、レストラン請求 Web アプリを開発しました (要件はブラウザーで実行する Web アプリであったため、デスクトップ アプリケーションではありません) ASP.NET Web Forms C# 4.0。今、新しい要件はPOSサーマルプリンターのレシート印刷です。私は POS に非常に慣れていませんが、どういうわけかサンプル Windows フォーム アプリケーションをビルドして実行し、POSIFLEX PP6800 Thermal Receipt Printerc# を使用して印刷することができました。

問題は、Localhost Web サイトで同じコードを使用して印刷できないことです。を使用してOPOS CCOOposForDotNetAssemblies-1_13_000ます。

私の質問は次のとおりです。

  1. LocalHost の OPOS で印刷できますか?
  2. OPOS over Internet Web サイトで印刷することはできますか?
  3. はいの場合、どうすればよいですか? 私は何を間違っていますか?

私が使用しているコードは次のとおりです。

using POS.Devices;
private OPOSPOSPrinter Printer = null;
protected void Button1_Click(object sender, EventArgs e)
{
    Printer = new OPOSPOSPrinterClass();

    // Open the printer.
    Printer.Open("PosPrinter");
    Printer.ClaimDevice(1000);
    Printer.AsyncMode = true;
    Printer.DeviceEnabled = true;
    Printer.ResultCode;
    Printer.PrintNormal(2, "\x1B|cA\x1B|2CHeading\x1B|1C\n"+DateTime.Now.ToString("D")+"\n\n" );
    Printer.CutPaper(1);
    Printer.Close();
 }

興味深いことに、エラーはありませんが、タイムアウトになるまでビープ音が聞こえ、プリンターは 1 行にいくつかのドットと文字を印刷し、他には何も印刷しません。Windowsフォームでは発生していません。前もって感謝します。

4

2 に答える 2

0

Public Sub GiftReceipt()

試す

    Dim displayString As String

     Dim ESC As String = Chr(&H1B)

    displayString = ESC + "!" + Chr(1) + ESC + "|cA" + "Store Name" + ESC + "|1lF"
    displayString += ESC + "|cA" + "Store Address" + ESC + "|1lF"
    displayString += ESC + "|2C" + ESC + "|cA" + ESC + "|bC" + "Gift Receipt" + ESC + "|1lF" + ESC + "|1lF"
    displayString += ESC + "|N" + ESC + "!" + Chr(1) + "  Transaction #:  " + vbTab.ToString() + "105" + ESC + "|1lF"

displayString += " 日付: " + Date.Today() + vbTab.ToString() + "時間: "

   displayString += DateAndTime.Now().ToLongTimeString() + ESC + "|1lF"

   displayString += "  Cashier:  " + CStr(_currSess.Cashier.Number) + vbTab.ToString() + "Register:  " + CStr(_currSess.Register.Number) + ESC + "|1lF" + ESC + "|1lF"

   displayString += ESC + "|2uC" + "  Item                 Description           Quantity" + ESC + "|N" + ESC + "!" + Chr(1) + ESC + "|1lF" + ESC + "|1lF" + "  "

    'Iterate loop for each row of the Data Set.
For k As Integer = 0 To TransactionSet1.TransactionEntry.Rows.Count - 1

            'Checking for each row which has selected in DataGrid item.
  If CType(dgTransactionList.Item(k, 0), System.String) = "True" Then

                  'Get the Item value from selected row.
      Dim item As String = dgTransactionList.Item(k, 1).ToString()

                  Dim itemValue As String = String.Empty
                   If item.Length > 11 Then

'アイテムの長さが 11 より大きい場合、アイテム 0 から 11 の部分文字列を取得します。item = item.Substring(0, 11) Else '長さが 11 になるまでアイテム文字列に " " を追加します。while item.Length <= 11

                                 item += " "

                          End While

                  End If

     displayString += item + vbTab.ToString()
 Dim desc As String = dgTransactionList.Item(k, 2).ToString()
     Dim descValue As String = String.Empty

      If desc.Length > 20 Then

  'If Description length is greater then 20, then take substring of item 0 to 20.
             desc = desc.Substring(0, 20)

                Else
            While desc.Length <= 20

           'Adding " " in Description string until length 20.
                              desc += " "

                       End While

                End If

                displayString += desc + vbTab.ToString()
    Dim qnty As String = dgTransactionList.Item(k, 3).ToString()
                Dim qntyValue As String = String.Empty

                If qnty.Length > 3 Then

  'If Quantity length is greater then 20, then take substring of quantity 0 to 3.
      qnty = qnty.Substring(0, 3)

                Else

                    While qnty.Length <= 3

                  'Adding " " in Quantity string until length 20.
                             qntyValue += " "
                              qnty += " "

                    End While

                End If

                qntyValue += qnty.Trim()
                displayString += qntyValue
                displayString += ESC + "|1lF" + "  "

            End If

    Next k

 displayString += ESC + "|1lF"
 displayString += ESC + "|cA" + "Thank You for shopping" + ESC + "|1lF"
        displayString += ESC + "|cA" + _currSess.Configuration.StoreName + ESC + "|1lF"
        displayString += ESC + "|cA" + "We hope you'll come back soon!" + ESC + "|1lF" + ESC + "|1lF" + ESC + "|fP"
        _currSess.Register.SetActivePrinterNumber(0)

        Dim objRp As Object = _currSess.Register.ReceiptPrinter
        objRp.PrintNormal(2, displayString))

        objRp.Release()
        MsgBox("Gift Receipt printed Successfully.")

Catch ex As Exception

        MsgBox(ex.ToString())

 End Try

サブ終了

于 2015-01-12T09:05:59.640 に答える
0

私は最近、サーマルプリンターを使用して領収書を印刷するPOS Webアプリケーションを開発しました。これはローカルプリンターを使用します

JavaScript を使用してコンテナーをキャプチャするか、コンテンツをキャプチャするだけです。

window.print() を使用して呼び出すだけで、領収書を印刷できます

于 2015-04-10T20:52:01.337 に答える