int b = 0;
int c = 0;
int d = 0;
private void form2_Load(object sender, EventArgs e)
{
foreach (PaperSize ps5 in pdc.PrinterSettings.PaperSizes)
{
if (ps5.PaperName == "A4")
{
printDocument1.DefaultPageSettings.PaperSize = ps5;
}
}
int a = Ds.Tables[0].Rows.Count; //a 原始总共有多少行
if (a % 16 == 0)
c = a / 16; //c 计算共有多少页,每16笔分页
else
c = a / 16 + 1;
printPreviewControl1.Zoom = 1.0;
printPreviewControl1.Document = pdc;
pdc.DocumentName = c.ToString(); //此处显示共多少页
b = 0;
d = c;
pdc.PrintPage += new PrintPageEventHandler(zdy); //使用自定义 zdy
{
y = 381;
for (int p = 0; p < k; p++)
{
y += 18;
e.Graphics.DrawString(Ds.Tables[0].Rows[0]["请购原因详细说明"].ToString().Trim().Substring(55 * p, 55) + '\r' + '\n', PrintFont, Brushes.Black, 20, y, new StringFormat());//因每行的长度是55,故55是固定不变的
}
e.Graphics.DrawString(Ds.Tables[0].Rows[0]["请购原因详细说明"].ToString().Trim().Substring(55 * k, m - 55 * k) + '\r' + '\n', PrintFont, Brushes.Black, 20, 399 + 18 * k, new StringFormat());//最后一点尾数的字符处理
e.Graphics.DrawString(Ds.Tables[0].Rows[0]["请购单号"].ToString().Trim(), PrintFont, Brushes.Black, 80, 780, new StringFormat()); //请购单号
b += 1;
if (b < d)
e.HasMorePages = true; //此处决定是否打印多页内容
else
e.HasMorePages = false;
}
int c = 0;
int d = 0;
private void form2_Load(object sender, EventArgs e)
{
foreach (PaperSize ps5 in pdc.PrinterSettings.PaperSizes)
{
if (ps5.PaperName == "A4")
{
printDocument1.DefaultPageSettings.PaperSize = ps5;
}
}
int a = Ds.Tables[0].Rows.Count; //a 原始总共有多少行
if (a % 16 == 0)
c = a / 16; //c 计算共有多少页,每16笔分页
else
c = a / 16 + 1;
printPreviewControl1.Zoom = 1.0;
printPreviewControl1.Document = pdc;
pdc.DocumentName = c.ToString(); //此处显示共多少页
b = 0;
d = c;
pdc.PrintPage += new PrintPageEventHandler(zdy); //使用自定义 zdy
}
{
y = 381;
for (int p = 0; p < k; p++)
{
y += 18;
e.Graphics.DrawString(Ds.Tables[0].Rows[0]["请购原因详细说明"].ToString().Trim().Substring(55 * p, 55) + '\r' + '\n', PrintFont, Brushes.Black, 20, y, new StringFormat());//因每行的长度是55,故55是固定不变的
}
e.Graphics.DrawString(Ds.Tables[0].Rows[0]["请购原因详细说明"].ToString().Trim().Substring(55 * k, m - 55 * k) + '\r' + '\n', PrintFont, Brushes.Black, 20, 399 + 18 * k, new StringFormat());//最后一点尾数的字符处理
e.Graphics.DrawString(Ds.Tables[0].Rows[0]["请购单号"].ToString().Trim(), PrintFont, Brushes.Black, 80, 780, new StringFormat()); //请购单号
b += 1;
if (b < d)
e.HasMorePages = true; //此处决定是否打印多页内容
else
e.HasMorePages = false;
}