求教!用C#开发了一软件,使用热敏印机打印销售单!打印总是纵向打印!
求教!用C#开发了一软件,使用热敏印机打印销售单!打印总是纵向打印,代码设置为横向打印时也依然是纵向打印,但如用word打印,又是正常(即打印设置设为横向时打印出来就就横向,纵向就是纵向),而我开发的打印不管怎么设置都是纵向打印,根本无法横向打印,烦啊!请各位前辈指教!部分代码如下:
private void FormPrint_Load(object sender, EventArgs e)
{
high = dt.Rows.Count * 10 + high;
this.printPreviewControl1.Document = this.printDocument1;
//this.printDocument1.DefaultPageSettings.Landscape = true;
this.printPreviewControl1.Document.DefaultPageSettings.Landscape = false;
//this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Default", 160, high); //自定义默认纸张大小
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString("金利来销售收据", new Font("宋体", 8), Brushes.Black, 35, 10);
//e.Graphics.DrawString("顾客姓名:" + salesID + "", new Font("宋体", 6), Brushes.Black, 20, 35);
e.Graphics.DrawString("日期:" + DateTime.Now.Date.ToString("yyyy年MM月dd日") + "", new Font("宋体", 6), Brushes.Black, 0, 35);
e.Graphics.DrawString("编号:"+ salesID +"", new Font("宋体", 6), Brushes.Black, 90, 35);
e.Graphics.DrawLine(new Pen(Color.Black), 0, 50, 155, 50);
e.Graphics.DrawString("商品名", new Font("宋体", 6), Brushes.Black, 0, 55);
e.Graphics.DrawString("颜色", new Font("宋体", 6), Brushes.Black, 35, 55);
e.Graphics.DrawString("尺码", new Font("宋体", 6), Brushes.Black, 63, 55);
e.Graphics.DrawString("数量", new Font("宋体", 6), Brushes.Black, 90, 55);
e.Graphics.DrawString("销售金额", new Font("宋体", 6), Brushes.Black, 120, 55);
decimal heji = 0;
int y = 70;
foreach (DataRow dr in dt.Rows)
{
e.Graphics.DrawString("" + dr[4].ToString().Trim() + "", new Font("宋体", 6), Brushes.Black, 0, y);
e.Graphics.DrawString("" + dr[5].ToString().Trim() + "", new Font("宋体", 6), Brushes.Black, 35, y);
e.Graphics.DrawString("" + dr[6].ToString().Trim() + "", new Font("宋体", 6), Brushes.Black, 67, y);
e.Graphics.DrawString("" + dr[8].ToString().Trim() + "", new Font("宋体", 6), Brushes.Black, 95, y);
e.Graphics.DrawString("" + dr[11].ToString().Trim() + "", new Font("宋体", 6), Brushes.Black, 122, y);
y += 15;
heji += Convert.ToDecimal(dr[11].ToString().Trim());
}
e.Graphics.DrawLine(new Pen(Color.Black), 0, y, 155, y);
e.Graphics.DrawString("销售员:"+FormLogin.userName +"", new Font("宋体", 6), Brushes.Black, 0, y+5);
e.Graphics.DrawString("合计:", new Font("宋体", 6), Brushes.Black, 90, y+5);
e.Graphics.DrawString("" + heji.ToString().Trim() + "", new Font("宋体", 6), Brushes.Black, 122, y+5);
}
private void 保存button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("保存成功!是否要打印?", "提示", MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes)
{
printDocument1.DefaultPageSettings.Landscape = true;
this.printDocument1.Print();
clearDG = true;
this.Dispose();
this.Close();
}
else
{
clearDG = true;
this.Close();
this.Dispose();
}
} --------------------编程问答-------------------- 晕,无人帮解答 --------------------编程问答-------------------- 周二我去调试一下,打印机啥 型号啊,我觉得你还是没撑握机器的参数。 --------------------编程问答-------------------- 图形Graphic.Draw
晕。
你不知道有 ESC/POS 之类的指令集吗?!你的POS没有高效的字符集打印指令码? --------------------编程问答-------------------- 如果这个卖你设备的公司的技术人员是那个,我劝你早早退货。不是因为机器问题,而是中间商倒爷的技术问题。 --------------------编程问答-------------------- 你好,请问你这种打印方法没有乱码的问题吗? --------------------编程问答-------------------- //this.printDocument1.DefaultPageSettings.Landscape = true;
this.printPreviewControl1.Document.DefaultPageSettings.Landscape = false;
這個弄縱向,橫向有什麼意義?是不是你的打印機的默認設置成縱向打印了?
补充:.NET技术 , C#