最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
c#实现打印功能,纸张大小,字体和颜色等
时间:2022-06-25 04:59:25 编辑:袖梨 来源:一聚教程网
c#实现打印功能,纸张大小,字体和颜色等
///
/// 打印的按钮
///
///
///
private void btnprint_click(object sender, eventargs e)
{
// printdocument1 为 打印控件
//设置打印用的纸张 当设置为custom的时候,可以自定义纸张的大小,还可以选择a4,a5等常用纸型
this.printdocument1.defaultpagesettings.papersize = new papersize("custum", 500, 300);
this.printdocument1.printpage += new printpageeventhandler(this.myprintdocument_printpage);
//将写好的格式给打印预览控件以便预览
printpreviewdialog1.document = printdocument1;
//显示打印预览
dialogresult result = printpreviewdialog1.showdialog();
//if (result == dialogresult.ok)
//this.myprintdocument.print();
}
///
/// 打印的格式
///
///
///
private void myprintdocument_printpage(object sender, system.drawing.printing.printpageeventargs e)
{
/*如果需要改变自己 可以在new font(new fontfamily("黑体"),11)中的“黑体”改成自己要的字体就行了,黑体 后面的数字代表字体的大小
system.drawing.brushes.blue , 170, 10 中的 system.drawing.brushes.blue 为颜色,后面的为输出的位置 */
e.graphics.drawstring("新乡市三月软件公司入库单", new font(new fontfamily("黑体"),11), system.drawing.brushes.black, 170, 10);
e.graphics.drawstring("供货商:河南科技学院", new font(new fontfamily("黑体"), 8), system.drawing.brushes.blue, 10, 12);
//信息的名称
e.graphics.drawline(pens.black, 8, 30, 480, 30);
e.graphics.drawstring("入库单编号" , new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 9, 35);
e.graphics.drawstring("商品名称", new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 160, 35);
e.graphics.drawstring("数量", new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 260, 35);
e.graphics.drawstring("单价", new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 330, 35);
e.graphics.drawstring("总金额", new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 400, 35);
e.graphics.drawline (pens.black ,8,50,480,50);
//产品信息
e.graphics.drawstring("r2011-01-2016:06:35", new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 9, 55);
e.graphics.drawstring("联想a460", new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 160, 55);
e.graphics.drawstring("100", new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 260, 55);
e.graphics.drawstring("200.00", new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 330, 55);
e.graphics.drawstring("20000.00", new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 400, 55);
e.graphics.drawline(pens.black, 8, 200, 480, 200);
e.graphics.drawstring("地址:新乡市河南科技学院信息工程学院", new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 9, 210);
e.graphics.drawstring("经办人:任忌", new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 220, 210);
e.graphics.drawstring("服务热线:15083128577", new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 320, 210);
e.graphics.drawstring("入库时间:"+datetime.now .tostring (), new font(new fontfamily("黑体"), 8), system.drawing.brushes.black, 9, 230);
}
相关文章
- 《燕云十六声》红尘无眼完成图文攻略 12-25
- 《燕云十六声》阴阳如影完成图文攻略 12-25
- 《燕云十六声》悬檐之下四架椽屋图文攻略 12-25
- 《燕云十六声》2024最新公测时间介绍 12-25
- 《燕云十六声》有没有藏宝阁 12-25
- 《燕云十六声》制作公司介绍 12-25