I'm running chrome in headless mode using selenium for python.
--kiosk-printing
argument is added to skip print preview
Everything is working fine except for printing.
This is how I start chrome
from selenium import webdriver
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--window-size=1280,720')
chrome_options.add_argument('--kiosk-printing')
driver = webdriver.Chrome(chrome_options=chrome_options)
Then I load my html to chrome
driver.get("https://localhost:5007/test_print.html")
The html has window.print()
method
<html>
<head>
<title>Test Printing</title>
</head>
<body>
<h1>Test Test Test</h1>
</body>
<script>
window.print();
</script>
</html>
This works when I remove headless option and keep selenium in the screen. So my question is 'IS THERE ANY WAY TO PRINT A DOCUMENT IN CHROME HEADLESS MODE?'
My purpose is to print a bill in a kiosk. My main webapp is on chrome kiosk mode. First I just loaded the bill to a hidden iframe but it shows the print preview for a less than one second which distracts user from the app. I want to print my bill 100% silently in a kiosk.
question from:
https://stackoverflow.com/questions/65931073/print-to-default-printer-in-chrome-headless-mode 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…