I have the following method, which loads into an empty image of a template, draws relevant information on it and saves it in another file. I want to change this a bit to achieve the following results:
- Uploading a template image
- draw relevant information about him
- print it
I do not want to save it, just print it. Here is my existing method:
public static void GenerateCard(string recipient, string nominee, string reason, out string filename) { // Get a bitmap. Bitmap bmp1 = new Bitmap("template.jpg"); Graphics graphicImage; // Wrapped in a using statement to automatically take care of IDisposable and cleanup using (graphicImage = Graphics.FromImage(bmp1)) { ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg); // Create an Encoder object based on the GUID // for the Quality parameter category. Encoder myEncoder = Encoder.Quality; graphicImage.DrawString(recipient, new Font("Arial", 10, FontStyle.Regular), SystemBrushes.WindowText, new Point(480, 33)); graphicImage.DrawString(WordWrap(reason, 35), new Font("Arial", 10, FontStyle.Regular), SystemBrushes.WindowText, new Point(566, 53)); graphicImage.DrawString(nominee, new Font("Arial", 10, FontStyle.Regular), SystemBrushes.WindowText, new Point(492, 405)); graphicImage.DrawString(DateTime.Now.ToShortDateString(), new Font("Arial", 10, FontStyle.Regular), SystemBrushes.WindowText, new Point(490, 425)); EncoderParameters myEncoderParameters = new EncoderParameters(1); EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 100L); myEncoderParameters.Param[0] = myEncoderParameter; filename = recipient + " - " + DateTime.Now.ToShortDateString().Replace("/", "-") + ".jpg"; bmp1.Save(filename, jgpEncoder, myEncoderParameters); } }
I hope you can help, Brett