Custom: My Printer - android

This is the link of the Bluetooth mobile printer i used for Printing
Does anyone here tried it implementing it in the Android Application? I already using it right now but im having problem with the Printing font Sizes.
Here's my code from the SDK.
//Fill class: LEFT X2
fntPrinterX2NormalLeft.setCharHeight(PrinterFont.FONT_SIZE_X1); //Height x1
fntPrinterX2NormalLeft.setCharWidth(PrinterFont.FONT_SIZE_X1); //Width x1
fntPrinterX2NormalLeft.setEmphasized(false); //No Bold
fntPrinterX2NormalLeft.setItalic(false); //No Italic
fntPrinterX2NormalLeft.setUnderline(false); //No Underline
fntPrinterX2NormalLeft.setJustification(PrinterFont.FONT_JUSTIFICATION_LEFT);
fntPrinterX2NormalLeft.setInternationalCharSet(PrinterFont.FONT_CS_DEFAULT); //Default International Chars
The PrinterFont.FONT_SIZE_X1 is large as the default and the maximum size is up to FONT_SIZE_X8.
Could anyone tell me the limit of the size of printing, or this size was the default?
Is there anyone here from the Custom Printer?
Their SDK has lack of information.. Not like Bixolon Printer It's detailed and Informative..

Related

How to detect emoji support on Android by code

By code, I can make a button that inserts these 3 emojis into the text: ⚽️😈🐺
On many phones when the user clicks the button, though, the problem is that ⚽️😈🐺 displays as [X][X][X]. Or even worse, it displays only three empty spaces.
I would like to disable and hide my own built-in emoji-keypad on Android devices that do not display emojis correctly. Does anyone knows or have a tip on how to detect in code if a device has emoji support?
I have read that emoji is supported from android 4.1, but that is not my experience....
I just implemented a solution for this problem myself. The nice thing with Android is that it is open source so that when you come around problems like these, there's a good chance you can find an approach to help you.
In the Android Open Source Project, you can find a method where they use Paint.hasGlyph to detect whether a font exists for a given emoji. However, as this method is not available before API 23, they also do test renders and compare the result against the width of 'tofu' (the [x] character you mention in your post.)
There are some other failings with this approach, but it should be enough to get you started.
Google source:
https://android.googlesource.com/platform/packages/inputmethods/LatinIME/+/master/java/src/com/android/inputmethod/keyboard/emoji/EmojiCategory.java#441
https://android.googlesource.com/platform/packages/inputmethods/LatinIME/+/master/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
Based on Jason Gore answer:
For example create boolean canShowFlagEmoji:
private static boolean canShowFlagEmoji() {
Paint paint = new Paint();
String switzerland = "\uD83C\uDDE8\uD83C\uDDED"; // Here enter Surrogates of Emoji
try {
return paint.hasGlyph(switzerland);
} catch (NoSuchMethodError e) {
// Compare display width of single-codepoint emoji to width of flag emoji to determine
// whether flag is rendered as single glyph or two adjacent regional indicator symbols.
float flagWidth = paint.measureText(switzerland);
float standardWidth = paint.measureText("\uD83D\uDC27"); // U+1F427 Penguin
return flagWidth < standardWidth * 1.25;
// This assumes that a valid glyph for the flag emoji must be less than 1.25 times
// the width of the penguin.
}
}
And then in code whenever when you need to check if emoji is available:
if (canShowFlagEmoji()){
// Code when FlagEmoji is available
} else {
// And when not
}
Surrogates of emoji you can get here, when you click on detail.
An alternative option might be to include the Android "Emoji Compatibility" library, which would detect and add any required Emoji characters to apps running on Android 4.4 (API 19) and later: https://developer.android.com/topic/libraries/support-library/preview/emoji-compat.html
final Paint paint = new Paint();
final boolean isEmojiRendered;
if (VERSION.SDK_INT >= VERSION_CODES.M) {
isEmojiRendered = paint.hasGlyph(emoji);
}
else{
isEmojiRendered = paint.measureText(emoji) > 7;
}
The width > 7 part is particularly hacky, I would expect the value to be 0.0 for non-renderable emoji, but across a few devices, I found that the value actually ranged around 3.0 to 6.0 for non-renderable, and 12.0 to 15.0 for renderable. Your results may vary so you might want to test that. I believe the font size also has an effect on the output of measureText() so keep that in mind.
The second part was answerd by RogueBaneling here how can I check if my device is capable to render Emoji images correctly?

Android print image using BIXOLON SPP-R300

I'm developing application which prints image using Bixolon SPP-R300 mobile printer via Bluetooth.My problem is I can't print my image on whole width of paper. Printer decreases dimensions very much, but saved pictures dimensions in Android is well.I want to print image on whole width.I looked in users manual of Bixolon for android but didn't help. Also in internet there is no information about it.So, I don't know what to do. Here is a code snippet from my project which prints image:
mBxlService = new BxlService();
mBxlService.Connect();
if (mBxlService.GetStatus() == BxlService.BXL_SUCCESS) {
returnValue = mBxlService.PrintImage(mypath.getPath(),
384,
BxlService.BXL_ALIGNMENT_CENTER,
40);
if (returnValue == BxlService.BXL_SUCCESS) {
returnValue = mBxlService.LineFeed(2);
}
}
In user manual,where is written that "Set to a value of 384, image is fit to full size of paper" didn't helped.
Here is a printed image.
and here is manual
The printer you are using has 576 dots per line. The SPP200 has 384 dots.

How to stop a Zebra Printer RW 420 from automatically feeding lots of extra paper when issuing command printImage from printer.getGraphicsUtil?

I am using a zebra RW420 in an android project and I am coding and I find that even when simply testing the printer using the ZSDK Developer Demos the printer is printing lots of extra paper when it is issued a print command. In this case I am testing out the signature capture and print demo. I do find that if I connect it to the computer and print a label created using Zebra Designer it prints the label properly with no extra paper (in fact i wouldn't mind a couple of millimeters extra in that case).
If any one knows how to save some trees here that would be great!
The code in question is:
connection.open();
ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
GraphicsUtil g = printer.getGraphicsUtil();
Bitmap image = signatureArea.getBitmap();
g.printImage(image, 0, 0, image.getWidth(), image.getHeight(), false);
connection.close();
this works perfect for me:
Connection connection = getZebraPrinterConn();
connection.open();
ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
// this is very important which sets automatic heigth setting for label
connection.write("! U1 JOURNAL\r\n! U1 SETFF 50 2\r\n".getBytes());
printer.printImage(new ZebraImageAndroid(bitmap), 0, 0,800, 1200, false);
connection.close();
This wont waste paper and it will print upto the availability of text/data
Assume that you have to print a receipt of width 800 and height 1200 , but it is printing a receipt of height approx. 1800 . so there is a wastage of a receipt for 600 px of white space to make use of that wastage you can use above code.
Do you have the keyword "FORM" in your CPCL label? It's usually before PRINT
This tells the printer to form feed after printing to the top-of-form setting the printer is configured to. To disable it, you can remove the FORM keyword from your format if you don't need it, or you can set the top-of-form to 0.
! U1 getvar "media.tof"
will show you what your top-of-form is currently set to
! U1 setvar "media.tof" "0"
will set it to 0, so that the FORM will feed 0 dots

Getting HTML data from web service in JSON parsing

i am doing JSON parsing for particular web service with different IDs,Parsing returns some fields like "Description,unitcost,saleprice,summary etc.., In Description field i am getting data in HTML format, But HTML Structure is not unique for each ID,
these are the urls i am using
http://demo.s2commerce.net/DesktopModules/S2Commerce/S2Commerce.svc/rest/ProductID/8/Portal/0
http://demo.s2commerce.net/DesktopModules/S2Commerce/S2Commerce.svc/rest/ProductID/5/Portal/0
And data i am getting in "description" field for 3 urls is below
1."Description":" <\/p>\u000d\u000a\u000d\u000aThis exclusive edition is another striking symbol of cooperation between Acer and Ferrari -- two progressive companies with proud heritages built on passion, innovation, power and success<\/p>\u000d\u000a<\/div>\u000d\u000a\u000d\u000aAcer has flawlessly designed the Ferrari 3200, instilling it with exceptional performance, brilliant graphics, and lightning-fast connectivity. This exclusive edition is another striking symbol of cooperation between Acer and Ferrari -- two progressive companies with proud heritages built on passion, innovation, power and success.<\/p>\u000d\u000a<\/div>\u000d\u000a <\/p>",
2."Description":"\u000d\u000aA technically sophisticated point-and-shoot camera offering a number of pioneering technologies such as Dual Image Stabilization, Bright Capture Technology, and TruePic Turbo, as well as a powerful 5x optical zoom.<\/p>\u000d\u000a<\/div>\u000d\u000a\u000d\u000aOlympus continues to innovate with the launch of the Stylus 750 digital camera, a technically sophisticated point-and-shoot camera offering a number of pioneering technologies such as Dual Image Stabilization, Bright Capture Technology, and TruePic Turbo, as well as a powerful 5x optical zoom that tucks away into a streamlined metal, all-weather body design. The camera is distinguished by a number of premium features, including:<\/p>\u000d\u000a* An advanced combination of the mechanical CCD-shift Image Stabilization and Digital Image Stabilization work together to ensure the clearest pictures possible in any situation;\u000d\u000a* A 5x optical zoom lens with a newly developed lens element to maintain a small compact size;\u000d\u000a* A 2.5-inch LCD and Bright Capture Technology dramatically improve composition, capture and review of images in low-light situations;\u000d\u000a* Olympus' exclusive TruePic Turbo Image Processing engine is coupled with a 7.1-megapixel image sensor to produce crisp, high-quality p<\/p>\u000d\u000a<\/div>
i want to get only paragraphs between paragraphs tags.
can anyone suggest me to do this?
thanks in advance
You can use regular expressions. Something like this
String description = "test <p> some \n string <\\/p> skip this <p> another <\\/p> not in range";
...
if (!"".equals(description)) {
Pattern p = Pattern.compile("\\Q<p>\\E[\\w|\\s]*\\Q<\\/p>\\E");
Matcher m = p.matcher(description);
while (m.find()) {
String ptag = m.group();
Log.d("regex", ptag);
}
}
this will find every part of text between <p> and <\/p>. Maybe, you'll need some modiifications. See all supported RegEx instructions in documentation
just see this link.
Is it possible to have multiple styles inside a TextView?
you just need to set the string data parsed from json in to this textview.

Missing font character like reduced Planck constant

I want to display two Unicode characters in TextView, but I get squares:
- ℏ (reduced Planck constant/PLANCK CONSTANT OVER TWO PI http://www.fileformat.info/info/unicode/char/210f/index.htm)
- ℞ (PRESCRIPTION TAKE http://www.fileformat.info/info/unicode/char/211e/index.htm)
I know that not all Unicode characters are supported by default Android font, but reduced "h-bar" is Latin character and it's one of the fundamental physical constants. Can anyone confirm that I making everything right? And if, how to solve this problem (third-part font is the only solution)?
view = new TextView(this);
int[] codePoint = { 0x210f, 0x211e };
String hhh = new String(codePoint, 0, codePoint.length);
view.setText(hhh);
According to the character set page the Droid fonts don't support U+210F (ℏ), but they do support U+0127 (ħ), so you might consider using an italic font and U+0127 instead.
add font containing characters to /system/fonts,
modify /system/etc/fallback_fonts.xml so android finds font then
reboot.
Everything should be working now

Categories

Resources