private void print_printpage(object sender, PrintPageEventArgs e) { int top = 0; var xml = System.IO.File.ReadAllText(Program.path + "\\print_style\\批发销售.xml", System.Text.Encoding.GetEncoding("gb2312")); ReadXml read = new ReadXml(xml); // int block1Height = Convert.ToInt32(read.Read("block1/height")); int block2Height = Convert.ToInt32(read.Read("block2/height")); int block3Height = Convert.ToInt32(read.Read("block3/height")); // DrawField(e.Graphics, read, top, "block1/field", dtPrint.Rows[0]); DrawText(e.Graphics, read, top, "block1/text"); DrawLine(e.Graphics, read, top, "block1/line"); DrawLineII(e.Graphics, read, top, "block1/lineII"); DrawPicture(e.Graphics, read, top, "block1/picture"); top += block1Height; // foreach (DataRow row in dtPrint.Rows) { DrawField(e.Graphics, read, top, "block2/field", row); DrawText(e.Graphics, read, top, "block2/text"); DrawLine(e.Graphics, read, top, "block2/line"); DrawLineII(e.Graphics, read, top, "block2/lineII"); DrawPicture(e.Graphics, read, top, "block2/picture"); top += block2Height; } // DrawField(e.Graphics, read, top, "block3/field", dtPrint.Rows[0]); DrawText(e.Graphics, read, top, "block3/text"); DrawLine(e.Graphics, read, top, "block3/line"); DrawLineII(e.Graphics, read, top, "block3/lineII"); DrawPicture(e.Graphics, read, top, "block3/picture"); }
private int GetHight() { int height = 0; var xml = System.IO.File.ReadAllText(Program.path + "\\print_style\\批发销售.xml", System.Text.Encoding.GetEncoding("gb2312")); ReadXml read = new ReadXml(xml); int block1Height = Convert.ToInt32(read.Read("block1/height")); int block2Height = Convert.ToInt32(read.Read("block2/height")); int block3Height = Convert.ToInt32(read.Read("block3/height")); height += block1Height; foreach (DataRow row in dtPrint.Rows) { height += block2Height; } height += block3Height; if (height < 550) { height = 550; } if (height % 550 != 0) { height += 550 - height % 550; } return(height); }