I'm trying to print on a printer full of functionality (Kyocera TASKalfa 5501i), having a mailbox add-on with 7 outputs installed. I want to print to each of those outputs indiviually using Java on a server. Because my application runs on a remote server, Java has no UI available to, for example, open the drivers default preferences-window and select the output-tray there. Until now i got all attributes working, that are in the javax.print.attribute.standard package, but i have no idea how to select the output-tray.
I searched nearly the entire internet for a solution. Does anyone have an idea how to select the output-tray/mailbox or pass, any non-default parameter to the printer without having to implement the complete printing-stack from bottom up?
Kind regards.
Related
I need to get title of current active window(for example right now: Google Chrome). I search smth in internet, and found only this javax.swing.FocusManager.getCurrentManager().getActiveWindow(); . But i don't know how to get PROGRAM TITLE with that code.
If you are fine with a non-java solution that will work for Windows computers, there is a programming language called AutoHotkey (AHK) that is more suited for this kind of task. There exists a popular script called "Window Spy" (also known as "ActiveWindowInfo") that has the ability to view the title of the active window, as well as other information such as PID, the name of the .exe that the Window is an instance of, and etc. (I have attached a screenshot of what Window Spy told about the Google Chrome window I was using to write this reply. In the screenshot, I have also indicated which part of it tells you the Title of the Window).
This script comes with most AutoHotkey IDEs (such as SciTe4Autohotkey if you are interested). However, you can perfectly well run the script without an IDE.
Here are some quickstart instructions:
First, you will need to install AHK itself (here is the official website)
You can download the script itself by navigating to https://raw.githubusercontent.com/fincs/SciTE4AutoHotkey/master/source/tools/ActiveWindowInfo.ahk in Chrome, using the shortcut Control+S to save the script to your computer. Make sure that when you download the script, it ends with a .ahk instead of the .txt that it will default to.
Navigate to the file that you downloaded and run it with AutoHotkey (It should be the default thing that happens if you double click the .ahk file with AutoHotkey installed).
If you need any more info on how to use the script, please let me know.
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.
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.
I have an applet that receives an XML that serialized a JasperPrint object and print it using printservices. The applet is signed and the certificate is imported in house.
This applet is in a Web application that call it using javascript and it runs in terminals with Windows XP.
The problem is that when you use the applet always displays the prompt to run the application and users have to confirm to print.
Is there any way around this without ever having to confirm?
UPDATE:
i google the problem and i see that applet is dying (like #user3712670 says),
there are another alternative to run java code on client pc from a web page?
i need to use it locally
Short answer: no.
Any settings for those confirmation dialogs are client-side, so there's nothing you can do in your code or on your server to prevent them.
You might be able to get rid of some of them by making your clients change their security settings, but this is probably not advised. And you probably can't get rid of all of them.
You can check the plugin settings for the particular browser you're running, and you can check the Java security settings from the Control Panel.
The real answer is that applets are a dying technology, and trying to make them work is a bit like plugging up the holes in a sinking ship.
So I'm working on a project where I would like to be able to have the user browse the Active Directory to find a machine or workstation. I already know that you can envoke this directory search in the command prompt by using:
rundll32 dsquery,OpenQueryWindow
I'm using java for my project and I understand how to capture input from a command that I execute in the program but currently, at home, I'm not connected to a domain so I cannot test what the command returns when a user selects a computer or if it even returns anything. Could someone test this for me and tell me what it returns.
Also, if anyone has any better ideas on how to achieve this without relying on window's tools, like maybe a Java API for Active Directory Services?
Instead of calling an API function using rundll32, you should use a Java based LDAP library which will encapsulate the work in front of the Active Directory (so you won't have to parse the results by yourself).
Also, if anyone has any better ideas on how to achieve this without relying on window's tools, like maybe a Java API for Active Directory Services?
Choosing a pure Java library could help you run your application on many platforms (as opposed to using Windows' rundll32 which will limit you to Windows platform)
Check out this thread: https://stackoverflow.com/questions/389746/ldap-java-library.
currently, at home, I'm not connected to a domain so I cannot test what the command returns
There are solutions for this kind of testing problems. You should read about mocking: http://en.wikipedia.org/wiki/Mock_object
Good luck!
Tal.
Talk to the AD via the LDAP API.