首页 技术 正文
技术 2022年11月20日
0 收藏 370 点赞 4,887 浏览 2027 个字
其他条码知识 请访问:http://www.ybtiaoma.com ,本文仅供参考,请勿转载,谢谢using System;
using System.Drawing;
using System.Drawing.Printing;
using System.Runtime.InteropServices;
using System.Windows.Forms;/*2014-3-1
* 测试打印机 新北洋BTP-2100E Plus 西铁城CLP-S631
* 测试结果:页面大小,上间距,左间距都可以正常使用
*/namespace PrintingExample
{
public partial class frnPrinterLabel : Form
{
public frnPrinterLabel()
{
InitializeComponent();
} private PrintDocument m_printDoc = null;//打印文档
private PrintPreviewDialog m_printPreview = null;//打印预览UI
private PrinterSettings psetting = new PrinterSettings();//实例打印设置对象 private float m_pageWidth = 70F;//纸张宽度 mm单位
private float m_pageHeight = 50F;//纸张高度 mm单位 private void Form1_Load(object sender, EventArgs e)
{
m_printDoc = new PrintDocument();//实例打印文档对象
m_printPreview = new PrintPreviewDialog(); //m_printPreview.PrintPreviewControl.AutoZoom = false;
m_printPreview.PrintPreviewControl.Zoom = ;
m_printPreview.Width = Screen.PrimaryScreen.Bounds.Width;
m_printPreview.Height = Screen.PrimaryScreen.Bounds.Height; //自定义纸张大小
m_printDoc.DefaultPageSettings.PaperSize = new PaperSize("newPage70X40"
, (int)(m_pageWidth / 25.4 * )
, (int)(m_pageHeight / 25.4 * ));
//自定义图片内容整体上间距/左间距
m_printDoc.OriginAtMargins = true;
m_printDoc.DefaultPageSettings.Margins.Top = (int)( / 25.4 * );
m_printDoc.DefaultPageSettings.Margins.Left = (int)( / 25.4 * );
//打印事件
m_printDoc.PrintPage += new PrintPageEventHandler(m_printDoc_PrintPage); } private void button1_Click(object sender, EventArgs e)
{
m_printDoc.Print();//打印
} private void btnView_Click_1(object sender, EventArgs e)
{
m_printPreview.Document = m_printDoc;//把打印文档显示到预览对话框中
m_printPreview.ShowDialog();
} /// <summary>
/// 绘制需要打印的内容
/// </summary>
void m_printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
       //创建文本信息
e.Graphics.DrawString("杭州允博条码科技有限公司", new Font("宋体", ), Brushes.Black, , ); e.Graphics.DrawString("地址:杭州市江干区九堡家苑三区\r\n" +
"电话:0571-87298557\r\n"+
"联系方式:15158883623" , new Font("宋体", ), Brushes.Black, , );
//创建二维码--需要引用DLL
       DotNetBarcode QRBarcode = new DotNetBarcode();//实例二维码       QRBarcode.Type = DotNetBarcode.Types.QRCode;
            QRBarcode.QRSetTextType = DotNetBarcode.QRTextTypes.Automatic;            QRBarcode.QRWriteBar("杭州允博条码科技有限公司", , , , e.Graphics);
} }
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,954
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,479
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,291
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,108
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,740
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,774