Silent printing (direct) using KIOSK mode in Google Chrome

Learn silent printing (direct) using kiosk mode in google chrome with practical examples, diagrams, and best practices. Covers asp.net, google-chrome, printing development techniques with visual ex...

Achieving Silent Direct Printing with Google Chrome Kiosk Mode

Hero image for Silent printing (direct) using KIOSK mode in Google Chrome

Learn how to configure Google Chrome in Kiosk mode for silent, direct printing, ideal for ASP.NET applications and specialized printing stations.

Silent printing, especially direct to a printer without user intervention, is a common requirement for many business applications, particularly in environments like retail, healthcare, or manufacturing. When developing web applications, such as those built with ASP.NET, achieving this can be challenging due to browser security restrictions. This article explores how to leverage Google Chrome's Kiosk mode to enable silent, direct printing, providing a robust solution for these scenarios.

Understanding the Challenge of Silent Printing in Browsers

Modern web browsers prioritize user security and privacy, which includes preventing websites from directly accessing system resources like printers without explicit user consent. This is why most browser-based print operations trigger a print dialog, requiring the user to confirm the print job. While this is a crucial security feature for general browsing, it becomes an impediment for dedicated applications that require automated printing, such as point-of-sale systems or label printers driven by a web interface.

Leveraging Google Chrome Kiosk Mode for Silent Printing

Google Chrome's Kiosk mode offers a powerful solution by allowing the browser to run in a restricted, full-screen environment, often used for public terminals. Crucially, Kiosk mode can be combined with command-line arguments to bypass the print dialog and send print jobs directly to a specified printer. This makes it an excellent candidate for dedicated printing stations.

flowchart TD
    A[Start Chrome in Kiosk Mode] --> B{Load Web Application URL}
    B --> C[Web App Triggers Print Command]
    C --> D{"Chrome's --kiosk-printing Flag Active?"}
    D -- Yes --> E[Print Job Sent Directly to Default Printer]
    D -- No --> F[Print Dialog Appears (User Intervention Required)]
    E --> G[Document Prints Silently]
    F --> H[User Confirms Print]
    H --> G

Process Flow for Silent Printing in Chrome Kiosk Mode

Configuring Chrome for Silent Kiosk Printing

To achieve silent printing, you need to launch Google Chrome with specific command-line arguments. This typically involves creating a shortcut or a batch file that executes Chrome with these parameters. The key arguments are --kiosk, --kiosk-printing, and optionally --print-to-pdf if you want to save to PDF silently, or --print-to-printer="Printer Name" to specify a printer.

start chrome.exe --kiosk --kiosk-printing --print-to-printer="Your Default Printer Name" "http://localhost:12345/YourWebApp/PrintPage.aspx"

Example Batch File for Launching Chrome in Silent Kiosk Print Mode

Integrating with ASP.NET Applications

From your ASP.NET application, you can trigger the print command using JavaScript. When Chrome is running in Kiosk mode with the --kiosk-printing flag, the window.print() JavaScript function will bypass the print dialog and send the job directly to the configured printer.

<!DOCTYPE html>
<html>
<head>
    <title>Print Page</title>
    <script type="text/javascript">
        function printPage() {
            window.print();
            // Optionally, close the window after printing
            // window.close(); 
        }
    </script>
</head>
<body onload="printPage()">
    <h1>Invoice #12345</h1>
    <p>Customer: John Doe</p>
    <p>Amount: $100.00</p>
    <!-- Your print-ready content here -->
</body>
</html>

Simple HTML/JavaScript to trigger a print job from an ASP.NET page

1. Identify Your Printer Name

Go to 'Devices and Printers' (Windows) or 'Printers & Scanners' (macOS) and note the exact name of the printer you wish to use for silent printing.

2. Create a Chrome Shortcut or Batch File

Create a new shortcut to chrome.exe or a .bat file. Add the necessary command-line arguments: --kiosk, --kiosk-printing, and --print-to-printer="Your Printer Name". Specify the URL of your ASP.NET print page.

3. Develop Your ASP.NET Print Page

Create an ASP.NET page (e.g., PrintPage.aspx) that contains the content you want to print. Include a JavaScript window.print() call, ideally triggered on body.onload or after dynamic content has loaded.

4. Test the Silent Print Functionality

Execute the shortcut or batch file. Chrome should launch in full-screen Kiosk mode, navigate to your print page, and the document should print silently without any dialogs appearing.