不好意思,我不是楼主,路过。但是想问jinbingg(bing),你可以说一下用C#自己写打印程序应该多注意哪些方面,
或者提一点点思路呀?
或者提一点点思路呀?
解决方案 »
- panel动态产生
- 动态创建BUTTON控件出错!
- 同样是session语句:session["name"]=textbox1.text;和label2.text=session["name"].tostring(); 不同
- 求一SQL语句
- VB.NET代码转成C#?
- 类型或命名空间名称“Padding”在类或命名空间“Infragistics.WebUI.Shared”中不存在
- 有谁能更改并完善这个投票程序
- 大侠给看一下下面的remoting小程序为什么不对
- 怎么在字符串中包含"\"?
- Win32API能在.NET下的语言中使用么?如果能,能给例子么?
- 在WinForm下怎样解决多个控件绑定同一数据源的问题(急)
- 再问telnet编码问题?
{
statusBar1.Text="打印操作";
PrintDialog printDialog=new PrintDialog(); printDialog.Document=printDocument; if(printDialog.ShowDialog()==DialogResult.OK)
{
try
{
printDocument.Print();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
{
statusBar1.Text="页面设置";
PageSetupDialog pageSet=new PageSetupDialog();
pageSet.Document=printDocument;
pageSet.AllowOrientation=true;
pageSet.ShowDialog();
} private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
float linesPerPage=0;
float yPos=0;
int count=0;
float leftMargin=e.MarginBounds.Left;
float topMargin=e.MarginBounds.Top;
string line=null;
StreamReader streamToPrint=new StreamReader(currentFileName);
SolidBrush brush=new SolidBrush(textBox1.ForeColor);
linesPerPage=e.MarginBounds.Height/textBox1.Font.GetHeight(e.Graphics); while(count<linesPerPage&&((line=streamToPrint.ReadLine())!=null))
{
yPos=topMargin+(count*textBox1.Font.GetHeight(e.Graphics));
e.Graphics.DrawString(line,textBox1.Font,brush,leftMargin,yPos,new StringFormat());
count++;
}
if(line!=null)
{
e.HasMorePages=true;
}
else
{
e.HasMorePages=false;
}
}