private void Printbutton_Click(object sender, EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.DefaultPageSettings.Margins.Top = 10;
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.Print(); //PrintPreviewDialog cppd = new PrintPreviewDialog();
//cppd.Document = pd;
//cppd.ShowDialog();
}
void pd_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics g = e.Graphics;
System.Drawing.Font font=new Font(this.Font,FontStyle.Regular);
barcode.Draw(g, barcode.ClientRectangle, GraphicsUnit.Inch, 0.01f, 0,null); g.Dispose();
}
{
PrintDocument pd = new PrintDocument();
pd.DefaultPageSettings.Margins.Top = 10;
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.Print(); //PrintPreviewDialog cppd = new PrintPreviewDialog();
//cppd.Document = pd;
//cppd.ShowDialog();
}
void pd_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics g = e.Graphics;
System.Drawing.Font font=new Font(this.Font,FontStyle.Regular);
barcode.Draw(g, barcode.ClientRectangle, GraphicsUnit.Inch, 0.01f, 0,null); g.Dispose();
}
解决方案 »
- 每隔一段时间,执行一次操作,大家给个思路
- datagridview更新的问题
- 用C#实现Windows智能手机和PC短信收件箱,发件箱的同步
- 有了Remoting ,是不是就可以把以前的使用TCP协议建立连接传送数据的程序,改装成Remoting 形式??
- windowsforms的问题啊
- Infragistics.UltraChart 控件问题!非常着急求救!!help me!!
- 如何在左键菜单中增加一个带图标的文件夹,就像winrar或者winzip一样
- listbox删除选中行问题
- 急,.net安装密钥,在线等待!!!!!!!!!!!!
- 求助,C#操作sql完整的方法怎样?附疑问一个
- 请问有人做过对doc和xls文件的全文检索吗?
- 分页显示数据
我只是用他生成条形码,打印是自己做的
{
Graphics myGraphics = this.CreateGraphics();
Size s = panel1.Size;
memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(this.Location.X+319, this.Location.Y+36, 0, 0, s);
//memoryImage.Save(@"d:\a.bmp");
} private void printDocument1_PrintPage(System.Object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
Point ulCorner = new Point(0,0);
Point urCorner = new Point(338,0);
Point llCorner = new Point(0, 365);
Point[] destPara = { ulCorner, urCorner, llCorner };
e.Graphics.DrawImage(memoryImage, destPara); //e.Graphics.DrawImage(memoryImage, 0, 0);
}private void vistaButton1_Click(object sender, EventArgs e)
{
printDocument1.Print();
}
Graphics g = e.Graphics;
Rectangle rect = barcodeControl2.ClientRectangle;
rect.X += 100;
rect.Y += 100;
barcodeControl2.Draw(g, rect, GraphicsUnit.Inch, 0.01f, 0, null);
g.Dispose();因为barcodeControl2.ClientRectangle的超始位置为Point(0,0);
所以,如果需要调整。你可以试着修改Rectangle的超始位置。