我正在尝试制作一个打印文本框全文的程序。当我在打印之前将其生成为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
这是文本框截图:
这就是我得到的:
你可以看到一些文字遗失了。我对打印并不熟悉,所以我不知道如何解决这个问题。