1

Code below is used to print from ASP .NET MVC3 application to Samsung ML-331x Series printer connected to IP address in LAN and shared in server as Samsung ML-331x Series

Nothing is printed. Execution stops at doc.Print() line. Every controller call adds new unfinished job:

Spooler output

Those jobs are never finished, only iisreset clears them.

Server is Windows 2003 + IIS It worked in MVC2 .NET 3.5 application. ForteSSL VPN was installed in server and application was upgraded to MVC3 and .NET 4. (After that printing was not checked immediately, so I'm not sure is this related to those changes).

User NETWORK SERVICE with all permissions is added to printer users but problem persists. Running application in development computer by pressing F5 in visual studio with Web Developer server and calling with controller to print to PDF Creator works OK.

How to print from controller in server ?

    public ActionResult PrintTest()
    {
        var doc = new PrintDocument();
        doc.PrinterSettings.PrinterName = "Samsung ML-331x Series";
        doc.PrintPage += new PrintPageEventHandler(TestProvideContent);
        doc.Print();
        return new ContentResult()
        {
            Content = "Printed"
        };
    }

    public void TestProvideContent(object sender, PrintPageEventArgs e)
    {
        e.Graphics.DrawString("Test",
          new Font("Arial", 12),
          Brushes.Black,
          e.MarginBounds.Left,
          e.MarginBounds.Top);
    }

Update

Application runs at full trust Level. Application log in event viewer does not have any entries about this.

Using Programmatically "hello world" default SERVER-side printer in ASP.NET MVC I tried to use printer name with server name as \\SERVER\Samsung ML-331x Series but problem persists.

Community
  • 1
  • 1
Andrus
  • 26,339
  • 60
  • 204
  • 378

0 Answers0