A StartDocPrinter call was not issued???

K

Kyle

Can you raise events from ASP.NET code that will be
handled by windows such as a print event? Is there a
security setting that makes this not allowed. I want to
be able to user the PrintPageEventHandler in my code
(because its the only way I know how to print). When I
run the following code I get an exception saying A
StartDocPrinter call was not issued

private void buttonPrint_Click(object sender,
System.EventArgs e) {
try {
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler
(this.pd_PrintPage);
pd.Print();
}
catch(Exception ex) {
Response.Write(ex.Message);
}
}

private void pd_PrintPage(object sender,
PrintPageEventArgs e) {
Font drawFont = new Font("Arial", 16);
SolidBrush drawBrush = new SolidBrush(Color.Black);
PointF drawPoint = new PointF(150.0F, 150.0F);
e.Graphics.DrawString("Hello World", drawFont,
drawBrush, drawPoint);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top