0

Printer List

asked 2015-01-29 04:34:53 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

updated 2015-01-29 06:17:44 +0800

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

delete flag offensive retag edit

6 Answers

Sort by ยป oldest newest most voted
1

answered 2015-02-01 23:24:29 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Senthilchettyin,

At the print dialogue of the web browser you can set margins to none. This will remove the date and the url (Tested with Chrome).

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2015-01-29 06:50:59 +0800

cor3000 gravatar image cor3000
4351 2 7
ZK Team

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

link publish delete flag offensive edit
0

answered 2015-01-29 06:59:01 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

updated 2015-01-29 06:59:23 +0800

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.

link publish delete flag offensive edit

Comments

in principle there is no difference in zcript and java code (MVVM or MVC), both are executed on the server side. And anything possible in a zscript can be done in MVC or MVVM too. so please show the example with zscript you cannot transform into MVVM code.

cor3000 ( 2015-01-29 07:03:36 +0800 )edit
0

answered 2015-01-29 07:13:27 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

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

image description

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

link publish delete flag offensive edit
0

answered 2015-01-29 07:59:10 +0800

cor3000 gravatar image cor3000
4351 2 7
ZK Team

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.

link publish delete flag offensive edit
0

answered 2015-02-02 00:48:31 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

Yes thank you darksu. It works

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2015-01-29 04:34:53 +0800

Seen: 39 times

Last updated: Feb 02 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More