printing to a dot matrix printer on a mac - java

So i am designing an art project that will print to a dot matrix printer the contents of my internet history. i have found info online to parse out a plist (what os x uses to store internet history) so im all set on that front but what i am looking to find out is how to send a request to the printer to print a new line, which would happen when a new page is visited. i was wondering if it is possible in any of the following languages: objective-c, javascript, php, or processing/java, all of which i have a decent understanding of. I am have tried to do a little research before asking here and it seems like i may need to use shell commands, which i am not familiar with at all. the printer i will most likely be using is an EPSON LX-300 Dot Matrix Printer if that matters. i would like to do this on os x, but if i have to use windows that is an option. if anyone knows how to do this or can give me some direction that would be a huge help. thanks

Here is how I might do it.
First, I suppose I might look around for a dot matrix printer with a modern interface and a Mac OS X driver. There might still be people printing multipart forms who need impact printers.
But failing that, I would then look for a serial (as in, RS-232 serial) printer and connect it to my mac via a USB-to-RS232-serial converter. Be careful, most of the generic such things don't work on the Mac, get a USB serial widget like this that specifically supports the mac.
Then, I would write the code in sh/bash and run it in a Terminal window. Those language systems you cite are overkill for this job, some lack system interfaces entirely, and the ones that can turn system knobs do it via complex interfaces. It's better to put together stty(2), echo(1), cat(1) et al and just get some strings to print.

Related

Print receipt using receipt printer

I am developing a Point Of Sale application, and one of the functionality is to print receipt in a thermal/receipt printer. Currently I have a Datecs DPP-255 printer.
I have no idea where to begin my quest.
I tried search through internet, found out that JavaPOS/UnifiedPOS exists but I couldn't find enough documentation to get me started. Please shed some light.
Here is an open source project for testing, that may also be used as a reference on how to program using JavaPOS (source code available):
JavaPOS POSTest 2 - a JavaPOS application for testing JavaPOS devices (source code is here).
Also here are some projects hosted on GitHub (see the source code to get the idea and to play with):
JavaPOS
POSdeviceSimulator
POStest
Related links:
Old documentation page for
JavaPOS
How to develop using JavaPOS in
Eclipse?
NOTE:
in order to utilize JavaPOS (which is now a part of the UnifiedPOS specification, see Appendix B), the producer of your Datecs DPP-255 device must provide the related drivers. Are they provided? JavaPOS - is a specification, so accordingly there must be some implementation of it.
So it looks like this printer supports something called ESC/POS, which is like a command set that allows you to print and format data. There are a few guides available online, this is one I've used before: http://www.starmicronics.com/support/mannualfolder/escpos_cm_en.pdf
Note that printers sometimes subtly differ in which command sets from ESC/POS they support, so you might have a bit of trial and error on your hands.
In terms of sending that data to the printer, it depends on what type of connection it is. For serial, you should just be able to open and write to that port, using the ESC/POS command set.
Not all of the data you will send will be ASCII or UTF encoded, a lot of them are binary values you need to send. So for example, to tell the printer to write a new line, the Hex value for that is 0A. So in Java you would need to specify that as String s = "\u000A"; etc.
For java you will need to download the Java Comm API from http://java.sun.com/products/javacomm/
There is a tutorial on this here: http://www.java-samples.com/showtutorial.php?tutorialid=214
Hopefully this helps.

How to add an available network printer using java code?

I would like to get the list of available network printers, and allow users to install (add) a selected printer on their pc using a JButton.
I have searched the net and did find a java api called java printer api but this didn't help me.
Any suggestions ?
As you have probably realized, the standard Java Print service API is for printing documents from a Java application. It works by interacting with an existing printer or print service provided by the host system. It does not address the concerns of setting up or configuring printers or print services.
I would like to get the list of available network printers, and allow users to install (add) a selected printer on their PC using a JButton.
The Java printing APIs don't provide that functionality.
So there is no way to automate the install process? Execute a batch script maybe?
If it is possible to automate printer installation, discovery, configuration (or what have you) using a shell script or batch file that can be run by an unprivileged user, then it is possible (actually simple) to get Java to run the script.
Writing that script is likely the hard part, and it is not a Java programming problem. And if you can't write / find a script to do this, then your chances of doing printer setup from a Java program are about zero. While it may be technically possible to do the task in Java, it is (IMO) not worth the development effort to do it that way.

How to print a voucher with Java and a EPSON TM-T88III

I just bought an EPSON TM-T88III. Now I want to write a small application in java that prints a voucher with some plain text, so nothing special. I was wondering how I could do this.
So far I figured out that I can print simple documents using the Windows Drivers and Notepad. Do you recommend me to use the JavaPoS? It would be great to get some hints to point me in the right direction.
I know this is so late, but I'm having a similar issue.
I recommend using an existing ESC/POS (the communication protocol) library.
This was enough to get me started, I simply did a port for my project (using a TM-T20)
https://code.google.com/p/escprinter/source/browse/trunk/net/drayah/matrixprinter/ESCPrinter.java?r=2

Enumerating attached DVD drives in Linux / Java / Scala

In my Scala (runs on top of Java) Application I would like to get a list of all drives that contain DVD media, e.g. something like this:
/dev/scd0 Star Trek DS9 DVD1
/dev/scd0 The 4400 DVD1
Not sure if it's possible to get the name of the disc, but the path is the important thing for me anyway.
I would prefer a pure Java / Scala solution (using file.io stuff). If that's not possible, accessing the right Linux files is fine, too (like /proc/something).
Thanks in advance!
I think you're out of luck with java.io.* but if you don't mind making calls out to Linux commands, you could assemble the data by:
Calling "mount" and capturing the first column of output.
Calling "volname" on each value you captured from step 1.
According to the man page for volname, it only returns data for ISO-9660 filesystems (e.g. DVDs), so any device path that returns empty can be ignored.
There is one (untested) possibility to get your drives with pure Java code. At least on Windows.
Its a little bit hacky and doesn't work under linux (because linux gets not as much integration love from sun I believe).
import javax.swing._
import javax.swing.filechooser._
val chooser = new JFileChooser()
val view = chooser.getFileSystemView()
The FileSystemView clas provides a few features such as asking the possible roots if they
are a drive (isDrive()). Swing uses this to present the file chooser with the right icons to
you so it should work under windows because IIRC it shows the correct symbols there. Under
Linux it unfortunately does only show the "/" root.
One of the reasons this doesn't work under linux could be, that the linux developers constantly change their preferred way of presenting such information to the user space. at the moment it is IIRC hal and dbus. Maybe SUN didn't want to publish a new java version each time this changes.
If pure java doesn't cut it maybe you could use a little bit of jni (which is not so hard to use anymore if you're using tools like JNA or such) to access the linux apis directly. I haven't done that but could try if you're interested.

Java VNC Applet vs Screen Capture

I am trying to make an application in which one component captures the screen of the user (for screen casting). I am aware that there are two options to achieve the same using a Java applet (please correct me if I am wrong). First is to use the java applet to take screen shots continuously and convert it into a video and upload it as a video file. And second is to create a java vnc server and record it as a .fbs file and play it using a player like: http://www.wizhelp.com/flashlight-vnc/index.html
I would like to know the best solution in terms of video quality, file size, cross-platform compatibility (windows and mac), firewall problems and finally ease of implementation.
I am very new to Java. Please tell me whats the best solution for my problem. Also, is it easy enough for me to program it on my own or should I get it developed via a freelancer. I have tons of programming experience (5+ years in LAMP) but none in Java.
Thank you very much.
I agree that this is pretty hard. I implemented those two solutions (VNC and onboard screen capture) plus a third (capture from an external VGA source via an Epiphan grabber) for a former employer. I had the best bandwidth-to-quality ratio with VNC, but I got higher framerate with VGA capture. In all three cases, I reduced the frames + capture times to PNGs and sequenced them in a QuickTime reference movie. Then I made flattened video (MPEG4 or SWF) of the results. In my case, I then synchronized the screen video with a DV stream.
In the end the technology worked (see a sample of the output) but our business model failed.
From what I know, the older versions of applet had security restrictions that may not allow for screen capture. Instead, a java application may be feasible.
Regarding the build-it-yourself vs the fire-a-coder, it depends on how you value your time compared to what you can find on a freelancer site.
I think you can find someone from India/Romania/Poland/Other countries that can make it for an affordable price
Given your Java knowledge and the difficulty of the task, have you considered taking an alternative approach? For example, how about a native VNC server for the end-user, which is just a small download and then they click "Run." And that native server is programmed to capture the screen and send it straight to your web server, which has a client like vnc2swf or other means of converting the VNC stream to a video or .fbs file? Does all that make sense?
Admittedly, without Java, you have to prepare one executable program per platform you want to support, however, I don't know. That still sounds easier to me. Consider Copilot.com. They are doing VNC but they still use small native apps for each platform.
Sorry but this seems the kind of job that requires a lot of experience. Even if you find code snippets all around the net to fix this and that, the overall result may be way worse than simply hiring an experienced Java programmer.

Categories