PrintDocument将是要走的路。它使用GDI+
来绘制到文档的表面。您现在负责布局。
private void pd_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
{
single yPos = 0;
int count = 0;
single leftMargin = e.MarginBounds.Left;
single topMargin = e.MarginBounds.Top;
Image img = Image.FromFile({path to img});
Rectangle logo = New Rectangle(40,40,50,50);
using (Font printFont = new Font("Arial", 10.0f))
{
e.Graphics.DrawImage(img, logo);
e.Graphics.DrawString(textbox1.Text, printFont, Brushes.Black, leftMargin, yPos, New StringFormat());
}
//etc...
//taken from the example and added how to draw the text from a textbox
}
谢谢!我会如何去添加一个简单的文本框来打印我的文档?我没有看到在提供的链接中添加控件的任何示例 – Nathan
@ user2856410您无法“添加”文本框。您可以在任意位置的表面上绘制文字。 –
我可以添加图片吗? – Nathan