在单页c#上打印两张图像 [英] print two images on single page c#

查看:84
本文介绍了在单页c#上打印两张图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在单页上打印两张图片。

我试过下面的代码,但是它打印的是不同页面上的所有图片。



I want to print two images on single page.
I have tried below code, but it is printing all images on different pages.

public void PD_PrintPage(object sender, PrintPageEventArgs e)
{
    float W = e.MarginBounds.Width;
    float H = e.MarginBounds.Height;

    for (; FileCounter >= 0; FileCounter--)
    {
        try
        {
            Bitmap Bmp = new Bitmap(BmpFiles[FileCounter]);
            if (Bmp.Width / W < Bmp.Height / H)
                W = Bmp.Width * H / Bmp.Height;
            else
                H = Bmp.Height * W / Bmp.Width;

            e.Graphics.DrawImage(Bmp, 0, 0, W, H);

            break;
        }
        catch
        {
        }
    }

    FileCounter -= 1;

    if (FileCounter > 0)
    {
        e.HasMorePages = true;
    }
    else
    {
        FileCounter = BmpFiles.Length - 1;
    }
}



这将打印不同页面中的所有图像



我想要打印一个图像的一些功能,留下一些空间,如果剩余空间则再次在同一页面中显示其他图像。


this will print all images in different page

I want some functionality that will print one image ,leave some space and again prine other image in same page if space is remaining.

推荐答案

你有一个 break; 尝试块中的语句,这意味着你永远不会超过第一项。您还有一个空的 catch 块,这意味着您的程序将忽略所有异常,并且可能无故失败。
You have a break; statement inside your try block, which means you never get past the first item. You also have an empty catch block, which means your program will ignore all exceptions and probably fail without reason.


这篇关于在单页c#上打印两张图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆