在C#中将另一张图像打印到第二页 [英] Print another image to the second page in C#

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

问题描述

如何在打印文档的第二页中打印第二张图像..

how do i print the second image in the second page of the print document..

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
    {
        Graphics graphics = e.Graphics;

        Image bgFront = ((PictureBox)pictureBox_IDFront).Image;
        e.Graphics.DrawImage(bgFront, 0, 0, 212, 337);


        Image bgBack = ((PictureBox)pictureBox_IDBack).Image;
        e.Graphics.DrawImage(bgBack, 212, 0, 212, 337);
    }



我想将第二张图片打印到另一页。我只需要2页就可以了。正面和背面的图像。每个页面包含一些像这样的字符串用于第二页。返回页面。


i want to print the second image to another page. i will only need 2 pages for this. the front and the back image. each pages includes some string like this is for the second page. the back page.

e.Graphics.DrawString("Employee Information", printFont, Brushes.Black, y, x);
        x = x + (printFont.Size + spacing);
        e.Graphics.DrawString("Name: " + this.label_FullName.Text, printFont, Brushes.Black, y, x);
        x = x + (printFont.Size + spacing);
        e.Graphics.DrawString("Address: ", printFont, Brushes.Black, y, x);



非常感谢你的帮助。



我尝试了什么:



i尝试了e.hasmorepages但我不知道在哪里放我的代码。谢谢。


thank you very much for your help.

What I have tried:

i tried e.hasmorepages but i don't know where to put my codes. thank you.

推荐答案

快速阅读:绝对新手的.NET打印指南 [ ^ ]



如果e.HasMorePages为True,PrintPage路由会被打印一次,并且会继续打印



您需要在该例程之外声明的页面计数变量您更新并且 - 如果pagecount = 2则e.HasMorePages = False



您也可以使用相同的变量来决定要打印的图像。
Have a quick read of: An absolute beginner's guide to printing in .NET[^]

The PrintPage routing gets called once for every page printed and will continue on if e.HasMorePages is True

You need a page count variable declared outside of that routine that you update and - if pagecount = 2 then e.HasMorePages = False

You can also use that same variable to decide what image to print.


当您进行多页打印时,由您决定随时打印哪个页面,如MSDN中所示:如何:Pri Windows窗体中的多页文本文件 [ ^ ]

该示例从字符串打印,并在下次从中删除打印部分,但它与图像的原理完全相同:保留一个类级别变量,告诉您所在的页面,或者设置要打印的图像集合,并在打印时从集合中删除每个图像。
When you do multipage printing, it's up to you to decide which page you are printing at any moment, as showed in MSDN: How to: Print a Multi-Page Text File in Windows Forms[^]
That example prints from a string, and removes the printed part from it for next time, but it's exactly the same principle with images: either keep a class level variable which tells you which page you are on, or set up a collection of images to print and remove each from the collection when you print it.


这篇关于在C#中将另一张图像打印到第二页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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