using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
namespace WindowsFormsApplication17
{
public
partial class Form1 : Form
{
String drawString = "";
Font drawFont = null;
SolidBrush drawBrush = null;
float x = 0F;
float y = 0F;
StringFormat drawFormat = new StringFormat();
string test = "";
public string Test
{
get { return test; }
set { test = value; }
}
public Form1()
{
InitializeComponent();
//设置纸张大小
PaperSize paperSize = new PaperSize("DataOrder", 1023, 614);
printDocument1.DefaultPageSettings.PaperSize = paperSize;
}
//打印
private void button1_Click(object sender, EventArgs e)
{
printDocument1.PrintPage += new
PrintPageEventHandler(MyPrintDoc_PrintPage);
try
{
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.FormBorderStyle =
FormBorderStyle.Fixed3D;
printPreviewDialog1.ShowDialog();
printDocument1.Print();
}
catch
{
MessageBox.Show("请安装打印机", "提示", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
protected void MyPrintDoc_PrintPage(object sender,
PrintPageEventArgs e)
{
//字体 颜色 格式 坐标
drawFont = new Font("Arial", 8);
drawBrush = new SolidBrush(Color.Black);
x = 0F;
y = 0F;
drawFormat.FormatFlags = StringFormatFlags.NoWrap;
//块数
int num = 6;
float weightAll = 12.600F;
//标题
//标题第一行
string title = "钢板入库计量单";
string BillCode = "吊号:" + "20080505170";
string ClassType = "班别:" + "乙";
string type1 = "类型:" + "定轧";
string OrderNum = "记录单号:" + "QW-Y14-02-06";
//标题第二行
string ArriveStation = "到站:";
string SpLine = "专用线:";
string SaleNo = "销售订单号:";
//标题第三行
string AcceptName = "收货单位:" + "XXXX/12*2438*9144收二支";
string time = DateTime.Now.Year.ToString() + "年" +
DateTime.Now.Month.ToString().PadLeft(2,'0')+"月"+DateTime.Now.Day.ToString()+"日";
//表格下数据
string BoardNum = "合计:" + num.ToString() +
"
块
" + weightAll.ToString()+"
吨 ";
string CheckMan1 = "检查员:" + "";
string MeName = "计量员:"+"XX";