All, I am trying to look for some solution to print the data in the webpage silently,
the printer type is Datamax e-4205A Label Printer, But so far I am stuck with it , Any Idea?
Any way , Is it possible to program an Activex control based on the printer API? thanks.
Related
I've been trying to find something on the web but was unable to find anything that can help me with my issue.
I need to send content of JFXTreeTableView to printer to print it. Any help appreciated. I can even use ArrayList<Object> as a data source to print so don't stick to the table.
Sorry for the long winded question, I've spent a few days trying to figure this out and have so far found dozens of ways not to solve my problem.
I'm currently trying to use a Datamax O'Neill E Class Mark 3 printer to print some labels. The java application that generates the label data cannot be easily modified, and simply outputs plain text via a built in "print" function (output example below)
Unit name [LF]
Unit description [LF]
Quantity
When I print to a Ricoh printer it works (using CR+LF replacement in the Ricoh driver). However when I print to the label printer it does not. I've been advised that the label printer requires "control codes" and "encoded data" to be able to print.
I've been able to log the .prn files from the printer and when sending the exact same data from Notepad to he printer, the .prn file is much larger and appears to be "encoded" containing control codes.
This is entirely inside a windows environment using a networked printer (tried USB as well). I basically need something for my Java application to print to, that will add the necessary "encoding" to the data and then pass it along to the Datamax printer. Any ideas?
I'll try and post some samples tomorrow when I'm in the office as I'm currently typing this on mobile.
What I ended up doing was using the printers logging feature to log all jobs to C:\printlogs\ and have a batch file that loops every few seconds to run notepad /P on each file in the folder and then clean them all up.
I know it's a messy workaround, but it works.
When you print text from something like Notepad, that text gets sent to a print driver that converts it into the format the printer understands. You can't generally add control codes to the text in Notepad and have it work because it won't be seen as anything other than plain text to be printed.
The programmer's manual for that printer can be found here. That gives you everything you need to know to print labels on that printer. But in order to send those commands to the printer, you can't just paste them into Notepad. You have to write them directly to the printer, bypassing the print driver. For that you're going to need to use the WritePrinter function. The sequence of steps for printing goes like this:
To begin a print job, call StartDocPrinter.
To begin each page, call StartPagePrinter.
To write data to a page, call WritePrinter.
To end each page, call EndPagePrinter.
Repeat 2, 3, and 4 for as many pages as necessary.
To end the print job, call EndDocPrinter.
The MSDN entry for WritePrinter includes a link to example code (in C).
I'm building an application that has to use a POS printer to print a receipt on a button click.
I've never used a printer with JAVA before, so I have no idea, but I've done some research and I'm thinking of either formatting my receipt in a jtextarea and then printing it using the print() method,
or painting it to Graphics2D first using paint(g2d) and then printing it with a printer job using the Printable interface.
Which would be easier?
Thanks in advance.
I've actually worked a lot with stuff like this. I've tried printing with with Graphics2D which works fine but is very slow on a POS printer. You usually want POS printers to be fast. POS printers have a serial communications interface for printing, which is how I'd recommend you to do it. Have a look at:
http://www.javapos.com
It's a library for interfacing with POS peripherals. The documentation isn't the best. You will need javapos libraries, javapos drivers for your specific printer, serial communication libs (RXTX) etc.
I'm creating Web App using Java,And one of the tasks is to print a report to the customer.The problem is that the paper design is already made and putted in the actual printer and I must only fill the blank fields.The questions are :
1) how can I print the values exactly in the fields ?
2) Is there a way to simulate this process without having physical printer, like using virtual printer and upload the default page to it ?
I attached part of the paper that will be in the printer and I should fill the blank fields with data comes from JSF page.
I solved the problem like yours in the past. My company has a pre-designed printed invoice. My task is to put the data into the blanks in place. In my experience, you should:
Scan the paper into an image with the same size as the physical version.
Measure the distance from a blank to another.
Specify the location of the blanks to output the data based on your measurement.
You can use the digitalized version as the background of the output page and test on it.
Try to put the first blank in place.
Test and adjust your code.
Hope it helps.
If the things that are there in the page only in the soft copy you can do one thing. Design a A4 exactly the same way you have on the printed page. Then write down variables in the places where you would like to fill up from your java program. That docx file will act as the template. After that, replace those texts with the actual values from the Java program in that template. All these can be done with docx4j api.
A code block like this will be useful :
if (textElement.getValue().contains(placeholder)) {
String temp = textElement.getValue();
temp = temp.replace(placeholder, name);
textElement.setValue(temp);
return;
}
This is how we do it our project. If you need more help, let me know.
I am having a hard time trying to something simple in Java, but I have been beating my head against a wall for the better part of a day.
I am implementing a program that has a print feature. What I want to print is HTML text in a JEditorPane and I know I can use the print() method to print it to a printer, but I want to also print it to a file (PostScript or PDF, I don't really care which). I know that there exists somewhere in the depths of the JRE is code to convert the rendered contents of the JEditorPane to PostScript, since the printers I am dealing with are PostScript printers and that that is the standard output format for UNIX/Linux printers. Is there a way to leverage that to print to a file, without having to completely re-invent the wheel? I have been running web searches and randomly hacking code for the past couple of days with absolutely no meaningful progress.
As far as I can tell this is just not easily doable with Java. Instead, I found a package that implements 'exporting' the contents of the GUI (a JTextPane) to a PDF file, so I just added an additional toolbar button & menu item to 'Export to PDF'.