Articles in this section
Category / Section

How to silent print the PDF document in the ASP.NET Classic by using Service?

1 min read

At present, there is no support for silent printing of the PDF document in the ASP.NET. However, you can achieve this by a workaround by using PdfViewer.Windows dll. In the following example, a Service reference is created and the PDF document is printed silently through the default printer.


//Create an instance of PdfDocumentView.
PdfDocumentView view = new PdfDocumentView();
//Load the document in the viewer as stream.
view.Load(new MemoryStream(filestreamarray));
//Silently print the document through the default printer.

The following code example in Default.aspx.cs accesses the PrintService method in the Service reference.


//Create an object reference for the Serviceclient.
var client = new ServiceReference1.Service1Client("BasicHttpBinding_Service1");
if (System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName).Equals(".pdf"))
    //Get the stream of the file uploaded.
    Stream fileStream = FileUpload1.PostedFile.InputStream as Stream;
    MemoryStream memoryStream = new MemoryStream();
    byte[] byteArray = memoryStream.ToArray();
    //Call the PrintService method in the service with filestream array as the parameter.

Sample Link:


Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied