2013-10-11 70 views
0

我试图打印出一张表格,客户填写了他们签名,然后存储在我们的文件夹中,但我无法弄清楚如何正确打印表格。我已经在网上尝试过大量的指南或教程,但我只能拍摄表格并打印出来,看起来很糟糕。用图片打印表格

有没有什么方法可以打印我的表单,其中包含专业质量的控件,标签和图片?我听说过Visual Studio的插件可能可以做到这一点,如果它没有太多的麻烦,价格可能不是太多的因素。

如果很重要,我所有的控件都包含在form2中,并且打印将通过form2中的菜单按钮完成。

谢谢!

回答

2

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 
    } 
+0

谢谢!我会如何去添加一个简单的文本框来打印我的文档?我没有看到在提供的链接中添加控件的任何示例 – Nathan

+0

@ user2856410您无法“添加”文本框。您可以在任意位置的表面上绘制文字。 –

+0

我可以添加图片吗? – Nathan