I have a client who would like to automatically print documents in Laserfiche. From this Forum thread from 2007, it appears impossible because Microsoft doesn't support unattended printing (https://support.laserfiche.com/ForumsFrames.aspx?Link=viewtopic.php%3ft%3d9644%26amp%3bhighlight%3dprint%2bunattended%26amp) . I just wanted to confirm that this is the case still or see if anyone has done something like this. It doesn't seem like a great idea to have unattended printing in the event something goes wrong and thousands of pages get printed, but just thought I would see.
Question
Question
Want to confirm it's not possible to automatically print using the SDK because Microsoft doesn't support unattended printing?
Replies
Documents can be printed automatically using the Client Automation Tools library included in the Laserfiche SDK (version 9 and later). The documentation covers the calls in detail, but I recommend looking at the MainWindow.PrintById method.
Your concerns are all very valid, however; I'd keep a careful eye on what's being printed automatically, lest you accidentally print much more than you intended to.
Hey Zach,
What if I want to print automatically from Workflow? Would I need to create a web service or something?
That's the part of unattended printing that's not likely to work. You can call CAT or a web service from WF to print, but if your application puts up any messages (for ex, Word saying that the page is outside the printing margins), there's nobody to see those, so the whole print queue will be stuck.
Awesome, thanks Zach!
Hi Zachary,
Would it be possible to post some sample code to help get us started with CAT? I want to be able to select an entry in the Client window, then have a custom button on the toolbar that the user uses to print the selected entry.
In addition to getting this right, I will then add additional code to execute other tasks as a result of pressing this custom button.
I intend to remove the standard Print Icon from the toolbar and use my own.
Thanks
Sheldon
Sample code for using CAT is installed with the SDK project - There should be a couple zips under the Program Files\Laserfiche\SDK\Samples that, when opened, contain various sample projects in different languages. I'm pretty sure the CAT ones have examples of adding custom toolbar buttons.
Hi Justin,
Thanks for the info. I am aware of these sample projects, which are very helpful. Perhaps I should rephrase my initial question.
I simply want to print a selected entry from the LF Client.
How do I use MainWindow.PrintById ?
Thanks
Sheldon
The generic framework can look something like:
using (ClientManager lfclient = new ClientManager()) { // Set some print options in preparation for later. PrintOptions printoptions = new PrintOptions(); // Print entire document. Laserfiche.ClientAutomation.PageSet pages = new Laserfiche.ClientAutomation.PageSet(); printoptions.PageNumbers = pages; printoptions.DoNotPrompt = false; printoptions.DocumentPart = PrintType.Images; // Here we're assuming that there's at least 1 instance of the // Client already open. IList<ClientInstance> OpenLFClients = lfclient.GetAllClientInstances(); // Use the first one CAT finds and log in to the desired // repository. ClientInstance singleLF = OpenLFClients[0]; LaunchOptions options = new LaunchOptions(); options.ServerName = "myserver"; options.RepositoryName = "myrepository"; MainWindow FolderBrowser; singleLF = lfclient.LogIn(options, out FolderBrowser); // Get a list of entry ids of what's selected in the // folder browser. IList<int> selectedDocIds = FolderBrowser.GetSelectedEntries(); // Print the first selected entry. Hopefully, it's a document. FolderBrowser.PrintById(selectedDocIds[0], printoptions); }