现有两张不同名字的图片,我想在页面上实现打印功能,把这两张图片在同一页面打印出来,我用的是C# Winform,请问该如何实现?我现有打印一张图片的代码,如下:
private void PrintPageImage(object sender, PrintPageEventArgs ev)
{
//定义输出图处的相关大小
Image image = this.pic.Image;
int x=ev.MarginBounds.X;
int y=ev.MarginBounds.Y;
int width=image.Width;
int height=image.Height;
System.Drawing.Rectangle destRect=new System.Drawing.Rectangle(x,y,width,height);
ev.Graphics.DrawImage(image,destRect,0,0,image.Width,image.Height,System.Drawing.GraphicsUnit.Pixel);
}

解决方案 »

  1.   

    private void PrintPageImage(object sender, PrintPageEventArgs ev)
    {
    //定义输出图处的相关大小
    Image image = this.pic.Image;
    int x=ev.MarginBounds.X;
    int y=ev.MarginBounds.Y;
    int width=image.Width;
    int height=image.Height;
    System.Drawing.Rectangle destRect=new System.Drawing.Rectangle(x,y,width,height);
    ev.Graphics.DrawImage(image,destRect,0,0,image.Width,image.Height,System.Drawing.GraphicsUnit.Pixel);//Draw another image
    Image image2 = Image.FromFile( otherfile );//you can change its source
    x=ev.MarginBounds.X;
    y=ev.MarginBounds.Y;
    width=image2.Width;
    height=image2.Height;destRect=new System.Drawing.Rectangle(x,y + image.Height + 10,width,height);
    ev.Graphics.DrawImage( image2,destRect,0,0,image2.Width,image2.Height,System.Drawing.GraphicsUnit.Pixel);}