【发布时间】:2014-07-28 23:52:58
【问题描述】:
我正在尝试制作一个打印文本框全文的程序。当我将其生成为 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
这是文本框截图:
这是我得到的:
如您所见,缺少一些文本。我对打印不是很熟悉,所以我不知道如何解决这个问题。
【问题讨论】:
-
不,我看不到缺少什么,因为我看不到应该打印的内容。
-
所以你错过了一些你好?
-
当您在调试器中检查
textBox1.Text时,它包含什么? -
@HimBromBeere 是的,你好只是一个例子,问题出在任何文本中。
-
在文本框中显示所有文本。
标签: c# printing textbox printdocument