<p>I'm working on a web application that needs to prints silently -- that is without user involvement.  What's the best way to accomplish this?  It doesn't like it can be done with strictly with Javascript, nor Flash and/or AIR.  The closest I've seen involves a Java applet.</p>

<p>I can understand why it would a Bad Idea for just any website to be able to do this.  This specific instance is for an internal application, and it's perfectly acceptable if the user needs to add the URL to a trusted site list, install an addon, etc.</p>

[{'answer_id': 21916, 'author': 'Rob Cooper', 'author_id': 832, 'author_profile': 'https://Stackoverflow.com/users/832', 'pm_score': 0, 'selected': False, 'text': '<p>I have to be honest, I am kinda thinking out loud here.. But could it not be done with  an applet or some sort (be it Java or whatever) that is given trusted permissions (such as that within the Intranet zone) or something?</p>\n\n<p>May be worth investigating what permissions can be given to each zone?</p>\n\n<p>Following a Google, I think you definately have a challenge, so far most of the articles I have seen involve printing to <a href="http://aspalliance.com/462" rel="nofollow noreferrer">printers connected to the server</a>.</p>\n\n<p>If its internal, would it be possible to route printing from the server to department/user printers or something?</p>\n'}, {'answer_id': 21918, 'author': 'Christopher Mahan', 'author_id': 479, 'author_profile': 'https://Stackoverflow.com/users/479', 'pm_score': 2, 'selected': False, 'text': '<p>I wrote a python tsr that polled the server every so often (it pulled its polling frequency from the server) and would print out to label printer. Was relatively nice. </p>\n\n<p>Once written in python, I used py2exe on it, then inno setup compiler, then put on intranet and had user install it. </p>\n\n<p>It was not great, but it worked. Users would launch it in the morning, and the program would receive the kill switch from the server at night.</p>\n'}, {'answer_id': 21924, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 3, 'selected': False, 'text': '<p>Here are two code samples you can try:</p>\n\n<p><strong>1</strong>:</p>\n\n<pre><code>&lt;script&gt;\nfunction Print() {\n  alert ("THUD.. another tree bites the dust!")\n  if (document.layers)\n  {\n    window.print();\n  }\n  else if (document.all)\n  {\n    WebBrowser1.ExecWB(6, 1);\n    //use 6, 1 to prompt the print dialog or 6, 6 to omit it\n    //some websites also indicate that 6,2 should be used to omit the box\n    WebBrowser1.outerHTML = "";\n  }\n}\n&lt;/script&gt;\n&lt;object ID="WebBrowser1" WIDTH="0" HEIGHT="0"\nCLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"&gt;\n&lt;/object&gt;\n</code></pre>\n\n<p><strong>2</strong>:</p>\n\n<pre><code>if (navigator.appName == "Microsoft Internet Explorer")\n{ \n  var PrintCommand = \'&lt;object ID="PrintCommandObject" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"&gt;&lt;/object&gt;\';\n  document.body.insertAdjacentHTML(\'beforeEnd\', PrintCommand); \n  PrintCommandObject.ExecWB(6, -1); PrintCommandObject.outerHTML = ""; \n} \nelse { \n  window.print();\n} \n</code></pre>\n\n<p>You may need to add the site/page you are testing on to you local intranet zone.</p>\n'}, {'answer_id': 21982, 'author': 'Vaibhav', 'author_id': 380, 'author_profile': 'https://Stackoverflow.com/users/380', 'pm_score': 0, 'selected': False, 'text': '<p>If it is just an internal application, then you can avoid printing from the browser, and send a printout directly from the server to the nearest printer to the user.</p>\n'}, {'answer_id': 682483, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 5, 'selected': False, 'text': '<p>Here’s what you need to do to enable Firefox immediately print without showing the print preferences dialog box.</p>\n\n<ol>\n<li><p>Type about:config at Firefox’s location bar and hit Enter.</p></li>\n<li><p>Right click at anywhere on the page and select New > Boolean</p></li>\n<li><p>Enter the preference name as print.always_print_silent and click OK.</p></li>\n</ol>\n\n<hr>\n\n<p>I found that somewhere and it helped me</p>\n'}, {'answer_id': 4220615, 'author': 'Jef S.', 'author_id': 512871, 'author_profile': 'https://Stackoverflow.com/users/512871', 'pm_score': 1, 'selected': False, 'text': '<p>I have it working all day long using a simple JSP page and the Java PDF Renderer library (https://pdf-renderer.dev.java.net).  This works because Java prints using the OS and not the browser.  Supposedly "silent printing" is considered a browser vulnerability/exploit and was patched after IE 6 so good luck getting it to work via Javascript or Active X. Maybe its possible but I couldn\'t get it to work without Java.</p>\n'}, {'answer_id': 9335118, 'author': 'auledoom', 'author_id': 1075751, 'author_profile': 'https://Stackoverflow.com/users/1075751', 'pm_score': 0, 'selected': False, 'text': '<p>I\'m on the same issue here, this is what i learn so far. </p>\n\n<p>A.: You need to setup an IPP PrintServer</p>\n\n<p>You have multiple print server implementations you may try.</p>\n\n<ol>\n<li><p>Hardware IPP print server: like DLINK DPR-1020 or similar, some printer have this functionality builtin.</p></li>\n<li><p>Linux server with CUPPS : <a href="http://www.howtoforge.com/ipp_based_print_server_cups" rel="nofollow">http://www.howtoforge.com/ipp_based_print_server_cups</a></p></li>\n<li><p>XP-Pro server with ISS: <a href="http://www.michaelphipps.com/ipp-print-server-windows-xp-solution" rel="nofollow">http://www.michaelphipps.com/ipp-print-server-windows-xp-solution</a></p></li>\n</ol>\n\n<p>B.: You need to make your WebApp a client of this IPP Server so you pick-process-send every user\'s print request to the PrintServer.</p>\n\n<p>PHP::PRINT::IPP is a php lib you may try (it\'s well tested on cups servers).</p>\n'}, {'answer_id': 14943756, 'author': 'Iannazzi', 'author_id': 1303144, 'author_profile': 'https://Stackoverflow.com/users/1303144', 'pm_score': 3, 'selected': False, 'text': '<p>We struggled with a similar problem. We needed to print checks to a check printer, labels to a label printer, and customer invoices to an invoice printer for retail store <a href="http://embrasse-moi.com" rel="noreferrer">embrasse-moi</a>. We have dummy computers, nooks, ipads, iphones with no printing capabilities. The printing an invoice feature was basically a silent print. A pdf was written to the server, and a shell script was used locally to retrieve it and print.</p>\n\n<p>We used the following for a perfect solution with minimal libraries: </p>\n\n<ol>\n<li><p>use TCPDF in PHP to create PDF. Store the PDF on the server. Put it in a \'Print Queue\' Folder. Kudos for TCPDF, a bit difficult to learn, but SICK SICK SICK. Note we are printing 80 labels per page using avery 5167 with a bar code with perfect accuracy. We have a labels, check, and invoice print queue. Different folders basically for different printers.</p></li>\n<li><p>Use the included shell script to connect to the server via FTP, download the PDF, delete the PDF off the server, send the PDF to the printer, and again, delete the PDF.</p></li>\n<li><p>Using a local computer attached to the printer, run the script in terminal. obviously modify your printers and paths.</p></li>\n<li><p>Because you always want this running, and because you use a MAC, create an \'app\' using automator. Start automator, put the script in a \'run shell script\' and save. Then stick that app in a login item. See the script below the shell script if you want to see the \'output\' window on the MAC.</p></li>\n</ol>\n\n<p>BAM - works sick.</p>\n\n<p>Here is the shell script</p>\n\n<pre><code>#!/bin/bash\n\n# Get a remote directory Folder\n# List the contents every second\n# Copy the files to a local folder\n# delete the file from server\n# send the file to a printer\n# delete the file\n# compliments of embrasse-moi.com\n\n\nclear               # clear terminal window\n\necho "##########################################"\necho "Embrasse-Moi\'s Remote Print Queue Script"\necho "##########################################"\n\n#Local Print Queue Directory\nCOPY_TO_DIRECTORY=/volumes/DATA/test/\necho "Local Directory: $COPY_TO_DIRECTORY"\n#Priter\nPRINTER=\'Brother_MFC_7820N\'\necho "Printer Name: $PRINTER"\n\n#FTP Info\nUSER="user"\nPASS="pass"\nHOST="ftp.yourserver.com"\n#remote path\nCOPY_REMOTE_DIRECTORY_FILES=/path\necho "Remote Print Queue Directory: $HOST$COPY_REMOTE_DIRECTORY_FILES"\n\necho \'Entering Repeating Loop\'\nwhile true;  do\n\n    #make the copy to directory if not exist\n    echo "Making Directory If it Does Not Exist"\n    mkdir -p $COPY_TO_DIRECTORY\n    cd $COPY_TO_DIRECTORY\n\n    ######################### WGET ATTEMPTS ############################################\n    #NOTE wget will need to be installed\n    echo "NOT Using wget to retrieve remote files..."\n\n    # wget --tries=45 -o log --ftp-user=$USER --ftp-password=$PASS ftp://ftp.yourserver.com$COPY_REMOTE_DIRECTORY_FILES/*.pdf\n\n    ######################### FTP ATTEMPTS ############################################\n    echo "NOT Using ftp to retrieve and delete remote files..."\n    #This seems to fail at mget, plus not sure how to delete file or loop through files\n    ftp -n $HOST &lt;&lt;END_SCRIPT\n    quote USER $USER\n    quote PASS $PASS\n    cd $COPY_REMOTE_DIRECTORY_FILES\n    ls\n    prompt\n    mget *\n    mdel *\nEND_SCRIPT\n\n\n    echo "Examining Files in $COPY_TO_DIRECTORY"\n    for f in $COPY_TO_DIRECTORY/*.pdf\n    do\n      # take action on each file. $f store current file name      \n      #print\n      echo "Printing File: $f To: $PRINTER"\n      lpr -P $PRINTER $f\n\n      # This will remove the file.....\n      echo "Deleting File: $f"\n      rm "$f"\n    done\n    echo "Script Complete... now repeat until killed..."\n    sleep 5\ndone\n</code></pre>\n\n<p>and the automator script if you want to see output, keep the app with the script\nchoose a run apple script option:</p>\n\n<pre><code>on run {input, parameters}\n\n    tell application "Finder" to get folder of (path to me) as Unicode text\n    set workingDir to POSIX path of result\n    tell application "Terminal"\n            do script "sh " &amp; "\'" &amp; workingDir &amp; "script1.sh" &amp; "\'"\n\n    end tell\n\n    return input\nend run\n</code></pre>\n'}, {'answer_id': 26598148, 'author': 'user1912424', 'author_id': 1912424, 'author_profile': 'https://Stackoverflow.com/users/1912424', 'pm_score': 0, 'selected': False, 'text': '<p>You should have a look at <a href="http://www.printnode.com" rel="nofollow">PrintNode</a>.  They provide a silent remote printing services for web applications.  You install a piece of software on the desktop which syncs to their servers.  You can then send printjobs using an json request and they are instantly printed out.</p>\n'}, {'answer_id': 30038360, 'author': 'Cedric', 'author_id': 310923, 'author_profile': 'https://Stackoverflow.com/users/310923', 'pm_score': 4, 'selected': False, 'text': '<p>As @Axel wrote, Firefox has the print.always_print_silent option.</p>\n\n<p>For Chrome, use the <code>--kiosk-printing</code> option to skip the Print Preview dialog:</p>\n\n<p>Edit the shortcut you use to start Chrome and add "--kiosk-printing" then restart Chrome. </p>\n\n<p>Note: If it doesn\'t work it is most likely because you did not completely stop Chrome, logging out and back in will surely do the trick.</p>\n'}, {'answer_id': 38715833, 'author': 'Nige', 'author_id': 6666771, 'author_profile': 'https://Stackoverflow.com/users/6666771', 'pm_score': 2, 'selected': False, 'text': '<p>I know this is an older thread, but it\'s still the top Google search for \'silent printing\' so I\'ll add my findings for the benefit of anyone coming across this now.</p>\n\n<p>We had a similar issue with printing labels of various types to various printers for a stocksystem.  It took some trial and error, but we got around it by having the system create a pdf of the labels, with printer name and page qty\'s encoded in the pdf.  All you then have to do is:\nIN IE, go to Internet Options >> Security >> Trusted Sites  >> Sites\nClear \'Require server verification (https:) for all sites in this zone\'\nadd "<a href="http://[yoururl]" rel="nofollow">http://[yoururl]</a>"\nand the pdf will print out automatically.</p>\n\n<p>When we originally set this up we were using Chrome as the default browser, but in September 2015, Chrome dropped the ability to run NPAPI plugins.  This meant that you could no longer select the Adobe pdf plugin as the default pdf handler, and the built in pdf plugin does not handle silent printing :-(\nIt does still work in Internet Explorer (IE11 at time of writing) but I\'ve not tried any other browsers.</p>\n\n<p>HTH\nCheers,\nNige</p>\n'}]
['https://Stackoverflow.com/questions/21908', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/181/']