C#如何打印图片和信息?求指教。 用printer控件,GDI+画上想要打印的内容 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 参考 private void button2_Click(object sender, EventArgs e) { PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(this.printDocument1_PrintPage); StandardPrintController spc = new StandardPrintController(); pd.PrintController = spc; pd.PrinterSettings.PrinterName = "发送至 OneNote 2010"; pd.Print(); } private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.PageUnit = GraphicsUnit.Document; e.Graphics.DrawString(this.textBox1.Text, new Font("Arial", 11), new SolidBrush(Color.Black), 100.0F, 5.0F); e.Graphics.DrawImage(DrawImg39(new EnCodeString().code39(this.textBox1.Text)), 10.0F, 70.0F); e.Graphics.DrawString("test", new Font("Arial", 11), new SolidBrush(Color.Black), 70F, 180.0F); e.Graphics.DrawString("test", new Font("Arial", 11), new SolidBrush(Color.Black), 180F, 220.0F); PaperSize cps = new PaperSize("Customer", 30, 30); e.PageSettings.PaperSize = cps; e.PageSettings.PaperSize.PaperName = "4xe Enhanced"; e.HasMorePages = false; } pd.PrinterSettings.PrinterName = "发送至 OneNote 2010"; 这里不是写的打印机么?如果不写这句就是用默认打印机,如果要选打印机,那你自己加一个PrintDialog WebBrowser组件execWB方法进行打印示例//打印页面设置<form id="form1" runat="server"> <div> <table> <tr> <td style="width: 466px; text-align: center;"> <asp:Label ID="Label1" runat="server" Font-Size="12pt" Font-Bold="True" ></asp:Label> </td></tr> <tr><td style="font-size: 9pt; width: 466px; text-indent: 8pt; text-align: left; height: 380px;"> <asp:Label ID="Label2" runat="server" Font-Size="9pt" Height="412px" Width="430px" BorderWidth="1px" ForeColor="#404040"></asp:Label> </td> </tr> <tr> <td style="text-align: center; width: 466px; height: 46px;"> <object id="WebBrowser" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"> </object> <asp:Panel ID="panel1" runat="server" Width="460px" Height="12px"> <input onclick="document.all.WebBrowser.ExecWB(6,1);" type="button" value="打印" id="Button1" > <input onclick="document.all.WebBrowser.ExecWB(6,6);" type="button" value="直接打印" id="Button2"> <input onclick="document.all.WebBrowser.ExecWB(8,1);" type="button" value="页面设置" id="Button3"> <input onclick="document.all.WebBrowser.ExecWB(7,1);" type="button" value="打印预览" id="Button4" > <input type="button" value="关闭窗口" onclick="javascript:window.close()" id="Button5"> </asp:Panel></td> </tr> </table> </div></form>//处理打印设置public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string path = Server.MapPath("App_Data\\jytk.txt"); System.IO.StreamReader reader = new System.IO.StreamReader(path, System.Text.Encoding.Default); this.Label1.Text = reader.ReadLine(); this.Label2.Text = reader.ReadToEnd(); reader.Close(); }} reporting service来做,排版容易 WPF编程中设置Combobox为允许输入文本 100分求助,如何创造个method并return back规定的变量?(实题,已附上完整代码) 我要学代码 如何编写onfocus事件? 用GDI+如何设计一款荧光笔 如何从ArrayList中读出数组 残影问题,请各位高手指点 后台传递DataTable到页面,怎么操作呢? 请问使用C#如何设置一个全局环境变量? 巨龙的7张盘怎么不好用啊..中文企业版的 c# 在调用java的webservice是对象实例化报错,请高手帮忙 将Object类型的变量转换成反射获取的类型
private void button2_Click(object sender, EventArgs e)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(this.printDocument1_PrintPage);
StandardPrintController spc = new StandardPrintController();
pd.PrintController = spc;
pd.PrinterSettings.PrinterName = "发送至 OneNote 2010";
pd.Print();
} private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.PageUnit = GraphicsUnit.Document;
e.Graphics.DrawString(this.textBox1.Text, new Font("Arial", 11), new SolidBrush(Color.Black), 100.0F, 5.0F);
e.Graphics.DrawImage(DrawImg39(new EnCodeString().code39(this.textBox1.Text)), 10.0F, 70.0F);
e.Graphics.DrawString("test", new Font("Arial", 11), new SolidBrush(Color.Black), 70F, 180.0F);
e.Graphics.DrawString("test", new Font("Arial", 11), new SolidBrush(Color.Black), 180F, 220.0F);
PaperSize cps = new PaperSize("Customer", 30, 30);
e.PageSettings.PaperSize = cps;
e.PageSettings.PaperSize.PaperName = "4xe Enhanced";
e.HasMorePages = false;
}
这里不是写的打印机么?
如果不写这句就是用默认打印机,如果要选打印机,那你自己加一个PrintDialog
//打印页面设置
<form id="form1" runat="server">
<div>
<table>
<tr>
<td style="width: 466px; text-align: center;">
<asp:Label ID="Label1" runat="server" Font-Size="12pt" Font-Bold="True" ></asp:Label>
</td></tr>
<tr><td style="font-size: 9pt; width: 466px; text-indent: 8pt; text-align: left; height: 380px;">
<asp:Label ID="Label2" runat="server" Font-Size="9pt" Height="412px"
Width="430px" BorderWidth="1px" ForeColor="#404040"></asp:Label>
</td>
</tr>
<tr>
<td style="text-align: center; width: 466px; height: 46px;">
<object id="WebBrowser" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<asp:Panel ID="panel1" runat="server" Width="460px" Height="12px">
<input onclick="document.all.WebBrowser.ExecWB(6,1);" type="button" value="打印" id="Button1" >
<input onclick="document.all.WebBrowser.ExecWB(6,6);" type="button" value="直接打印" id="Button2">
<input onclick="document.all.WebBrowser.ExecWB(8,1);" type="button" value="页面设置" id="Button3">
<input onclick="document.all.WebBrowser.ExecWB(7,1);" type="button" value="打印预览" id="Button4" >
<input type="button" value="关闭窗口" onclick="javascript:window.close()" id="Button5">
</asp:Panel></td>
</tr>
</table>
</div>
</form>
//处理打印设置
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string path = Server.MapPath("App_Data\\jytk.txt");
System.IO.StreamReader reader = new System.IO.StreamReader(path, System.Text.Encoding.Default);
this.Label1.Text = reader.ReadLine();
this.Label2.Text = reader.ReadToEnd();
reader.Close();
}
}