Hi All,
We have two requirements :-
- We need a script to lock the document versions in the contract document once a contract document is approved.
- We need a button to print the contract document .
For the print button functionality, we have written a script, but we are not able to get the network printers and thus tthe code is dumping.
Script is :-
import com.sap.custom.clmprinter;
import javax.print.*;
import javax.print.attribute.*;
//printer = new clmprinter();
ver = doc.getDocVersions();
if(hasValue(ver))
{
iter = ver.iterator();
while(iter.hasNext())
{
member = iter.next();
document = member.getDoc();
}
}
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
services = PrintServiceLookup.lookupPrintServices(flavor, aset);
if (services[0] != null)
{
DocPrintJob job = null;
String printer = "Printer Name";
for(int i = 0; i < services.length;i++)
{
if(services[i].getName().equalsIgnoreCase(printer))
{
job = services[i].createPrintJob(); // here we are not getting the printers on network
}
}
if(job == null)
{
job = services[0].createPrintJob();
}
InputStream b = new BufferedInputStream(new FileInputStream(document.getFileData((SessionContextIfc) session)));
Doc document = new SimpleDoc(b, flavor, null);
job.print(document, aset);
}
Is there any configurations whichneeds to be done to get the printers or any other thing missed in the coding that should be taken care.
Also any suggestions on the 1st requirement?
Regards,
Puneet Arora