Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating graphics from scratch and returning them to print a page event

I'm working in C# .NET 3.5. I have a class of recipes that contains an image and some strings. I want to print out these recipes, four per page. I want to write a "getprintobject" function in the class to return something to draw onto my print document, but I'm stumped...

I wish I could just create and return a graphics object, but I don't see a "e.graphics.drawgraphics()". I have also thought about creating a bitmap or image and returning that, but I'm not sure how to create one from scratch and get a new graphics object to modify it.

like image 678
Steve Goykovich Avatar asked Feb 25 '23 02:02

Steve Goykovich


1 Answers

Create an Image, and use that image as a base for your Graphics object. e.g.

Bitmap img = new Bitmap(50, 50);
Graphics g = Graphics.FromImage(img);

Drawing on your graphics object, will draw on your image -- which you can then return.

like image 116
George Johnston Avatar answered Apr 26 '23 14:04

George Johnston