c#打印问题? StreamReader好象可以,但是无法指定某个字的大小? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 主要问题是 我所要打印的内容是怎么传过去.想象一下,你不用word 打印功能,你怎么把你的 word里面的内容(包括字体大小)发到打印机,打印出来. <script language='javascript'>print();</script> 我只是举例有一个word文档.实际上根本没有word文档.刚才研究了以下printdocument可以实现.不过也是复杂. 只有用printdocument可以实现。以下是设置字体、XY位置和打印的变量。e.Graphics.DrawString(strchar1[1],new Font("仿宋体",11),Brushes.Black,0.2f,8.2f);用pageSetupDialog实现页面的设置。 一点都不复杂! 用printdocument可以实现e.Graphics.DrawString(strchar1[1],new Font("仿宋体",11),Brushes.Black,0.2f,8.2f); 给你个报表工具看看 可不可以。。WWW.eastReport.net 参考:ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.2052/cpref/html/frlrfSystemDrawingPrintingPrintDocumentClassTopic.htmprivate void printButton_Click(object sender, EventArgs e) { try { streamToPrint = new StreamReader ("C:\\My Documents\\MyFile.txt"); try { printFont = new Font("Arial", 10); PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler (this.pd_PrintPage); pd.Print(); } finally { streamToPrint.Close(); } } catch(Exception ex) { MessageBox.Show(ex.Message); } } // The PrintPage event is raised for each page to be printed. private void pd_PrintPage(object sender, PrintPageEventArgs ev) { float linesPerPage = 0; float yPos = 0; int count = 0; float leftMargin = ev.MarginBounds.Left; float topMargin = ev.MarginBounds.Top; string line = null; // Calculate the number of lines per page. linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics); // Print each line of the file. while(count < linesPerPage && ((line=streamToPrint.ReadLine()) != null)) { yPos = topMargin + (count * printFont.GetHeight(ev.Graphics)); ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, new StringFormat()); count++; } // If more lines exist, print another page. if(line != null) ev.HasMorePages = true; else ev.HasMorePages = false; } 执行完成SQL语句后如何提示SQL消息 求TNL网络库的COM封装 关于值类型和引用类型的思考? 左右分栏,我无奈了 大家帮帮我,为什么会出现这种错? c# 刷新窗口,在线等! 急!用C#绘制曲线的问题,高手请帮帮忙! 浏览器internet选项设置问题……(高分赠送!高手请进!!) 关于menuItem的OwnDraw问题! c#同时连接两个串口出现问题,请大神帮忙!感谢 高手们 给点推荐吧! 谢谢 提问关于MD5
print();
</script>
刚才研究了以下printdocument可以实现.不过也是复杂.
e.Graphics.DrawString(strchar1[1],new Font("仿宋体",11),Brushes.Black,0.2f,8.2f);
用pageSetupDialog实现页面的设置。
一点都不复杂!
e.Graphics.DrawString(strchar1[1],new Font("仿宋体",11),Brushes.Black,0.2f,8.2f);
private void printButton_Click(object sender, EventArgs e)
{
try
{
streamToPrint = new StreamReader
("C:\\My Documents\\MyFile.txt");
try
{
printFont = new Font("Arial", 10);
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler
(this.pd_PrintPage);
pd.Print();
}
finally
{
streamToPrint.Close();
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
} // The PrintPage event is raised for each page to be printed.
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
string line = null; // Calculate the number of lines per page.
linesPerPage = ev.MarginBounds.Height /
printFont.GetHeight(ev.Graphics); // Print each line of the file.
while(count < linesPerPage &&
((line=streamToPrint.ReadLine()) != null))
{
yPos = topMargin + (count *
printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString(line, printFont, Brushes.Black,
leftMargin, yPos, new StringFormat());
count++;
} // If more lines exist, print another page.
if(line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
}