Printing a Local Report without Preview

Mohamed Sediq 0 Reputation points
2025-04-30T08:42:21.9333333+00:00

dear all

I using visual studio 2022 with MVC NET 8 and C# language and Microsoft reporting service 2016.

I want to print an invoice without displaying the report based on its type, for example: cash payment or home delivery.

Both invoices have different data. A print button has been created in the invoice, and clicking it selects the type of invoice to print. To implement the On Click using JavaScript, use JavaScript.

Is there a better way than using JavaScript to print the report based on the report type?

An attempt to execute this code will display the report.

 <button id="Print" onclick="printReport()" style="float : right" type="button">Print </button>

    <script>         function printReport() {         
         var reportUrl = "http://MyName/ReportServer/report/POS/InvoiceSale?						           [email protected]&rs:Command=Render&rs:Format=PDF&rs:Toolbar=none&rc:Parameters=Collapsed";         var printWindow = window.open(reportUrl, "_blank");
        printWindow.onload = function () {
            printWindow.print();
        };
    }
    </script>

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,431 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.