public static void ImprimirLista(ArrayList lista, string impresora) { System.IntPtr lhPrinter = new System.IntPtr(); DocumentInformation di = new DocumentInformation(); int pcWritten = 0; string linea; string lineFeed = "\r\n"; di.DocName = "CB"; di.DataType = "RAW"; NativeMethods.OpenPrinter(impresora, ref lhPrinter, 0); NativeMethods.StartDocPrinter(lhPrinter, 1, ref di); NativeMethods.StartPagePrinter(lhPrinter); try { System.Collections.IEnumerator myEnumerator; myEnumerator = lista.GetEnumerator(); while (myEnumerator.MoveNext()) { StringBuilder sbLinea = new StringBuilder(); sbLinea.Append(myEnumerator.Current.ToString()); sbLinea.Append(lineFeed); linea = sbLinea.ToString(); NativeMethods.WritePrinter(lhPrinter, linea, linea.Length, ref pcWritten); } } catch { throw new Exception(Errores.Desconocido); } NativeMethods.EndPagePrinter(lhPrinter); NativeMethods.EndDocPrinter(lhPrinter); NativeMethods.ClosePrinter(lhPrinter); }
public static extern long StartDocPrinter(IntPtr hPrinter, int level, ref DocumentInformation pDocInfo);