Пример #1
0
        public void BrotherPrintThis()
        {
            try
            {
                string        path = @"C:\cartaebest3.lbx";
                bpac.Document doc  = new bpac.Document();
                doc.Open(path);
                bool   test    = doc.SetPrinter("Brother QL-800", true);
                string pedido2 = "Tipo pedido: Revision";
                string nombre  = "Nombre: " + txtnombre.Text;
                string numero  = "Numero: " + txtnumero.Text;
                string obser   = "Obs.: " + txtdescri.Text;
                // string orden = "Numero orden: " + orden;
                string orden2 = orden;
                doc.GetObject("pedido").Text = pedido2;
                doc.GetObject("nombre").Text = nombre;
                doc.GetObject("numero").Text = numero;
                doc.GetObject("modelo").Text = "Modelo: " + txtmodelo.Text;

                doc.GetObject("fecha").Text = fechafin;

                doc.GetObject("obser").Text      = obser;
                doc.GetObject("contraseña").Text = "Clave: " + Contrasena;

                doc.GetObject("id").Text = ID;
                //doc.GetObject("orden").Text = orden;
                doc.GetObject("codigo").Text = orden2;
                //doc.GetObject("tiempo").Text = espera;
                doc.StartPrint("", bpac.PrintOptionConstants.bpoDefault);
                doc.PrintOut(1, bpac.PrintOptionConstants.bpoDefault);
                doc.EndPrint();
                doc.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            var doc = new bpac.Document();

            // プリンタの情報を列挙
            ShowPrinterInfo(doc);

            // プリンタが印刷できる状態にあるか確認
            var enabledPrinter = GetEnabledPrinterName(doc);
            if (string.IsNullOrEmpty(enabledPrinter))
            {
                Console.WriteLine("利用できるプリンタがありません。");
                Console.ReadLine();
                return;
            }

            Console.WriteLine($"何かキーを押すと、{enabledPrinter}から印刷します。");
            Console.ReadLine();

            // ラベルの編集と印刷
            // 念のため、有効なプリンタを再設定
            doc.SetPrinter(enabledPrinter, false);

            var runDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            var labelFilePath = System.IO.Path.Combine(runDir, @"test.lbx");

            var hasOpened = doc.Open(labelFilePath);
            if (!hasOpened)
            {
                Console.WriteLine("指定されたラベルを開けませんでした");
                Console.ReadLine();
                return;
            }

            // 印刷完了イベントに行う処理を追加
            doc.Printed += new bpac.IPrintEvents_PrintedEventHandler(HandlePrinted);

            // 印刷設定開始:最後でカットし、品質優先印刷を行う
            // C#の場合、オプションを複数設定するには、"論理OR演算子" (|)を使う
            // https://msdn.microsoft.com/ja-jp/library/6a71f45d.aspx
            doc.StartPrint("", bpac.PrintOptionConstants.bpoCutAtEnd | PrintOptionConstants.bpoQuality);

            // ラベルの編集
            for (int i = 1; i < 3; i++)
            {
                // ラベルのテキストオブジェクトを上書き
                doc.GetObject("Content").Text = $"No.{i.ToString()}";

                // ラベルのバーコードオブジェクトを上書き
                // GetBarcodeIndex()にオブジェクト名を渡す
                doc.SetBarcodeData(doc.GetBarcodeIndex("Barcode"), i.ToString());

                // 現在のシートの印刷を印刷ジョブに追加する
                // なお、第二引数は"無効"らしいので、何を指定しても変化しないっぽい
                doc.PrintOut(1, bpac.PrintOptionConstants.bpoAutoCut);
            }

            doc.EndPrint();
            doc.Close();

            Console.ReadLine();
        }
Пример #3
0
        static void Main(string[] args)
        {
            var doc = new bpac.Document();

            // プリンタの情報を列挙
            ShowPrinterInfo(doc);

            // プリンタが印刷できる状態にあるか確認
            var enabledPrinter = GetEnabledPrinterName(doc);

            if (string.IsNullOrEmpty(enabledPrinter))
            {
                Console.WriteLine("利用できるプリンタがありません。");
                Console.ReadLine();
                return;
            }

            Console.WriteLine($"何かキーを押すと、{enabledPrinter}から印刷します。");
            Console.ReadLine();

            // ラベルの編集と印刷
            // 念のため、有効なプリンタを再設定
            doc.SetPrinter(enabledPrinter, false);

            var runDir        = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            var labelFilePath = System.IO.Path.Combine(runDir, @"test.lbx");

            var hasOpened = doc.Open(labelFilePath);

            if (!hasOpened)
            {
                Console.WriteLine("指定されたラベルを開けませんでした");
                Console.ReadLine();
                return;
            }


            // 印刷完了イベントに行う処理を追加
            doc.Printed += new bpac.IPrintEvents_PrintedEventHandler(HandlePrinted);


            // 印刷設定開始:最後でカットし、品質優先印刷を行う
            // C#の場合、オプションを複数設定するには、"論理OR演算子" (|)を使う
            // https://msdn.microsoft.com/ja-jp/library/6a71f45d.aspx
            doc.StartPrint("", bpac.PrintOptionConstants.bpoCutAtEnd | PrintOptionConstants.bpoQuality);

            // ラベルの編集
            for (int i = 1; i < 3; i++)
            {
                // ラベルのテキストオブジェクトを上書き
                doc.GetObject("Content").Text = $"No.{i.ToString()}";

                // ラベルのバーコードオブジェクトを上書き
                // GetBarcodeIndex()にオブジェクト名を渡す
                doc.SetBarcodeData(doc.GetBarcodeIndex("Barcode"), i.ToString());

                // 現在のシートの印刷を印刷ジョブに追加する
                // なお、第二引数は"無効"らしいので、何を指定しても変化しないっぽい
                doc.PrintOut(1, bpac.PrintOptionConstants.bpoAutoCut);
            }

            doc.EndPrint();
            doc.Close();

            Console.ReadLine();
        }