Wpf(c#)POS打印机的打印代码 [英] Wpf (c#) Printing Code for POS Printer
本文介绍了Wpf(c#)POS打印机的打印代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我开发了零售管理系统项目。我使用过POS打印机和
我不知道使用POS打印机使用WPF(C#)技术打印账单的代码。
请告诉我它是怎么回事完成。
I have developed a project on retail management system. I have used POS Printer and
I don''t know a code use for print bill using POS Printer using WPF (C#) Technology.
Please give me idea how it done.
// Print Event
private void miPrint_Click(object sender, System.EventArgs e)
{
if (printDialog1.ShowDialog() == DialogResult.OK)
{
// printDocument1.DefaultPageSettings.PaperSize.Width = 9000;
printDocument1.Print();
}
}
// OnBeginPrint
private void OnBeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
char[] param = {'\n'};
PrinterSettings p = new PrinterSettings();
PaperSize ps = new PaperSize ("Custom",9000,90000);
printDocument1.DefaultPageSettings.PaperSize = ps;
if (printDialog1.PrinterSettings.PrintRange == PrintRange.Selection)
{
lines = richTextBox1.SelectedText.Split(param);
}
else
{
lines = richTextBox1.Text.Split(param);
}
int i = 0;
char[] trimParam = {'\r'};
foreach (string s in lines)
{
lines[i++] = s.TrimEnd(trimParam);
}
}
// OnPrintPage
private void OnPrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
int x = e.MarginBounds.Left;
int y = e.MarginBounds.Top;
Brush brush = new SolidBrush(richTextBox1.ForeColor);
while (linesPrinted < lines.Length)
{
e.Graphics.DrawString (lines[linesPrinted++],
richTextBox1.Font, brush, x, y);
y += 15;
if (y >= e.MarginBounds.Bottom)
{
e.HasMorePages = true;
return;
}
}
linesPrinted = 0;
e.HasMorePages = false;
}
// Page Setup
private void miSetup_Click(object sender, System.EventArgs e)
{
// Call Dialog Box
pageSetupDialog1.ShowDialog();
}
// Print Preview
private void miPreview_Click(object sender, System.EventArgs e)
{
// Call Dialog Box
printPreviewDialog1.ShowDialog();
}
提前致谢.....
Thanks in advance.....
推荐答案
请看一下:
http: //bytes.com/topic/visual-basic-net/answers/636335-pos-printer-net [ ^ ]
这篇关于Wpf(c#)POS打印机的打印代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文