Print Report Without Preview

Mohamed Sediq 0 Reputation points
2025-04-30T09:36:39.13+00:00

I using visual studio 2022 with MVC NET 8 and C# , JavaScript 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.

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



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

<script>
    function printReport() {
    alert('Printing');
    var reportUrl = "http://MyName/ReportServer/report/POS/[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

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 75,051 Reputation points
    2025-04-30T15:43:44.5966667+00:00

    not really. window.print(), only works with a loaded document. the other option is to download a pdf, but then the browser just displays with a registered pdf tool, print is still a separate option.

    0 comments No comments

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.