请问打印页的尺寸如何改变? 不知你的代码在哪个事件中,应在printDocument1_PrintPage中设置即可 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 MSDN中关于DefaultPageSettings属性有说明: 打印开始后,通过 DefaultPageSettings 属性更改页设置对正在打印的页没有任何影响。所以我在其它地方设置,无论在什么地方设置均无效,代码如下:private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e){e.Graphics.PageUnit=GraphicsUnit.Millimeter;//设置打印的度量单位为毫米(mm)//从结构中找到邮编的x,y,并将缇值转化为毫米int x=iMyPrintRef[0].Xofzip*10/567;int y=iMyPrintRef[0].Yofzip*10/567;//支持彩色//Brush brush=new SolidBrush(this.textBoxEdit.ForeColor); //使用固定字体,颜色e.Graphics.DrawString(lines[linesPrinted++],new Font("宋体",12),Brushes.Black,x,y); if(linesPrinted<lines.Length)//ver 2.00 检查是否超过页的边界,72行一页{e.HasMorePages=true;//告诉控制器再次调用OnPrintPage()return;}linesPrinted=0;e.HasMorePages=false;//让PrintLoop()停止} //多页private string[]lines;private int linesPrinted;private int cNum;//当前打印信封对应的结构索引private void MiFilePrint_Click(object sender, System.EventArgs e){//ver 4.0//ver 4.00,打印信封//PageSize类的构造函数以1/100英寸为单位//1440缇=1英寸//567缇=1厘米=`00毫米//原来存储以缇为单位int dHeight=6720*100/1440;int dWidth=13096*100/1440;PaperSize currSize = new PaperSize("Custom size", dWidth, dHeight); printDocument.DefaultPageSettings.PaperSize =currSize;//设置字张大小 this.printDocument.Print();//激发PrintPage()事件}private void printDocument_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e){lines=new string[2];lines[0]="100100";lines[1]="200200";for(int i=0;i<iMyPrintRef.Length;i++){ if(iMyPrintRef[i].Id==9) { cNum=i; break; }}} 有谁做过数字图像的呢, 如何识别出来? 关于WebService使用代理的Proxy Timeout超时问题。 datalist中table去边框线样式问题 WinFrom 将上传的图片保存到数据库,图片压缩变小? 请问如何利用反射在c#中动态访问成员 C#中怎么浏览下一条数据 关于CreateGraphics,请教~~ XDJM帮忙看看调试器的问题! c#中的数据格式转化 datagridview显示问题 C#程序员能挣多少money?和java 比较呢?欢迎大家讨论!! 请问,我想学习C#,从微软下载了那个FrameWork SDK,可是安装后怎么没有可执行文件?
打印开始后,通过 DefaultPageSettings 属性更改页设置对正在打印的页没有任何影响。
所以我在其它地方设置,无论在什么地方设置均无效,代码如下:
private void printDocument_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.PageUnit=GraphicsUnit.Millimeter;//设置打印的度量单位为毫米(mm)
//从结构中找到邮编的x,y,并将缇值转化为毫米
int x=iMyPrintRef[0].Xofzip*10/567;
int y=iMyPrintRef[0].Yofzip*10/567;
//支持彩色
//Brush brush=new SolidBrush(this.textBoxEdit.ForeColor);
//使用固定字体,颜色
e.Graphics.DrawString(lines[linesPrinted++],new Font("宋体",12),Brushes.Black,x,y);
if(linesPrinted<lines.Length)//ver 2.00 检查是否超过页的边界,72行一页{
e.HasMorePages=true;//告诉控制器再次调用OnPrintPage()
return;
}
linesPrinted=0;
e.HasMorePages=false;//让PrintLoop()停止
}
//多页
private string[]lines;
private int linesPrinted;
private int cNum;//当前打印信封对应的结构索引
private void MiFilePrint_Click(object sender, System.EventArgs e)
{
//ver 4.0
//ver 4.00,打印信封
//PageSize类的构造函数以1/100英寸为单位
//1440缇=1英寸
//567缇=1厘米=`00毫米
//原来存储以缇为单位
int dHeight=6720*100/1440;
int dWidth=13096*100/1440;
PaperSize currSize = new PaperSize("Custom size", dWidth, dHeight);
printDocument.DefaultPageSettings.PaperSize =currSize;//设置字张大小
this.printDocument.Print();//激发PrintPage()事件
}private void printDocument_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
lines=new string[2];
lines[0]="100100";
lines[1]="200200";
for(int i=0;i<iMyPrintRef.Length;i++)
{
if(iMyPrintRef[i].Id==9)
{
cNum=i;
break;
}
}
}