所以我试图在 a 的情况下在循环中绘制一个PrintPage
字符串PrintDocument
:
for (int c = 0; c < currentwords; c++)
{
// index is a global int that starts at 0 and f9 is a font with size 9
ev.Graphics.DrawString(allitems[index], f9, Brushes.Black, new Point(100, 100));
// I used new Point(100, 100) for debugging purposes but normally I would
// do some calculating to see where it is to be printed
index++;
}
看起来一切正常,调试器显示它在我使用断点时运行,但是当我在 a 中显示文档时PrintPreviewDialog
它没有显示。allitems[index]
确实包含一个值,我不确定它为什么不显示。我在循环之外打印其他字符串和矩形,它们显示在对话框中。如果有人可以帮助我,请在此处发布,谢谢!
编辑:
以下是图形模式/渲染提示:
ev.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
ev.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
ev.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
ev.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
ev.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
编辑2:
好的,所以我使用了:
ev.Graphics.DrawString(allitems[0], f9, Brushes.Black, new Point(100, 100));
for (int c = 0; c < currentwords; c++)
{
// index is a global int that starts at 0 and f9 is a font with size 9
ev.Graphics.DrawString(allitems[index], f9, Brushes.Black, new Point(100, 100));
// I used new Point(100, 100) for debugging purposes but normally I would
// do some calculating to see where it is to be printed
index++;
}
并且只DrawString
显示了循环外部,但循环应该可以工作并且代码正在运行。