0

请建议,我正在尝试将我的图像列表打印一页图像。以下代码将每个图像与其他图像重叠打印在一页上。

  void pd_PrintPage(object sender, PrintPageEventArgs e)
    {

        List<Bitmap> labels = GetLabels();


        foreach (var bitmap in labels)
        {
            e.Graphics.DrawImageUnscaled(bitmap, 0, 0);
        }
    }
4

1 回答 1

1

Move the read of bitmaps outside the PrintPage event handler, make it something like this:

void pd_PrintPage(object sender, PrintPageEventArgs e)
{
   var bitmap = GetNextLabel();

   if(bitmap != null)
   {
      e.Graphics.DrawImageUnscaled(bitmap, 0, 0);
   }

   // Will print more pages as long as there are bitmaps
   e.HasMorePages = (bitmap != null);
}

So the GetNextLabel() method will have to keep track of what bitmap to print next, and return null when there are no more to print.

Setting e.HasMorePages = true will print another page. See this link for more details

于 2012-09-24T10:26:58.520 回答