资源简介
套打Demo
【核心代码】
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Printing; namespace Print_Demo { public partial class Form1 : Form { public PrintDocument printDt = new PrintDocument(); //打印文档对象 Font printFont; //打印使用的字体 public Form1() { InitializeComponent(); } void printDt_PrintPage(object sender, PrintPageEventArgs e) { float pointX = 10; float pointY = 10; e.Graphics.DrawString("打印内容", new Font("宋体", 16F), Brushes.Black, pointX 60, pointY); e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 26,pointX 300,pointY 26); e.Graphics.DrawString("打印内容", printFont, Brushes.Black, pointX, pointY 35); e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 56, pointX 300, pointY 56); e.Graphics.DrawString("打印内容", printFont, Brushes.Black, pointX, pointY 65); e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 86, pointX 300, pointY 86); e.Graphics.DrawString("打印内容", printFont, Brushes.Black, pointX, pointY 95); e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 116, pointX 300, pointY 116); e.Graphics.DrawString("打印内容", printFont, Brushes.Black, pointX, pointY 125); e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 146, pointX 300, pointY 146); e.Graphics.DrawString("打印内容", printFont, Brushes.Black, pointX, pointY 155); e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 176, pointX 300, pointY 176); e.Graphics.DrawString("打印内容", printFont, Brushes.Black, pointX, pointY 185); e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 206, pointX 300, pointY 206); e.Graphics.DrawString("检测结果", printFont, Brushes.Black, pointX, pointY 233); e.Graphics.DrawString("通过", new Font("宋体",22F,FontStyle.Bold), Brushes.Black, pointX 90, pointY 225); e.Graphics.DrawLine(new Pen(Color.Black), pointX, pointY 265, pointX 300, pointY 265); e.Graphics.DrawString("单位名称", printFont, Brushes.Black, pointX, pointY 275); } private void Form1_Load(object sender, EventArgs e) { printDt.PrintPage = new PrintPageEventHandler(printDt_PrintPage); printFont = new Font("宋体", 12F); } private void btnPrint_Click(object sender, EventArgs e) { //PrintDialog printDlg = new PrintDialog(); //printDlg.Document = printDt; //printDlg.AllowPrintToFile = true; //printDlg.AllowCurrentPage = true; //printDlg.AllowSelection = true; //printDlg.ShowDialog(); //printDlg.ShowDialog(); printDt.Print(); } private void btnLook_Click(object sender, EventArgs e) { PrintPreviewDialog printPreview = new PrintPreviewDialog(); printPreview.PrintPreviewControl.Document = printDt; printPreview.ShowDialog(this); } } }
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
namespace Print_Demo
{
public partial class Form1 : Form
{
public PrintDocument printDt = new PrintDocument(); //打印文档对象
Font printFont; //打印使用的字体
public Form1()
{
InitializeComponent();
}
void printDt_PrintPage(object sender PrintPageEventArgs e)
{
float pointX = 10;
float pointY = 10;
e.Graphics.DrawString(“打印内容“ new Font(“宋体“ 16F) Brushes.Black pointX+60 pointY);
e.Graphics.DrawLine(new Pen(Color.Black) pointX pointY + 26pointX + 300pointY + 26);
e.Graphics.DrawString(“打印内容“ printFont Brushes.Black pointX pointY+35);
e.Graphics.DrawLine(new Pen(Color.Black) pointX pointY + 56 pointX + 300 pointY + 56);
e.Graphics.DrawString(“打印内容“ printFont Brushes.Black pointX pointY + 65);
e.Graphics.DrawLine(new Pen(Color.Black) pointX pointY + 86 pointX + 300 pointY + 86);
e.Graphics.DrawString(“打印内容“ printFont Brushes.Black pointX pointY + 95);
e.Graphics.DrawLine(new Pen(Color.Black) pointX pointY + 116 pointX + 300 pointY + 116);
e.Graphics.DrawString(“打印内容“ printFont Brushes.Black pointX pointY + 125);
e.Graphics.DrawLine(new Pen(Color.Black) pointX pointY + 146 pointX + 300 pointY + 146);
e.Graphics.DrawString(“打印内容“ printFont Brushes.Black pointX pointY + 155);
e.Graphics.DrawLine(new Pen(Color.Black) pointX pointY + 176 pointX + 300 pointY + 176);
e.Graphics.DrawString(“打印内容“ printFont Brushes.Black pointX pointY + 185);
e.Graphics.DrawLine(new Pen(Color.Black) pointX pointY + 206 pointX + 300 pointY + 206);
e.Graphics.DrawString(“检测结果“ printFont Brushes.Black pointX pointY + 233);
e.Graphics.DrawString(“通过“ new Font(“宋体“22FFontstyle.Bold) Brushes.Black pointX+90 pointY + 225);
e.Graphics.DrawLine(new Pen(Color.Black) pointX pointY + 265 pointX + 300 pointY + 265);
e.Graphics.DrawString(“单位名称“ printFont Brushes.Black pointX pointY + 275);
}
private void Form1_Load(object sender EventArgs e)
{
printDt.PrintPage += new PrintPageEventHandler(printDt_PrintPage);
printFont = new Font(“宋体“ 12F);
}
private void btnPrint_Click(object sender EventArgs e)
{
//PrintDialog printDlg = new PrintDialog();
//printDlg.Document = printDt;
//printDlg.AllowPrintToFile = true;
//printDlg.AllowCurrentPage = true;
//printDlg.AllowSelection = true;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 391 2009-03-17 12:04 套打Demo\Print_Demo\Print_Demo\bin\Debug\ddd
文件 20480 2010-09-30 13:25 套打Demo\Print_Demo\Print_Demo\bin\Debug\Print_Demo.exe
文件 24064 2010-09-30 13:25 套打Demo\Print_Demo\Print_Demo\bin\Debug\Print_Demo.pdb
文件 5632 2005-11-11 22:25 套打Demo\Print_Demo\Print_Demo\bin\Debug\Print_Demo.vshost.exe
目录 0 2009-03-17 12:04 套打Demo\Print_Demo\Print_Demo\bin\Debug
目录 0 2009-03-17 11:25 套打Demo\Print_Demo\Print_Demo\bin
文件 3522 2010-09-30 13:25 套打Demo\Print_Demo\Print_Demo\Form1.cs
文件 2727 2009-03-17 12:09 套打Demo\Print_Demo\Print_Demo\Form1.Designer.cs
文件 5814 2009-03-17 12:09 套打Demo\Print_Demo\Print_Demo\Form1.resx
文件 842 2009-03-17 12:09 套打Demo\Print_Demo\Print_Demo\obj\Debug\Print_Demo.csproj.GenerateResource.Cache
文件 20480 2010-09-30 13:25 套打Demo\Print_Demo\Print_Demo\obj\Debug\Print_Demo.exe
文件 180 2009-03-17 12:09 套打Demo\Print_Demo\Print_Demo\obj\Debug\Print_Demo.Form1.resources
文件 24064 2010-09-30 13:25 套打Demo\Print_Demo\Print_Demo\obj\Debug\Print_Demo.pdb
文件 180 2009-03-17 11:55 套打Demo\Print_Demo\Print_Demo\obj\Debug\Print_Demo.Properties.Resources.resources
目录 0 2009-03-17 11:25 套打Demo\Print_Demo\Print_Demo\obj\Debug\TempPE
目录 0 2010-09-30 13:25 套打Demo\Print_Demo\Print_Demo\obj\Debug
文件 753 2010-09-30 13:25 套打Demo\Print_Demo\Print_Demo\obj\Print_Demo.csproj.FileListAbsolute.txt
目录 0 2009-03-17 11:55 套打Demo\Print_Demo\Print_Demo\obj
文件 3227 2009-03-17 11:55 套打Demo\Print_Demo\Print_Demo\Print_Demo.csproj
文件 469 2009-03-17 11:25 套打Demo\Print_Demo\Print_Demo\Program.cs
文件 1174 2009-03-17 11:25 套打Demo\Print_Demo\Print_Demo\Properties\AssemblyInfo.cs
文件 2876 2009-03-17 11:25 套打Demo\Print_Demo\Print_Demo\Properties\Resources.Designer.cs
文件 5612 2009-03-17 11:25 套打Demo\Print_Demo\Print_Demo\Properties\Resources.resx
文件 1095 2009-03-17 11:25 套打Demo\Print_Demo\Print_Demo\Properties\Settings.Designer.cs
文件 249 2009-03-17 11:25 套打Demo\Print_Demo\Print_Demo\Properties\Settings.settings
目录 0 2009-03-17 11:25 套打Demo\Print_Demo\Print_Demo\Properties
目录 0 2010-09-30 13:25 套打Demo\Print_Demo\Print_Demo
文件 919 2009-03-17 11:25 套打Demo\Print_Demo\Print_Demo.sln
..A..H. 12800 2010-09-30 14:07 套打Demo\Print_Demo\Print_Demo.suo
目录 0 2009-03-17 11:25 套打Demo\Print_Demo
............此处省略4个文件信息
相关资源
-
C# 开发BHO(Browser Helper ob
ject)插件 - c# + sqlite demo(增删改查)
- C# 调用摄像头拍照(基于AForge)
- Autofac(IoC依赖注入容器)Demo
- panel内容打印(图片打印)
- C# 调用BarTender打印条码DEMO
- 大型比赛竞赛抽签系统 可打印 c# vs
- C# 斑马标签打印 WEBWINFORM
- Winform可视化打印模板设计
- 汉王人脸通SDK v3.0 c#接收互联网数据
- C#调用Lucene方法-实现快速搜索
- Unity2D小游戏——炸弹人类似qq堂的小
- .Net C# 小程序卡券demo
- 神思ss628型USB二代身份证DEMOC#
- wpf 搜集整理demo源码(都是c#写的,惊
- C#H264格式视频解码
- C#利用Zxing.NET生成条形码和二维码并实
- winform c# mschart demo 范例
- C# 斑马打印机USB接口ZPL条码打印
- C#调用USB接口斑马打印机
- C#调用SAP RFC 案例demo
- 12306抢票工具--抢票C# Demo
- .net批量打印word源码C#_VS2012
- WinForm C#Demo 会员与消费系统 进销存系
- Protogen编译protobuf demotools.rar
- 网页js与本地C#程序 websocket通讯实现打
- C# RedisDemo Redisdll 全部DLL
- c#微信支付、微信企业支付到个人,微
- 带条码打印的固定资产管理系统源码
- 热敏打印机C#二次开发包DLL
评论
共有 条评论