We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: PdfViewer

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.

C#

//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.
view.PrintDocument.Print();

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

C#

//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();
    fileStream.CopyTo(memoryStream);
    byte[] byteArray = memoryStream.ToArray();
    //Call the PrintService method in the service with filestream array as the parameter.
    client.PrintService(byteArray);
}

Sample Link:

https://www.syncfusion.com/downloads/support/directtrac/general/PdfViewerWeb281456998.zip

 

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile