PJL command to set orientation - java

I have tried setting the number of copies using PJL and got it working. However I could not get the #PJL SET ORIENTATION=LANDSCAPE working. It always prints in Portrait. I am also looking for options to print particular page range say from page 2 to 5. Can this be achieved using PJL? I am using the printer HP LaserJet 5000 Series PCL6.

I am able to achieve page range using the command, #PJL JOB NAME="TestPage" START=2 END=5. It works. Modfying the orientation does not work.

This most likely cannot be done with PJL in your case. The datastream probably contains a command for orientation. PJL is designed to provide access to features that are not native to the datastream used, provides a solution for explicit language selection, allows for feedback from the printer and other job related items.
Your best solution is to parse the output and make the change inline. You might be able to do this with a 3rd party solution like Ghostscript by splitting the document into sections for portrait and landscape, having it rotate for you, and then piece the file back together again.
Other options might include using a language such as PCL5 where it might be easier to modify the data inline.

Your postscript code likely has the orientation command which is overriding your PJL command. In your postscript code, look for something like this, as it's the thing that will rotate the page to landscape:
90 rotate
For example, I'm using this code to go landscape in postscript:
% get pagesize from device or default to letter
/pageSize {
currentpagedevice /PageSize known {
currentpagedevice /PageSize get
} {
612 792 2 array astore
} ifelse
} def
% go landscape
90 rotate 0 pageSize aload pop pop neg translate

Related

Imagej getting a summary to be displayed and extracting its values

I am trying to build a simple java app, which would count particles and then display their number. I am using imagej (ij.jar) library, everything works perfect until the little box with result is supposed to be shown. COuld anyone pease explain to me how can I display that. And the second thing, how do I extract that value to an int.
my current code:
button action, which leads to:
ImagePlus imp = IJ.openImage("C:\\Users\\bibaleze69\\Desktop\\imageprocessing\\chromosomes2.jpg");
imp1.show();
IJ.run(imp, "Color Threshold...", "");
IJ.run(imp, "Analyze Particles...", "show=[Overlay Outlines] display summarize");
how do I extract that value to an int.
I believe you want to use the Results Table API. ResultsTable.getResultsTable will get the active results after your Analyze Particles command, and you can then interrogate it with the getValue methods.
COuld anyone pease explain to me how can I display that
I think your Analyze Particles isn't running because running Color Threshold... doesn't actually apply the threshold to create a mask or 8-bit image, it just opens the thresholding interface. I actually had a lot of trouble trying to get the Color Threshold to apply. I think you have a couple options though:
If you run Color Threshold in Fiji, and open the Macro Recorder, you can press the "Macro" button in the Color Threshold dialog to dump a ton of IJ1 Macro code to the recorder. This code will actually apply the selected threshold to your image and create an image that can then be input to Analyze Particles. But you would have to replicate this process on the Java side and I don't know how flexible it will be.
Alternately, you can adapt the following IJ1 Macro code to just threshold the image as 8-bit.
run("8-bit");
setAutoThreshold("Default");
//run("Threshold...");
setOption("BlackBackground", false);
run("Convert to Mask");
If you can get the desired threshold from just operating on an 8-bit version of your image then this is a much simpler option to get your data to Analyze Particles.
If these options don't fully work for you, I would also recommend writing to the ImageJ mailing list, which is read by the Threshold Colour author, among many others.

Finding images on screen

I'm a rookie java learner. I'm trying to develop a bot (or trainer, whatever) for a simple mini-game, I need to analyze the screen for images and press the corresponding action. Therefore: -
I first tried to use sikuli ScreenRegion for this, but it didn't quite go as expected. What I tried was something like this: -
if(arrowSet.find(oneDown)!=null)
{
r.keyPress(KeyEvent.VK_DOWN);
r.keyRelease(KeyEvent.VK_DOWN);
r.delay(20);
}
But it just jumped to the action, even if the condition was false. Is my application of ScreenRegion wrong in this situation? Or should I use something different than sikuli?
If using Java is not required and you work under Windows, you might consider using Automa - Python tool/library for UI automation. It allows operations on images.
For example, to find out whether an image exists on screen:
Image("arrow_screenshot1.png").exists() # returns True or False
To click on an image:
click(Image("arrow_screenshot1.png"))
To find out image coordinates/center:
Image("arrow_screenshot1.png").x # returns x-coordinate
Image("arrow_screenshot1.png").y # returns y-coordinate
Image("arrow_screenshot1.png").center # returns Point object
To wait until an image appears on the screen:
wait_until(Image("arrow_screenshot1.png").exists)
etc.
I think that using Automa you can quite easily achieve what you need!
Disclaimer: I'm one of Automa's developers
Figured it out, guys! Seems like the image recognition of sikuli is fuzzy. It wont work with targetImage.setMinRank(1.00) wont work, but when I tried running the program with targetImage.setMinRank(0.99), it all worked fluidly. Thank you for you help.

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.

Printing data to a pre printed form/stationery

We have a requirement where we already have pre printed stationery and want user to put data in a HTML form and be able to print data on that form. Alignment/text size etc are very important since the pre-printed stationery already has boxes for each character. What could be a good way to achieve this in java? I have thinking of using jasper reports. Any other options? May be overlay image with text or something?
Also we might need to capability to print on plain paper in which case the boxes needs to be printed by our application and the form should match after the printed with the already printed blank stationery containing data.
Do we have some open source framework to do such stuff?
Jaspersoft reports -- http://sourceforge.net/projects/jasperreports/
You will then create XML templates, then you will be able to produce a report in PDF, HTML, CSV, XLS, TXT, RTF, and more. It has all the necessary options to customize the report. Used it before and recommend it.
You will create the templates with iReport then write the code for the engine to pass the data in different possible ways.
check http://www.jaspersoft.com/jasperreports
Edit:
You can have background images and overlay the boxes over it and set a limit on the max character size ... and many more
It is very powerful and gives you plenty of options
Here is one of iReport's tutorial for a background image http://ireport-tutorial.blogspot.com/2008/12/background-image-in-ireport.html
The big problem when printing form content that has been filled in electronically, is aligning it correctly on the pre-printed form. You may get content to align for one printer, but when you use another it is completely misaligned.
Fly Software have a form design product called InForm Designer that gets around the problem nicely by allowing users to specify and save vertical and horizontal offsets for printers. This ensures filled in form content is always aligned. I've tried it and it works perfectly. Take a look for yourself here...
http://www.flysoftware.com/products/inform_designer/overview.asp
It might be worth implementing a printer offset similar to InForm's in your own application (if possible).
Some things to think about.
First in terms of the web page, do you want use the stationery as the form layout?
Does it have to be exact?
Combed boxes (one for each character)
Do you want to show it like that on the web page, or deal with the combing later.
How are you going to deal with say a combed 6 digit number. Is this right aligned. What if they enter 7 digits. Same for text. what if it won't fit.
Font choices, we had a lot of fun with W...
How aligned do you want the character within the box, what font limitations does that imply, some of the auto magic software we looked at did crap like change the size of each character.
Combed editing is a nightmare, we display combed, but raise an edit surface the size of the full box on selection.
Another thing that might drive you barking mad, you find find small differences in the size and layout of the boxes, so they look okay from a distance but a column of boxes sort of shifts about by a pixel. Some of testing guys had to lend us their electron microscopes, so we could see how many ink molecules we were out by. :(
Expect to spend a lot of time in the UI side of things, and remember printed stationery changes, so giving yourself some sort of meta description of the form to start with will save you loads of trouble later on.

Syntax for generating Barcode using PCL syntax

Iam searching for a PCL syntax to generate and print the BARCODE. If anyone having any information about the same, please help me. I have tried googling it, but didnt find anything.
First you need a barcode font. Once you have this simply move the cursor to the spot you want (in the example 300 x 300 in whatever unit of measure you've defined), and then call the barocde and put your text down. A simple exmample might look like htis:
<ESC>*p300x300Y<ESC>*c100D1234567890
This assumes that you have embedded the barcode as part of the print job and assigned the numeric 1000 to the font call. Just search the web for "pcl barcode font" and you will find many sites that sell these fonts and provide instructions on how to call. If the printer has barcode fonts embedded, try printing a font list and it should provide the escape sequence you need to call.

Categories

Resources