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();
//Set paper size
PaperSize paperSize = new PaperSize("DataOrder", 1023, 614);
= paperSize;
}
//Print
private void button1_Click(object sender, EventArgs e)
{
+= new PrintPageEventHandler(MyPrintDoc_PrintPage);
try
{
= printDocument1;
= FormBorderStyle.Fixed3D;
();
();
}
catch
{
("Please install the printer", "Tip", , );
}
}
protected void MyPrintDoc_PrintPage(object sender, PrintPageEventArgs e)
{
//Font Color Format Coordinates
drawFont = new Font("Arial", 8);
drawBrush = new SolidBrush();
x = 0F;
y = 0F;
= ;
//Number of blocks
int num = 6;
float weightAll = 12.600F;
//Title
//The first line of the title
string title = "Steel plate storage measurement order";
string BillCode = "Hanging number:" + "20080505170";
string ClassType = "Class:" + "B";
string type1 = "Type:" + "Standard Rolling";
string OrderNum = "Record Order Number:" + "QW-Y14-02-06";
//The second line of title
string ArriveStation = "Arrival:";
string SpLine = "Special Line:";
string SaleNo = "Sales Order Number:";
//The third line of the title
string AcceptName = "Receiver unit:" + "XXXX/12*2438*9144 collects two branches";
string time = () + "year" + ().PadLeft(2,'0')+"month"+()+"day";
//Data under the table
string BoardNum = "Total:" + () + " Block " + ()+" Tons ";
string CheckMan1 = "Inspector:" + "";
string MeName = "Meter: "+"XX";
string CheckMan2 = "Checkman:" + "";
//Length of line
Pen line = new Pen(drawBrush, 1);
//Drawing--The position of the word
//Drawing--Total title
(title, drawFont, drawBrush, 400, 45, drawFormat);
//Drawing-Title-First Line
//Hanging number
(BillCode, drawFont, drawBrush, 125,83, drawFormat);
//Class
(ClassType, drawFont, drawBrush, 354, 83, drawFormat);
//type
(type1, drawFont, drawBrush, 500, 83, drawFormat);
//Record order number
(OrderNum, drawFont, drawBrush, 685, 83, drawFormat);
//Drawing-Title-Second Line
//Arrival
(ArriveStation, drawFont, drawBrush, 125, 106, drawFormat);
//Special cable
(SpLine, drawFont, drawBrush, 354, 106, drawFormat);
//Sales Order Number
(SaleNo, drawFont, drawBrush, 500, 106, drawFormat);
//Drawing-Title-Third Line
//The receiving unit
(AcceptName, drawFont, drawBrush, 125, 129, drawFormat);
//time
(time, drawFont, drawBrush, 685, 129, drawFormat);
//Drawing--Data under the table
//Total
(BoardNum, drawFont, drawBrush, 125, 568, drawFormat);
//Inspector
(CheckMan1, drawFont, drawBrush, 400, 568, drawFormat);
//Measuring
(MeName, drawFont, drawBrush, 550, 568, drawFormat);
//Check
(CheckMan2, drawFont, drawBrush, 700, 568, drawFormat);
//Drawing Table
float leftbianJu = 120;
float topbianJu = 152;
float tableWidth = 770;
float tableHeight = 393;
float cellwidth = 55;
float cellwidth1 = 110;
float cellheigh = 0F;
//Drawing--The position of the line Outer rectangle
//Horizontal
(line, leftbianJu, topbianJu,leftbianJu+tableWidth,topbianJu);
(line, leftbianJu, topbianJu + tableHeight, leftbianJu + tableWidth, topbianJu + tableHeight);
//Vertical
(line, leftbianJu, topbianJu, leftbianJu, topbianJu+tableHeight);
(line, leftbianJu + tableWidth, topbianJu, leftbianJu + tableWidth, topbianJu + tableHeight);
//(line, 15, 0, 15, 614);
//Drawing--The position of the internal vertical line
y = topbianJu+tableHeight;
x = leftbianJu + cellwidth;
(line, x, topbianJu, x,y );
x= leftbianJu + cellwidth + cellwidth1;
(line,x , topbianJu, x, y);
x = leftbianJu + cellwidth + cellwidth1 * 2;
(line, x, topbianJu, x, y);
x = leftbianJu + cellwidth + cellwidth1 * 3;
(line, x, topbianJu, x, y);
x = leftbianJu + cellwidth * 2 + cellwidth1 * 3;
(line, x, topbianJu, x, y);
x = leftbianJu + cellwidth * 3 + cellwidth1 * 3;
(line, x, topbianJu, x, y);
x = leftbianJu + cellwidth * 4 + cellwidth1 * 3;
(line, x, topbianJu, x, y);
x = leftbianJu + cellwidth * 5 + cellwidth1 * 3;
(line, x, topbianJu, x, y);
x = leftbianJu + cellwidth * 6 + cellwidth1 * 3;
(line, x, topbianJu, x, y);
x = leftbianJu + cellwidth * 7 + cellwidth1 * 3;
(line, x, topbianJu, x, y);
//Drawing--The position of the inner horizontal line
//Calculate the table height based on the number of blocks
if (num != 0)
cellheigh = tableHeight / (float)num;
else
cellheigh = 0;
//Drawing--The position of the inner horizontal line
for (int i = 1; i < num; i++)
{
if (i == 1)
{
//data
string str = "";
str = "serial number";
x = leftbianJu + cellwidth / 5;
y = topbianJu + cellheigh / 3;
(str, drawFont, drawBrush, x, y, drawFormat);
str = "card number";
x = leftbianJu + cellwidth + cellwidth1 / 5;
(str, drawFont, drawBrush, x, y, drawFormat);
str = "furnace number";
x = leftbianJu + cellwidth + cellwidth1 + cellwidth1 / 5;
(str, drawFont, drawBrush, x, y, drawFormat);
str = "Material encoding";
x = leftbianJu + cellwidth + cellwidth1*2 + cellwidth1 / 5;
(str, drawFont, drawBrush, x, y, drawFormat);
str = "brand";
x = leftbianJu + cellwidth + cellwidth1*3 + cellwidth / 5;
(str, drawFont, drawBrush, x, y, drawFormat);
str = "thickness";
x = leftbianJu + cellwidth * 2 + cellwidth1 * 3 + cellwidth / 5;
(str, drawFont, drawBrush, x, y, drawFormat);
str = "width";
x = leftbianJu + cellwidth * 3 + cellwidth1 * 3 + cellwidth / 5;
(str, drawFont, drawBrush, x, y, drawFormat);
str = "length";
x = leftbianJu + cellwidth * 4 + cellwidth1 * 3 + cellwidth / 5;
(str, drawFont, drawBrush, x, y, drawFormat);
str = "weight";
x = leftbianJu + cellwidth * 5 + cellwidth1 * 3 + cellwidth / 5;
(str, drawFont, drawBrush, x, y, drawFormat);
str = "level";
x = leftbianJu + cellwidth * 6 + cellwidth1 * 3 + cellwidth / 5;
(str, drawFont, drawBrush, x, y, drawFormat);
str = "deviation";
x = leftbianJu + cellwidth * 7 + cellwidth1 * 3 + cellwidth / 5;
(str, drawFont, drawBrush, x, y, drawFormat);
}
//Horizontal line
y = topbianJu + cellheigh * i;
(line, leftbianJu, y, leftbianJu + tableWidth, y);
}
= false;
}