0

I have an application that writes SSRS reports as a PDF to a file directory and I would like each time a report is added to the folder for it to be printed to a specific network printer. The reports are generated using the SQL SSRS web service.

This folder and application is on a server and I cannot use Adobes silent printing to accomplish this. Does anyone have any advice?

Thanks.

1
  • Look up the Win32 Print Spooler API. You'll have to use platform invoke to call these native functions from C#. Commented Mar 14, 2016 at 18:58

2 Answers 2

1

You could try sending your document as raw or you might be able to convert your file to a stream and send it to your printer using TcpClient.

Sign up to request clarification or add additional context in comments.

Comments

1

Realized I left this question unanswered and wanted to give a followup in case anyone else encounters this problem. I ended up using the code from the answer found here...

Print a ReportViewer Without Preview

I was able to create the reports using my web service and put them into a report viewer and then simply pass the report and the printer I wanted to print to as parameters to the code above and it handled the printing for me. The only thing I did was extend the functionality to accept a printer name as a parameter and use assign that as the specified printer that I wanted to print to.

Here is some sample code in case anyone wants to see the general flow I used.

List<ReportParameter> reportparms = new List<ReportParameter>();

ServerReport rpt = new ServerReport();
reportparms.Add(new ReportParameter("param1", param1));
rpt.ReportServerUrl = reportserver;
rpt.ReportPath = myReportPath;
rpt.SetParameters(reportparms);

//I created a class "ReportPrintDocument" for the code from the question linked above.
ReportPrintDocument rdp = new ReportPrintDocument(rpt, myPrinter);
rdp.PrinterSettings.PrinterName = ps.Printer;

if (p.PrinterSettings.IsValid)
{
    rdp.Print();
}

There is some other logic here and there but that is the basic idea that will get the job done.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.