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; } c#中DataGridView中如何选定指定的列绑定数据 关于ComBox的问题 C#数据类型和C语言有什么不同? 连接SQL2000的问题 c#如何检测音频视频设备是否正常? 紧急求助 孟子E章快来救命啊~冰天雪地跪求+散分~ 关于[Index was outside the bounds of the array.]的问题 求一个利用地图算里程的功能,不用webBrowser1 C#如何实现word页眉下移 高手们 给点推荐吧! 谢谢 提问关于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;
}