110,568
社区成员
发帖
与我相关
我的任务
分享
private void button4_Click(object sender, EventArgs e)
{
//纸张设置默认
PaperSize pageSize = new PaperSize("Custom Title size", (int)(75 * 100 / 25.4 + 1), (int)(50 * 100 / 25.4 + 1));//①纸张大小设定:以百分之一英寸为单位。
pd.DefaultPageSettings.PaperSize = pageSize;
//打印事件设置
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage3);
pd.Print();
}
private void pd_PrintPage3(object sender, PrintPageEventArgs e)
{
Bitmap Bmp = new Bitmap(590, 394);//②毫米换成像素:75*200/25.4=590,50*200/25.4=394
Bmp.SetResolution(200, 200);
Graphics g = Graphics.FromImage(Bmp);
Font Ft = new Font("宋体", 12, FontStyle.Regular);
Brush Bs = new SolidBrush(Color.Black);
g.DrawString("字符串测试", Ft, Bs, 29, 197);
Pen Pn = new Pen(Bs);
g.DrawLine(Pn, 2, 2, 588, 2);
g.DrawLine(Pn, 2, 2, 2, 392);
g.DrawLine(Pn, 2, 392, 588, 392);
g.DrawLine(Pn, 588, 2, 588, 392);
//e.Graphics.DrawImage(Bmp,0,0);
Rectangle destRect = new Rectangle(6, 6, Convert.ToInt32(75 * 96 / 25.4), Convert.ToInt32(50 * 96 / 25.4));//③屏幕分辨率:96
Rectangle srcRect = new Rectangle(0, 0, Bmp.Width, Bmp.Height);
e.Graphics.DrawImage((Image)Bmp, destRect, srcRect, System.Drawing.GraphicsUnit.Pixel);//我怀疑问题与这条语句有关
}
design_Elements[reportPages_Number].page_TypeFace.Page_Area.Width = (int)Math.Floor(int.Parse(input_def[0].textBox.Text) * 3.779527559055118);
design_Elements[reportPages_Number].page_TypeFace.Page_Area.Height = (int)Math.Floor(int.Parse(input_def[1].textBox.Text) * 3.779527559055118) + 13 + 126;
.....................
......................
g.DrawImage(bmp, dr, sr, GraphicsUnit.Pixel);
.............................
............................
public static string[] page_types = new string[24] {
"A0","A1","A2","A3","A4","A5","A6","A7",
"B0","B1","B2","B3","B4","B5","B6","B7",
"C0","C1","C2","C3","C4","C5","C6","C7"
};
public static string[] page_size = new string[24] {
"841×1189","594×841","420×594","297×420","210×297","148×210","105×148","74×105",
"1000×1414","707×1000","500×707","353×500","250×353","176×250","125×176","88×125",
"917×1297","648×917","458×648","324×458","229×324","162×229","114×162","81×114"
};
public static string[] page_pixel = new string[24] {
"3178×4493","2245×3178","1587×2245","1122×1587","793×1122","559×793","396×559","279×396",
"3779×5344","2672×3779","1889×2672","1334×1889","944×1334","665×944","472×665","332×472",
"3465×4902","2449×3465","1731×2449","1235×1731","865×1224","612×865","430×612","306×430"
};