打印文本机器人文本

时间:2014-07-28 15:29:54

标签: c# printing textbox printdocument

我正在尝试制作一个打印文本框全文的程序。当我在打印之前将其生成为pdf以查看页面时,一些文本丢失了。

这是我的代码:

private void Print_Click(object sender, EventArgs e)
{
    PrintDialog PD = new PrintDialog();
    PrintDocument PDoc = new PrintDocument();
    PD.Document = PDoc;

    PDoc.PrintPage += new PrintPageEventHandler(PDoc_PrintPage);

    DialogResult result = PD.ShowDialog();

    if (result == DialogResult.OK)
    {
        PDoc.Print();
    }

}

void PDoc_PrintPage(object sender, PrintPageEventArgs e)
{
    Graphics graph = e.Graphics;
    graph.DrawString(textBox1.Text, 
        new Font("Arial", 12), new SolidBrush(Color.Black), 10, 10);
}

这是文本(仅供测试):

hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello

hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello

hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohello

这是文本框截图:

  

enter image description here

这就是我得到的:

  

enter image description here

你可以看到一些文字遗失了。我对打印并不熟悉,所以我不知道如何解决这个问题。

1 个答案:

答案 0 :(得分:0)

看起来您的问题是您希望在打印时包装文本。看看上一个帖子:Automatically Word-Wrapping Text To A Print Page?