Ejemplo n.º 1
0
 protected void Page_Init(object sender, EventArgs e)
 {
     if (WebClientPrint.ProcessPrintJob(this.Request))
     {
         PrintingManager.Print("AAAA", this);
     }
 }
Ejemplo n.º 2
0
        protected void Page_Init(object sender, System.EventArgs e)
        {
            if (WebClientPrint.ProcessPrintJob(this.Request))
            {
                session_id = this.Request.QueryString["sid"];
                //PrintingManager.Print((string)Application[session_id + CommonConstants.PrintCommand], this);
//                PrintingManager.Print("^XA" + "\n" +
//"^PW900" + "\n" +
//"^FO0,158^GB830,0,2,^FS" + "\n" +
//"^FO0,441^GB830,0,2,^FS" + "\n" +
//"^FO0,562^GB830,0,2,^FS" + "\n" +
//"^FO400,562^GB2,121,2^FS" + "\n" +
//"^FO0,683^GB830,0,2,^FS" + "\n" +
//"^FO600,683^GB2,100,2^FS" + "\n" +
//"^FO0,784^GB830,0,2,^FS" + "\n" +
//"^FO550,784^GB2,100,2^FS" + "\n" +
//"^FO0,884^GB830,0,2,^FS" + "\n" +
//"^FO33,12^AD,18^FDAir Line^FS" + "\n" +
//"^FO33,452^AD,18^FDAir Waybill No.^FS" + "\n" +
//"^FO33,574^AD,18^FDDestination^FS" + "\n" +
//"^FO410,574^AD,18^FDTotal No. of Pieces^FS" + "\n" +
//"^FO610,695^AD,18^FDOrigin^FS" + "\n" +
//"^FO33,796^AD,18^FDHAWB No.^FS" + "\n" +
//"^FO560,796^AD,18^FDHAWB PCS^FS" + "\n" +
//"^FO33,896^AD,18^FDHAWB Weight^FS" + "\n" +
//"^XZ",this);
            }
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.Now); //or a date much earlier than current time
        }
        public void PrintCommands(string sid)
        {
            if (WebClientPrint.ProcessPrintJob(System.Web.HttpContext.Current.Request.Url.Query))
            {
                HttpApplicationStateBase app = HttpContext.Application;

                //Create a ClientPrintJob obj that will be processed at the client side by the WCPP
                ClientPrintJob cpj = new ClientPrintJob();

                //get printer commands for this user id
                object printerCommands = app[sid + PRINTER_COMMANDS];
                if (printerCommands != null)
                {
                    cpj.PrinterCommands = printerCommands.ToString();
                    cpj.FormatHexValues = true;
                }

                //get printer settings for this user id
                int printerTypeId = (int)app[sid + PRINTER_ID];

                if (printerTypeId == 0) //use default printer
                {
                    cpj.ClientPrinter = new DefaultPrinter();
                }
                else if (printerTypeId == 1) //show print dialog
                {
                    cpj.ClientPrinter = new UserSelectedPrinter();
                }
                else if (printerTypeId == 2) //use specified installed printer
                {
                    cpj.ClientPrinter = new InstalledPrinter(app[sid + INSTALLED_PRINTER_NAME].ToString());
                }
                else if (printerTypeId == 3) //use IP-Ethernet printer
                {
                    cpj.ClientPrinter = new NetworkPrinter(app[sid + NET_PRINTER_HOST].ToString(), int.Parse(app[sid + NET_PRINTER_PORT].ToString()));
                }
                else if (printerTypeId == 4) //use Parallel Port printer
                {
                    cpj.ClientPrinter = new ParallelPortPrinter(app[sid + PARALLEL_PORT].ToString());
                }
                else if (printerTypeId == 5) //use Serial Port printer
                {
                    cpj.ClientPrinter = new SerialPortPrinter(app[sid + SERIAL_PORT].ToString(),
                                                              int.Parse(app[sid + SERIAL_PORT_BAUDS].ToString()),
                                                              (SerialPortParity)Enum.Parse(typeof(SerialPortParity), app[sid + SERIAL_PORT_PARITY].ToString()),
                                                              (SerialPortStopBits)Enum.Parse(typeof(SerialPortStopBits), app[sid + SERIAL_PORT_STOP_BITS].ToString()),
                                                              int.Parse(app[sid + SERIAL_PORT_DATA_BITS].ToString()),
                                                              (SerialPortHandshake)Enum.Parse(typeof(SerialPortHandshake), app[sid + SERIAL_PORT_FLOW_CONTROL].ToString()));
                }

                //Send ClientPrintJob back to the client
                System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
                System.Web.HttpContext.Current.Response.BinaryWrite(cpj.GetContent());
                System.Web.HttpContext.Current.Response.End();
            }
        }
Ejemplo n.º 4
0
 protected void Page_Init(object sender, System.EventArgs e)
 {
     if (WebClientPrint.ProcessPrintJob(this.Request))
     {
         ClientPrintJob cpj = new ClientPrintJob();
         cpj.ClientPrinter   = new UserSelectedPrinter();
         cpj.PrinterCommands = (string)Application[this.Request.QueryString["sid"] + CommonConstants.PrintCommand];
         cpj.SendToClient(Response);
     }
     Response.Cache.SetCacheability(HttpCacheability.NoCache);
     Response.Cache.SetExpires(DateTime.Now); //or a date much earlier than current time
 }
Ejemplo n.º 5
0
        public void PrintCommands(string sid)
        {
            if (WebClientPrint.ProcessPrintJob(System.Web.HttpContext.Current.Request))
            {
                HttpApplicationStateBase app = HttpContext.Application;
                //Create a ClientPrintJob obj that will be processed at the client side by the WCPP
                ClientPrintJob cpj = new ClientPrintJob();
                //get printer commands for this user id
                object printerCommands = app[sid + PRINTER_COMMANDS];
                if (printerCommands != null)
                {
                    cpj.PrinterCommands = printerCommands.ToString();
                    cpj.FormatHexValues = true;
                }
                cpj.ClientPrinter = new UserSelectedPrinter();
                //Send ClientPrintJob back to the client
                cpj.SendToClient(System.Web.HttpContext.Current.Response);
            }

        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Neodynamic.SDK.Web.WebClientPrint.CreateScript();


            //Is a Print Request?
            if (WebClientPrint.ProcessPrintJob(Request))
            {
                bool   useDefaultPrinter = (Request["useDefaultPrinter"] == "checked");
                string printerName       = Server.UrlDecode(Request["printerName"]);


                /*
                 * Response.Redirect("PrinterReciept.aspx?PolicyNr=" + model.MemeberNumber.ToString() +
                 * "&DatePaid=" + model.PaymentDate.ToString("YYYY-MMM-dd") +
                 * "&AmountPaid=" + model.Amount.ToString() +
                 * "&LateAmountPaid=" + model.LatePaymentPenalty.ToString() +
                 * "&PolicyHolder=" + model.FullNames +
                 * "&ReceivedBy=" + model.ReceivedBy +
                 * "&TimePrinted=" + DateTime.Now.ToString("YYYY-MMM-dd hh:mm") +
                 * "&Method=" + model.MethodOfPayment +
                 * "&Notes=" + model.Notes +
                 * "&Plan=" + model.PlanName);
                 *
                 *
                 *  Dim zlabel As New Com.SharpZebra.Example.BorderedLabel("   Branch Name...... " & vbTab & vbTab & ConfigurationManager.AppSettings("branch"), _
                 *                                 "   Receipt Nr....... " & vbTab & vbTab & intReceipt, _
                 * "   Policy Nr........ " & vbTab & vbTab & txtMemberNo.Text.ToUpper, _
                 * "   Date Paid........ " & vbTab & vbTab & dtDatepaid.ToString("dd-MMM-yyyy"), _
                 * "   Amount Paid...... " & vbTab & vbTab & FormatCurrency(txtAmount.Text, 2), _
                 * "   Policy Holder.... " & vbTab & vbTab & BL.pFullNames & "  " & BL.pSurname, _
                 * "   Received By...... " & vbTab & vbTab & txtRecievedBy.Text, _
                 * "   Time Printed..... " & vbTab & vbTab & DateTime.Now.ToString("dd-MMM-yyyy hh:mm"), _
                 * "   Method........... " & vbTab & vbTab & strMethod, _
                 * notes, _
                 * "   Underwriter...... " & vbTab & vbTab & BL.pAddress4, "123", strAppName, dtAdditionalAppSettings.Rows(0).Item("slogan"))
                 *
                 *
                 */


                //Create ESC/POS commands for sample receipt
                string ESC     = "0x1B";    //ESC byte in hex notation
                string NewLine = "0x0A";    //LF byte in hex notation

                string cmds = ESC + "@";    //Initializes the printer (ESC @)
                cmds += ESC + "!" + "0x38"; //Emphasized + Double-height + Double-width mode selected (ESC ! (8 + 16 + 32)) 56 dec => 38 hex
                cmds += "UnpluggIT";        //text to print
                cmds += NewLine + NewLine;
                cmds += ESC + "!" + "0x00"; //Character font A selected (ESC ! 0)
                cmds += "Policy Nr........  ";
                cmds += NewLine;
                cmds += "Date Paid........  ";
                cmds += NewLine + NewLine;
                cmds += "Amount Paid......  ";
                cmds += NewLine;
                cmds += "Policy Holder....  ";
                cmds += NewLine;
                cmds += "Time Printed.....  " + System.DateTime.Now.ToString("dd-MMM-yyyy");
                cmds += NewLine;
                cmds += "Method...........  ";
                cmds += NewLine;
                cmds += "Product Name.....  ";
                cmds += NewLine;
                cmds += System.DateTime.Now.ToString("dd-MMM-yyyy");

                cmds += "0x1D 0x56 <m>";

                //Create a ClientPrintJob and send it back to the client!
                ClientPrintJob cpj = new ClientPrintJob();
                //set ESC/POS commands to print...
                cpj.PrinterCommands = cmds;
                cpj.FormatHexValues = true;

                //set client printer...
                if (useDefaultPrinter || printerName == "null")
                {
                    cpj.ClientPrinter = new DefaultPrinter();
                }
                else
                {
                    cpj.ClientPrinter = new InstalledPrinter(printerName);
                }
                //send it...
                cpj.SendToClient(Response);
            }
        }