private void PrencherArquivo(DataTable dt, NotaFiscal item, ClienteAG cliente)
{
StringBuilder sb = new StringBuilder();
sb.Append(((char)27).ToString()).Append("C").AppendLine(((char)18).ToString());
sb.AppendLine("");
sb.AppendLine("");
sb.AppendLine("");
sb.AppendLine("");
for (int i = 1; i <= item.volqte; i++)
{
sb.AppendLine(cliente.nome);
sb.AppendLine("");
sb.AppendLine(cliente.logradouro + "-" + cliente.numeroendereco);
sb.AppendLine(cliente.bairro + "-" + cliente.mun_ufd_sigla);
sb.AppendLine("CEP:" + cliente.cep);
sb.AppendLine("");
sb.AppendLine("");
sb.AppendLine(item.numero + " " + item.volpeso.ToString("N1"));
sb.AppendLine("");
sb.AppendLine(" VOLUME " + i + " DE " + item.volqte);
if (item.volqte > i)
{
sb.AppendLine("");
sb.AppendLine("");
sb.AppendLine("");
sb.AppendLine("");
sb.AppendLine("");
sb.AppendLine("");
sb.AppendLine("");
sb.AppendLine("");
}
else
{
sb.AppendLine("");
sb.AppendLine("");
sb.AppendLine("");
}
}
sb.Append(((char)27).ToString()).AppendLine("@");
RawPrinterHelper.SendStringToPrinter("EPSON LX-300+ /II", sb.ToString());
}
public static bool SendStringToPrinter(string szPrinterName, string szString) { IntPtr pBytes; Int32 dwCount; // How many characters are in the string? dwCount = szString.Length; // Assume that the printer is expecting ANSI text, and then convert // the string to ANSI text. pBytes = Marshal.StringToCoTaskMemAnsi(szString); // Send the converted ANSI string to the printer. SendBytesToPrinter(szPrinterName, pBytes, dwCount); Marshal.FreeCoTaskMem(pBytes); return true; }
public static bool SendStringToPrinter(string szPrinterName, string szString)
{
IntPtr pBytes;
Int32 dwCount;
// How many characters are in the string?
dwCount = szString.Length;
// Assume that the printer is expecting ANSI text, and then convert
// the string to ANSI text.
pBytes = Marshal.StringToCoTaskMemAnsi(szString);
// Send the converted ANSI string to the printer.
SendBytesToPrinter(szPrinterName, pBytes, dwCount);
Marshal.FreeCoTaskMem(pBytes);
return true;
}