0
以下代码用于打印订单。 订单可以通过第一个DrawString调用写出可变数量的行。如何在C#页面的左下角打印文本
文本
Bottom line1
Bottom line2
必须出现在左下角的页面。
以下代码使用硬编码值e.MarginBounds.Top + 460
来打印此。 如何删除此硬编码值以便文本打印在页面底部?
var doc = new PrintDocument();
doc.PrinterSettings.PrinterName = "PDFCreator";
doc.PrintPage += new PrintPageEventHandler(ProvideContent);
doc.Print();
void ProvideContent(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawString("string containing variable number of lines", new Font("Arial", 12),
Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top);
e.Graphics.DrawString("Bottom line1\r\nBottom line2", new Font("Courier", 10), Brushes.Black,
e.MarginBounds.Left, e.MarginBounds.Top + 460);
}