on 10-24-2005 7:36 AM
Hi All,
I want to Print (Hard Copy) of my context Data,ie
I want to print data on local printer .
I tried by lots of ways but i could't get succes.
one of the way is that
One blank text file is copied to projects src/mime/component
folder and write the context data to that file.then send that file to printer,reading and writing of the file is woking fine but can't get the printout.
**Used Code**
public void onActionPrintData(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionPrintData(ServerEvent)
// method to print a file from the server
// a empty text file is created in src
mimes
Components
<package name>\<filename>
// the context data is written to this file in an event and then the file is directed towards the printer
try {
// creating a copy of the file on the server
File obj = new File("temp
webdynpro
web
local
TestTableEdit
Components
com.gpk.examples.testtableedit.TestTableEditApp
printData.txt");
FileWriter obj1 = new FileWriter(obj);
// looping through the context data.
obj1.write("Account Number");
obj1.write("\t");
obj1.write("Name of The Account Holder");
obj1.write("\t");
obj1.write("Available Balance");
obj1.write("\n");
for (int i = 0;i < wdContext.nodeResultAllAccountDetails().size();i++) {
obj1.write(wdContext.nodeResultAllAccountDetails().getResultAllAccountDetailsElementAt(i)
.getAccountNumber());
obj1.write("\t");
obj1.write(
wdContext
.nodeResultAllAccountDetails()
.getResultAllAccountDetailsElementAt(i)
.getName());
obj1.write("\t");
obj1.write(
wdContext.nodeResultAllAccountDetails()
.getResultAllAccountDetailsElementAt(i)
.getBalance()+ "");
obj1.write("\n");
}
obj1.close();
//reading the file
File obj5 =new File("temp
webdynpro
web
local
TestTableEdit
Components
com.gpk.examples.testtableedit.TestTableEditApp
printData.txt");
java.io.FileReader obj3 = new java.io.FileReader(obj5);
int count = (int) obj5.length();
char obj4[] = new char[count];
obj3.read(obj4);
wdContext.currentContextElement().setReadData(new String(obj4));
obj3.close();
} catch (Exception e) {
e.printStackTrace();
}
//*Printing Code*
FileInputStream psstream = null;
try {
psstream =new FileInputStream("temp
webdynpro
web
local
TestTableEdit
Components
com.gpk.examples.testtableedit.TestTableEditApp
printData.txt");
} catch (FileNotFoundException ffne) {
}
if (psstream == null) {
return;
}
DocFlavor psInFormat = DocFlavor.INPUT_STREAM.TEXT_PLAIN_HOST ;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new Copies(1));
Doc myDoc = new SimpleDoc (psstream,psInFormat,null);
wdComponentAPI.getMessageManager().reportSuccess(myDoc.toString());
PrintService services = PrintServiceLookup.lookupDefaultPrintService();
PrintServiceLookup.lookupPrintServices(psInFormat, aset);
if (services.length > 0) {
DocPrintJob job = services.createPrintJob() ;
try {
job.print(myDoc, aset);
} catch (PrintException pe) {
}
}
//@@end
}
Its an uregent.
Plz Help me.
Thanx,
Sanjay
As far as I know printing is not supported in WebDynpro. Not sure about the new releases . However some people do it through javaScripts but won't be of much help in the further releases.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
helo Sanjay,
As far as i know there is no functinality to print(on paper) through webdynpro application. the most u can do is to create a J2EE application that can print the contents from a file, as soon as it is called.
now on clicking the button to print the contents, u can call the J2EE application in the exit plug or in an external window.
Regards,
Piyush.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.