0

I have problems printing to a network printer. The code below works fine on my own laptop and from Visual Studio, but when the site is run on an IIS 8 website (on Windows Server 2008 R2), clicking the printer buttons does nothing.. the page just starts loading (loads forever and times out), but nothing happens and no jobs are added to the printer's queue..

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            int i = 0;
            foreach (string s in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
            {
                Button b = new Button();
                b.ID = "Print_" + i;
                b.Text = s.ToString();
                b.Click += b_Click;
                test.Controls.Add(b);
                i++;
            }

        }

        void b_Click(object sender, EventArgs e)
        {
            string printer = ((Button)sender).Text;
            PrintDocument p = new PrintDocument();
            p.PrinterSettings.PrinterName = printer;
            p.PrintPage += p_PrintPage;

            p.Print();
        }


        void p_PrintPage(object sender, PrintPageEventArgs e)
        {
            e.Graphics.DrawString("testpage", new System.Drawing.Font("Arial", 12), Brushes.Black, new PointF(200, 200));
        }
    }
Jaska
  • 1,412
  • 1
  • 18
  • 39
  • See the "Related" section over to the right? The first item there [Printing from ASP.NET to a network printer](http://stackoverflow.com/questions/3729153/printing-from-asp-net-to-a-network-printer?rq=1) may have your answer. – DOK Sep 13 '13 at 21:54
  • No that post doesn't help at all.. all permission are set and impersonation configured and the printers are listed on the web-page, so i don't think this is related to any permission problem.. – Jaska Sep 13 '13 at 22:00

0 Answers0