There are certain scenarios when user may request for printing of reports without opening the report when the report content is quite huge on click of button.I was not able to find any OOB business service which prints BIP report on client machine. There is business service for actuate report that does printing task but that can't be used for BIP reports. One of the alternate way to print BIP reports without opening them is to fetch content of report in the code using shell and fire verbex print. Please find below the code snippet to achieve this. This can be used for silent printing for any document.
function WebApplet_PreInvokeMethod (MethodName)
{
if(MethodName == "Printer")
{
var TargetFolder = "D:\Program Files\Siebel8\Files"; //This is the folder name where report document is kept
var oShell = COMCreateObject("Shell.Application"); //Creating Shell
var objFolder = oShell.Namespace(TargetFolder);
var objItem = objFolder.ParseName("AccountListReport.rtf"); //Name of the document to print
objItem.InvokeVerbEx("Print") // Print without opening the document
return(CancelOperation);
}
return (ContinueOperation);
}
The key here is InvokeVerbx method. The Shell object has a method called InvokeVerbEx that allow us perform the tasks that show up when we do right-click a file in Windows Explorer. Following options could be used with this method Open, Print, Edit, Cut, Copy, Delete, etc. The Shell object allows us to perform all those tasks programmatically.
Happy Printing!!
7 comments:
One small thing, before designing ensure that the production servers don't run on UNIX or there is no short term plan of migrating to UNIX as COM objects are specific to Windows platform.
Hi,
We had a similar requirement, the only question is where to define the printer if we are having 3 printers configured to a machine?
Hey Ishan,
This will take default printer set to your machine. However there is a business service(for actuate reports) which have a input parameter which accepts printer name.
Regards,
-Rahul-
Thanks a lot rahul..
But to be more precise our requirement is to print a document present in the file system and not for actuate reports with a click of a button. I tried this in my local and its not working. Do we need to unable any component or so.?
We don't have to enable anything for this. It is as good as doing right click and firing print command.
Your local may hang if file or folder is not properly fetched. Enable some logging to capture it which step exactly it is out. What is the format of file in question?
Atually the file which we need to print is present in the Att folder of the server, its a word document.
Ishan you need to enable debugging for that and identify where it is failing...either in getting directory or printing file...
Post a Comment