-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi
I am using the Following Code in MVVM to list the client side printers. But it always shows the printer list on the server.
import javax.print.PrintService;
PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
// Get the printer name
for(int i=0;i<services.length;i++)
{
String name = services[0].getName();
System.out.println("printer="+name);
}
My goal is client has installed zebra LP 2824 PLUS barcode PRINTER and i want to print 3 lines of text in that such as first Name, last Name, DOB
Hi Senthil,
that's exactly what should happen if you execute java code on the server side, you'll get the printers available on the server side.
If you want to print on the client side, you need to use java script to print on the client side. For example you could render the text to be printed into an iframe and call the javascript print() function.
Robert
Robert.
Can you please give me example code with OUT using zscript in zul . Because all examples using zscript, but in my project we have disabled that option and we are using MVVM.
Ok
Let me explain.
1.I need to print three lines (First Name, Last Name and Middle Name) in the small printer. You can see the printer here
Here is my sample zul file
<zk>
<window title="Print Whole Page" border="normal" apply="org.zkoss.bind.BindComposer"
viewModel="@id('vm') @init('com.product.webapp.main.PrintVM')">
First Name
<separator></separator>
Last Name
<separator></separator>
Middle Name
<separator></separator>
</window>
</zk>
package com.product.webapp.main;
import org.zkoss.bind.annotation.AfterCompose; import org.zkoss.bind.annotation.ContextParam; import org.zkoss.bind.annotation.ContextType; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.util.Clients;
public class PrintVM {
@AfterCompose
public void initSetup(@ContextParam(ContextType.VIEW) Component view) {
Clients.print(); // fire the printdialog
Clients.evalJavaScript("window.close()"); // close the printwindow
}
}
It is printing, but in the top it prints the URL and date at the bottom
I just want to print that three lines in that small printer as label. so that user take that and label in the lab speciman
ok then the answer is simple... if the default browser printing functionality is not what you need, then you need some kind of browser plugin or JS extension, that can print in the format you need. There is nothing ZK can help with. If you can point to a JS API that's accessing your printer as you expect I surely can help how to call this JS function to print as you like.
Yes thank you darksu. It works
Asked: 2015-01-29 04:34:53 +0800
Seen: 41 times
Last updated: Feb 02 '15