troubleshooting Question

printing a form in C# as a graphic

Avatar of r3nder
r3nderFlag for United States of America asked on
Programming.NET ProgrammingC#
15 Comments1 Solution690 ViewsLast Modified:
Hello all, I found this code but it doesnt work to well - I am trying to print a form in a winform app using WPF as a graphic. This is in the formname.xaml.cs

protected void btnPrint_Click(object sender, EventArgs e)
	PrintDocument pd = new PrintDocument();
	pd.PrintPage += new PrintPageEventHandler(PrintImage);

void PrintImage(object o, PrintPageEventArgs e)
	int x = SystemInformation.WorkingArea.X;
	int y = SystemInformation.WorkingArea.Y;
	int width = this.Width;
	int height = this.Height; 

	Rectangle bounds = new Rectangle(x, y, width, height); 

	Bitmap img = new Bitmap(width, height); 

	this.DrawToBitmap(img, bounds);
	Point p = new Point(100, 100);
	e.Graphics.DrawImage(img, p);    
any and all help is aprecciated

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 15 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 15 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros