This is probably our second-most requested tip – how do I emulate, from SSRS, the standard MEDITECH scheduled auto-print to a spooled printer functionality?
A Bad Idea
Before we show you how to auto-print to a spooled printer, you're going to get a talking to! Why? Because auto-printing to a networked printer is a bad idea:
- Unless you have locking output trays on your networked printers, scheduled printing to a device is a HIPAA violation waiting to happen. Almost any printout you have in modern healthcare contains PHI, and if someone can pick up the wrong report from a shared printer, your organization may find itself in violation without even realizing it.
- The printout is stale as soon as it’s printed. Unless the end-user reviews the report footer or header carefully to see what date/time it was printed, the user may attempt to take action using data that is hours or even days old.
- Auto-printing wastes paper and electricity, and most auto-printed reports are never used.
- Auto-printing requires more management — of the schedules controlling the auto-printing, of the print queues used to drive it, and of the printers themselves (particularly if they move, or change IP address, or are decommissioned).
It is optimal to set up all of your SSRS reports to be run on-demand by your end-users, whenever they need them. Then they only get the data when needed, it’s immediate and up-to-date, and they can act on it appropriately and at the right time. Additionally, you waste a lot less user-time, paper, electricity, and management overhead.
If a user does need a report on a schedule, it is far better to set up an SSRS Subscription that generates an Excel spreadsheet (but not recommended because Excel is insecure, corrupts data, and has row limitations that might inadvertently truncate your dataset) or PDF (better option) and delivers via email. Or, at most, to an AD-security controlled file share.
However, if none of that matters, and you still must have your scheduled, spooled printing, here’s how you can set up SSRS to auto-print to a network printer…
You Will Need:
- A Windows Server on which you can install software, set up shares, configure security, and manage the Scheduled Task Agent
- One or more printers that can handle directly printing a PDF
- SSRS Reports that can be scheduled
- Access in SSRS Report Manager to set up Subscriptions
- Confirm that the printers in question support Print-Ready PDF (or direct PDF) printing:
- Go into the printer’s control panel, print the Configuration report. Look for a Personalities section (on an HP printer) that shows PDF.
- On a Windows Server, set up a file share for each printer to which you’re going to send scheduled reports. Make sure this share has read/write permissions for the AD service account running your SSRS instance. We’ll call this the “printer control share.”
- IMPORTANT NOTE: Put these printer control shares in a folder structure that is easy to maintain with short names. No embedded spaces or parentheses, please! Something like:
Which would be shared like this:
- On the same Windows Server, confirm that it has lpr installed by reviewing this article: https://technet.microsoft.com/en-us/library/cc731857.aspx.
- Document the IP address/DNS name of each printer and the file share from which they’ll be getting files. A handy Excel spreadsheet will do for this. Or log them in your CMDB.
- If the DNS host names of the printers are not short (8 characters at most), this is a good time to make them short and sweet.
- In each printer control share folder, create this very simple batch file as (printername).cmd
FOR %%f IN (*.pdf) DO (lpr -S printerdnsname -P auto %%f & del %%f)
- Where you replace printerdnsname with the printer DNS name you documented. So if my printer was named “Scribe” on the network, I might have this printer control share:
Which is this folder on the QueueServer:
Where that folder contains this command file:
Containing this text:
FOR %%f IN (*.pdf) DO (lpr -S scribe -P auto %%f & del %%f)
- Now find some short PDF files and put them into your printer control share.
- Run the .cmd file from the command prompt, in the printer control share.
- If your printer supports Direct-PDF/Print-Ready printing, all of the PDFs should print out, in order, on the printer.
IMPORTANT NOTE: This batch command file is super simple. For each PDF, send it via lpr to the printer, then delete the file afterwards. If you’re a DOS batch command language wizard (and yes, such people exist…), I am certain you can improve it.
- Alternatively, if you already have a Windows Server acting as a Print Manager, where each of your PDF-capable printers has a printer queue already set up, then you can use this for your batch command instead:
FOR %%f IN (*.pdf) DO ( move %%f \\printserver\queue )
- Which will have the same effect.
- Now that we’ve confirmed the printer can handle a set of files dispatched to it via lpr or move, we need to set up a Scheduled Task to fire up this command file on a regular basis:
- Go to Start > Administrative Tools > Task Scheduler (or whichever path works on your server).
- Under Actions, click Create Task. (We don’t want a Basic Task because, well… it’s too basic!)
- Provide a suitable Name, like “Scheduled printing on Scribe.”
- Add the path to the Excel or CMDB or wiki entry that documents your scheduling printing setup to the Description.
- The Security settings may be problematic for you, depending on your AD setup and any GPOs that may be in place. However, you do need to “Run whether user is logged in or not,” and you may need to run with “Highest Privileges.”
- On the Triggers tab, click New.
- Under “Settings,” choose Daily.
- Set the “Start Time” to 12:00:00 AM.
- Under Advanced Settings, set the Task to “Repeat Task” every 15 Minutes, for a duration of 15 minutes.
- IMPORTANT NOTE: If you want the task to run more often than every 15 minutes, you can (after picking 15 Minutes from the drop-down list) change the number in the field to 10 or 5, as you please.
- Also set the “Stop Task if runs longer than” to 15 minutes (by picking 30 Minutes, and then editing the entry).
- Make sure the Enabled checkbox is checked.
- Click OK to add the Trigger.
- Now click on the Actions tab.
- Click New.
- Choose Start a Program for the Action field.
- Browse to the .cmd file for this particular printer schedule (in our example, it would be the scribe.cmd in the \\QueueServer\Printers\Scribe share folder, whatever folder that is…).
- Set the Start In field to be your printer control share folder, like this: D:\Printers\Scribe\
- Click OK.
- Click on the Settings tab.
- You want to make sure the following settings are check marked:
- Allow task to be run on demand.
- Stop the task if it runs longer than 1 hour.
- If the running task does not end when requested, force it to stop.
- If the task is already running, then the following rule applies: Do not start a new instance.
- Now – finally – you can set up a Subscription in SSRS to fire off a report as a PDF and drop it into your printer control share.
- In Report Manager, switch to Detail View.
- Find the Report you want to schedule. Then click on the Properties icon on the left side of the listing.
- Once the report properties have opened, click on the Subscriptions tab.
- Set the Delivered By field to Windows File Share.
- Enter the Path for the file to drop to — this will be the printer control share (as the UNC path version) — that you documented above.
- Enter the Credentials used to access the file share, if you have not already set the file share to be accessed (read/write) by the AD service account running SSRS on the Report Manager server.
- Set the Overwrite option to Increment File Names as newer versions are added.
- In the Subscription Processing Options section, set the schedule you want to use for report generation by clicking the Select Schedule button.
- In the Report Parameter Values section, fill in the parameters you need. Note that if you’ve got Date parameters, you need to either (A) set up each and every date range as a separate subscription, or (B) set up MEDITECH-style date mnemonics in your Report. See this Iatric Systems RWS Blog tip for how to do that.
- Click OK to save your subscription.
- Test the subscription! Generate some PDFs into the printer control share; confirm they print!
- Have two lattes.
- Getting security permissions correct for all of this will be the biggest hurdle.
- Second will be getting your Task Scheduler set up properly.
- Finally, dealing with the timing of how often the print job runs.
For more information, please contact Karen Roemer at 978.805.3142 or email email@example.com.