asp各种关于打印的代码
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Graphics g = Graphics.FromImage(temp);
Font f = new Font("宋体", 12);
Brush b = new SolidBrush(Color.Black);
protected System.Web.UI.WebControls.DataGrid MyDataGrid;
protected System.Web.UI.WebControls.Button btnSubmit;
protected System.Web.UI.HtmlControls.HtmlForm Form1;
g.DrawString(baseExpense, f, b, 219, 202);
g.DrawString(fine, f, b, 372, 202);
g.DrawString(upExpense, f, b, 486, 202);
string GetdSquery;
string id;
private void Page_Load(object sender, System.EventArgs e)
{
{
string date = lblDate.Text; //当前日期
string flowId = lblFlowId.Text; //流水号
string payDate = PayDate.Year.ToString() + "年" + PayDate.Month.ToString() + "月"; //应收年月
shineseExpense,
string payDate,
string adminName)
{
//读取图片模板
using System;
using System.Collections;
using ponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
string flowId,
string currentDate,
string baseExpense,
string fine,
string upExpense,
//填充数据到图片模板(位置要在制作图片模板的时候度量好)
g.DrawImage(temp, 0, 0, temp.Width, temp.Height);
g.DrawString(userId, f, b, 168, 105);
Rectangle destRect = new Rectangle(x, y, width, height);
e.Graphics.DrawImage(temp, destRect, 0, 0, temp.Width, temp.Height, System.Drawing.GraphicsUnit.Pixel);
id=Request.Params["id"].ToString();
string search=Request.Params["search"].ToString();
try
{
pd.Print();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "打印出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
g.DrawString(UserName, f, b, 166, 134);
g.DrawString(flowId, f, b, 535, 105);
g.DrawString(currentDate, f, b, 535, 134);
//打印事件设置
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
//ppd.Document = pd;
//ppd.ShowDialog();
string upExpense = lblUpExpense.Text; //上月上余
string actualExpense = txtActualExpense.Text; //实际应交费用
string chineseExpense = DecimalToChinese.ConvertSum(actualExpense); //实际应交费用的中文大写
string adminId = lblAdminId.Text; //操作员编号
string baseExpense = lblBaseExpense.Text; //应交基本费用
string fine = lblFine.Text; //罚款数目
int x = e.MarginBounds.X;
int y = e.MarginBounds.Y;
int width = temp.Width;
int height = temp.Height;
//读取图片模板
Image temp = Image.FromFile(@"Receipts.jpg");
GetResultIntoImage(ref temp, UserId, flowId, date, baseExpense, fine, upExpense, actualExpense, chineseExpense, payDate, adminId);
#region 打印
private void btnPrint_Click(object sender, EventArgs e)
{
//打印预览
//PrintPreviewDialog ppd = new PrintPreviewDialog();
C#打印源码也是打印控件的功能之一,这里介绍的C#打印源码可以实现自动打印处理,不过需要mdi文件的支持。
打印的原理是:生成mdi文件,系统碰到mdi的时候会自动以打印的方式处理。所以,不管用什么模板,什么方式;能在PrintPage事件处理中,生成一张要打印内容的图片就OK了!
C#打印源码如下:
g.DrawString(adminName, f, b, 497, 298);
g.Dispose();
}
#endregion
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CommData.data;
using Word;
using System.IO;
namespace CommData
////纸张设置默认
//PaperSize pageSize = new PaperSize("First custom size", 800, 600);
//pd.DefaultPageSettings.PaperSize = pageSize;
}
///
/// 将收费结果填充到图片模板
///
private void GetResultIntoImage(
ref Image temp,
string userId,
PrintDocument pd = new PrintDocument();
//设置边距
Margins margin = new Margins(20, 20, 20, 20);
pd.DefaultPageSettings.Margins = margin;
pd.PrintController.OnEndPrint(pd, new PrintEventArgs());
}
}
//打印事件处理
private void pd_PrintPage(object sender, PrintPageEventArgs e)
g.DrawString(actualExpense, f, b, 596, 202);
g.DrawString(chineseExpense, f, b, 196, 238);
g.DrawString(payDate, f, b, 176, 269);
{
/// <summary>
/// Result 的摘要说明。
/// </summary>
public class Result : System.Web.UI.Page
{
protected bel lblSearch;
Font f = new Font("宋体", 12);
Brush b = new SolidBrush(Color.Black);
protected System.Web.UI.WebControls.DataGrid MyDataGrid;
protected System.Web.UI.WebControls.Button btnSubmit;
protected System.Web.UI.HtmlControls.HtmlForm Form1;
g.DrawString(baseExpense, f, b, 219, 202);
g.DrawString(fine, f, b, 372, 202);
g.DrawString(upExpense, f, b, 486, 202);
string GetdSquery;
string id;
private void Page_Load(object sender, System.EventArgs e)
{
{
string date = lblDate.Text; //当前日期
string flowId = lblFlowId.Text; //流水号
string payDate = PayDate.Year.ToString() + "年" + PayDate.Month.ToString() + "月"; //应收年月
shineseExpense,
string payDate,
string adminName)
{
//读取图片模板
using System;
using System.Collections;
using ponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
string flowId,
string currentDate,
string baseExpense,
string fine,
string upExpense,
//填充数据到图片模板(位置要在制作图片模板的时候度量好)
g.DrawImage(temp, 0, 0, temp.Width, temp.Height);
g.DrawString(userId, f, b, 168, 105);
Rectangle destRect = new Rectangle(x, y, width, height);
e.Graphics.DrawImage(temp, destRect, 0, 0, temp.Width, temp.Height, System.Drawing.GraphicsUnit.Pixel);
id=Request.Params["id"].ToString();
string search=Request.Params["search"].ToString();
try
{
pd.Print();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "打印出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
g.DrawString(UserName, f, b, 166, 134);
g.DrawString(flowId, f, b, 535, 105);
g.DrawString(currentDate, f, b, 535, 134);
//打印事件设置
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
//ppd.Document = pd;
//ppd.ShowDialog();
string upExpense = lblUpExpense.Text; //上月上余
string actualExpense = txtActualExpense.Text; //实际应交费用
string chineseExpense = DecimalToChinese.ConvertSum(actualExpense); //实际应交费用的中文大写
string adminId = lblAdminId.Text; //操作员编号
string baseExpense = lblBaseExpense.Text; //应交基本费用
string fine = lblFine.Text; //罚款数目
int x = e.MarginBounds.X;
int y = e.MarginBounds.Y;
int width = temp.Width;
int height = temp.Height;
//读取图片模板
Image temp = Image.FromFile(@"Receipts.jpg");
GetResultIntoImage(ref temp, UserId, flowId, date, baseExpense, fine, upExpense, actualExpense, chineseExpense, payDate, adminId);
#region 打印
private void btnPrint_Click(object sender, EventArgs e)
{
//打印预览
//PrintPreviewDialog ppd = new PrintPreviewDialog();
C#打印源码也是打印控件的功能之一,这里介绍的C#打印源码可以实现自动打印处理,不过需要mdi文件的支持。
打印的原理是:生成mdi文件,系统碰到mdi的时候会自动以打印的方式处理。所以,不管用什么模板,什么方式;能在PrintPage事件处理中,生成一张要打印内容的图片就OK了!
C#打印源码如下:
g.DrawString(adminName, f, b, 497, 298);
g.Dispose();
}
#endregion
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using CommData.data;
using Word;
using System.IO;
namespace CommData
////纸张设置默认
//PaperSize pageSize = new PaperSize("First custom size", 800, 600);
//pd.DefaultPageSettings.PaperSize = pageSize;
}
///
/// 将收费结果填充到图片模板
///
private void GetResultIntoImage(
ref Image temp,
string userId,
PrintDocument pd = new PrintDocument();
//设置边距
Margins margin = new Margins(20, 20, 20, 20);
pd.DefaultPageSettings.Margins = margin;
pd.PrintController.OnEndPrint(pd, new PrintEventArgs());
}
}
//打印事件处理
private void pd_PrintPage(object sender, PrintPageEventArgs e)
g.DrawString(actualExpense, f, b, 596, 202);
g.DrawString(chineseExpense, f, b, 196, 238);
g.DrawString(payDate, f, b, 176, 269);
{
/// <summary>
/// Result 的摘要说明。
/// </summary>
public class Result : System.Web.UI.Page
{
protected bel lblSearch;