Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am using the below code for printing documents in ASP.NET. But the concern here is it is printing on the server not on client side. I want to print the documents on client machine.

C#
void PrintFiles()
    {
       ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.UseShellExecute = true;
        Process p = new Process();//Create new process for printing
        startInfo.Verb = "PRINT";//print command to execute
        startInfo.CreateNoWindow = true;//supress the print dialog.
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        string path = Server.MapPath("~/Documents/");
        //Get all the files from the Directory in string array
        string[] docFiles = Directory.GetFiles(path);
        //Loop through the files
        for (int count = 0; count < docFiles.Length; count++)
        {
            startInfo.FileName = docFiles[count]; //document to print
            p.StartInfo = startInfo; //Associate the print command and the filename to print with the process.
            p.Start();//Start printing.
        }
        p.Dispose();

    }
Posted
Comments
Sharma Richa 19-Jul-14 15:52pm    
I am also facing same issue. I you had got some resolution then please share.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900