在C#winfrom中编写直接打印不经过设置和预览,怎么设置我想要的固定的打印边距和纸张大小
privatevoidprintDocument1_PrintPage(objectsender,System.Drawing.Printing.PrintPageEve...
private void printDocument1_PrintPage(objectsender,System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap _NewBitmap = new Bitmap(tabPage1.Width, tabPage1.Height);
tabPage1.DrawToBitmap(_NewBitmap, new Rectangle(0, 0, _NewBitmap.Width, _NewBitmap.Height));
e.Graphics.DrawImage(_NewBitmap, 0, 0, _NewBitmap.Width, _NewBitmap.Height);
}
private void button2_Click(object sender, EventArgs e)
{
if (this.printDialog1.ShowDialog() == DialogResult.OK)
{
printDocument1.PrintController = new StandardPrintController();
this.printDocument1.Print();
}
} 展开
{
Bitmap _NewBitmap = new Bitmap(tabPage1.Width, tabPage1.Height);
tabPage1.DrawToBitmap(_NewBitmap, new Rectangle(0, 0, _NewBitmap.Width, _NewBitmap.Height));
e.Graphics.DrawImage(_NewBitmap, 0, 0, _NewBitmap.Width, _NewBitmap.Height);
}
private void button2_Click(object sender, EventArgs e)
{
if (this.printDialog1.ShowDialog() == DialogResult.OK)
{
printDocument1.PrintController = new StandardPrintController();
this.printDocument1.Print();
}
} 展开
1个回答
展开全部
你是用bitmap类型传入的打印,属于图像打印。
那么你的边距要在bitmap内部去指定。
如果用的是FlowDocument类型去打印, 则会有TextAlignment属性可以设置边距
参考msdn
https://msdn.microsoft.com/zh-cn/library/system.windows.documents.flowdocument.aspx
那么你的边距要在bitmap内部去指定。
如果用的是FlowDocument类型去打印, 则会有TextAlignment属性可以设置边距
参考msdn
https://msdn.microsoft.com/zh-cn/library/system.windows.documents.flowdocument.aspx
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询