Пример #1
0
        public void PrintDocument(ArrayList Lineas)
        {
            try
            {
                IntPtr pBytes;
                Int32  dwCount;

                Lineas = AddEjects(Lineas);

                for (int i = 0; i < _copias; i++)
                {
                    // How many characters are in the string?
                    foreach (string line in Lineas)
                    {
                        string lineToPrint = line + "\r\n";

                        dwCount = lineToPrint.Length;
                        // Assume that the printer is expecting ANSI text, and then convert
                        // the string to ANSI text.
                        pBytes = Marshal.StringToCoTaskMemAnsi(lineToPrint);
                        // Send the converted ANSI string to the printer.

                        SendBytesToPrinter(this.PrinterName, pBytes, dwCount);
                        Marshal.FreeCoTaskMem(pBytes);
                    }            //foreach
                }                //for
                PrintDirect.EndPagePrinter(lhPrinter);
                PrintDirect.EndDocPrinter(lhPrinter);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }        //PrintDocument
Пример #2
0
        public void Print(ArrayList lineas)
        {
            PrintDirect impre = new PrintDirect(_impresora);

            impre.Copias           = _copias;
            impre.TipoImpresora    = _tipoImpresora;
            impre.RenglonesPorHoja = _renglonesPorHoja;
            impre.PrintDocument(lineas);
        }
Пример #3
0
 protected virtual void Dispose(bool disposing)
 {
     try
     {
         // Check to see if Dispose has already been called.
         if (!this.disposed)
         {
             // If disposing equals true, dispose all managed
             // and unmanaged resources.
             if (disposing)
             {
                 PrintDirect.ClosePrinter(lhPrinter);
             }
         }
     }
     catch (Exception ex)
     {            //do nothing
         ex.ToString();
     }
     disposed = true;
 }
Пример #4
0
        public PrintDirect(string PrinterName)
        {
            if (PrinterName != null && PrinterName != "")
            {
                this.PrinterName = PrinterName;
            }

            lhPrinter = new System.IntPtr();
            di        = new DOCINFOA();

            di.pDocName  = "MINI-MI Document";
            di.pDataType = "RAW";

            PrintDirect.OpenPrinter(this.PrinterName, out lhPrinter, 0);
            if (lhPrinter == System.IntPtr.Zero)
            {
                throw new Exception("Error en la impresora " + this.PrinterName);                 //not open/found
            }
            PrintDirect.StartDocPrinter(lhPrinter, 1, di);
            PrintDirect.StartPagePrinter(lhPrinter);
        }        //constructor