how can I print an image in Eclipse Window builder - java

When I say print im talking about a physical printer so I want the users image chosen with jfilechooser to show up on the paper that comes out of the printer I can make it print out text but it also needs to show the image so far I have tried using buffered image and geticon neither of those worked so I really need help here.

Related

How to print Large Image on Thermal Printer

I'm able to print images on thermal printer. but the printed images has lines on in. i've googled it i did find some idea. like making it grayscale(bitmap i already done but no luck). i've seen the dithering but i cant make it work.
any idea/help is very much appreciated.! thanks MAN!
Found the the answer here ... http://new-grumpy-mentat.blogspot.com.br/2014/06/java-escpos-image-printing.html

Java Swing - PDF Thumbnail Viewer

I'm kinda new in programming and I'm trying to learn everything by myself.
Currently I'm working on a project to sort all my bills and other stuff.
I managed it to updload the bills as PDF files onto a FTP Server.
I'm displaying all outgoing money in a JTable and now I'd like to see a Thumbnail of the PDF
in the right part of my swing GUI after i selected a table row.
Here is what I was thinking of:
Get the selected row via a clickListener, read the bill number, which is the same number the file is called on the FTP (e.g. Number: "20130012" / File: "20130012.pdf").
Download the file from the FTP and save it somewhere temporary?!
and now I need to display the pdf in my grid layout but how =) ? If
it is a picture I could use the Image Icon right? But how do I get
the effect with a pdf?
As soon as I click on the thumbnail, I'd like to open up a pdf reader to see the actual file.
Sorry if this is to less information... just let me know if you need further information.
I'd really appreciate a few answers =)
Thanks
Use a ListSelectionListener to determine which JTable row was clicked and fetch its PDF file. If fetch latency is a problem, use SwingWorker. Once you create a thumbnail image of each page in the selected row's PDF, you can display them in a JList as shown here. Display the selected page at full size in your implementation of ListSelectionListener.

Getting pixel position of a text in an image

I am working on a research project.The scenario is this.
I am taking the screenshot of my desktop and then I process it using an API to get the position of a certain text on my Desktop.e.g , say I have the browser open on my desktop and I am on stackoverflow.Now I want to search the position of the logo stackoverflow on the screenshot taken.Then I want to simulate a click on it.I am using Java platform.
Now I have 2 questions:
1)Is there any free API(OCR) which I can use to process the screenshot to fetch text position (or can be done by some trick) and gives good results.
Or Any way you can suggest that I can use (instead of taking screenshot and processing it) to get the position of any text on the screen.
2)How can I simulate the click on the screen using the code by a background program running(I mean I have done it in Swing and other language UIs but this time its different as Now I want to click on the screen.
If I understood you right you want to move your mouse and click on the screen. That not that hard you could use the robot class from Java!
For example:
Robot rob = new Robot();
rob.keyPress( KeyEvent.VK_ENTER );
or what ever, there are so much bottons and movements you could with it. A list of all methods you find here.
And your other question I can't answer. I think there is no API that is able to search a text and give you the position. But what I know is that the robot class is able to capture the screen and put it into a BufferedImage. With it you could compare two pictures.
Maybe you could get use of this but I don't know if it is what you search.

Where do you get zebra printer fonts for print preview?

I'm printing labels with a Zebra printer using Java by sending ZPL II commands. I want to show a preview of the label before sending it to the printer.
Rather than trying to send fonts to the printer, I'd like to use the built in fonts.
I can see a list of the fonts on page 60 of the programming guide volume 2. There are 15 of them, each labeled with a single letter and no reference to the name of an equivalent screen font.
I can generate an image to display of the barcode, but I'm having trouble figuring out how to display the text appropriately because outside of the OCR fonts, I don't know of an equivalent font to leverage on-screen.
I haven't found any documentation that lists them at Zebra's website, and my searching is only returning results on how to send screen fonts to the printer (which looks complex enough for me to want to avoid at this point).
Does anybody know where I can get the fonts, or would you be able to provide me with a list of (hopefully free) equivalents?
I took a screenshot of the fonts displayed in the manual for reference.
After much research, I discovered that the fonts Zebra uses are tightly protected because of licensing.
Contacting Zebra about obtaining a license for the fonts is your only option.
The alternative I'm using for now is to preview the label with a free-to-distribute monospaced true-type font (which I haven't yet selected). The document I linked in my question provides size and spacing information for the built-in fonts so I can emulate as close as possible.
The Zebra fonts, except 0, are all bit mapped, fixed width fonts.
Courier should give you a reasonable approximation.
Just scale them using the table in the Zebra manual.
zpl-zbl2-pm-en.pdf
In case anyone stumbles upon this question.
You can generate a label preview using http://labelary.com/ API.

Printer independent way to preview and print generic text in Java

I examined the possibilities of previewing and printing generic text in Java. The requirements which I depend on are:
I should be able to specify font family and size of the font for both the preview component and for printed text.
The print preview must look exactly the same as the printed text.
Printing must be independend of printer device (no printer specific commands to define fonts etc.).
Printing of approx. 20 pages of generic text must start immediately (without any significant delay caused by data processing)
To meet the aformentioned requirements I first tried the Java Print Service API. I created the JTextPane which contained the text to preview and print. By using JTextPane I was able to specify the font so the result looked fancy. To print data from JTextPane I used the standard procedure, which is independend from printer device
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(myTextPane);
pj.print();
Everything would be fine if printing 20 pages of plain text wouldn't start in 15 seconds after the print() method was executed.
However printing starts immedialety when I print the same text as raw byte array ('application/octet-stream') with few PCL specific commands to set a proper font. But this approach is printer specific and there is also a problem with previewing the text so that the priview look exactly the same as printed text.
The problem with JTextPane is most likely caused by the fact that the data sent to printer are too large (pixel-by-pixel) while the second solution is a matter of few bytes. Unfortunately none of these solutions are sufficion for me because they don't meet all of the requirements.
Probably the solution would be if there is some 'facade' over printer control languages (PCL, ESC/P, ...) which would allow me to set the text font independently from the printer device. The problem with print preview would not be solved, but at least the printing would start immediately.
Any advice how to print the plain text not breaking the aforemention 4 criteria?
The problems above seems to be linked to Linux print driver and Cups.
I tried to print some text on Windows and everything works fine. Printing even starts immediately.

Categories

Resources