I have PAX A920 and i am trying to print receipt from chrome.
I wan to configure printer service in android for print receipt from my build in printer
I have write printer service for local printer and its is showing in preview, but I don't know how to configure build in printer.
This is code for local printer
final List<PrinterInfo> printers = new ArrayList<>();
final PrinterId printerId = generatePrinterId("Pax-printer:built-in");
Log.e("the", "the local printer id is " + printerId);
final PrinterInfo.Builder builder = new PrinterInfo.Builder(printerId, "POS Printer", PrinterInfo.STATUS_IDLE);
PrinterCapabilitiesInfo.Builder capBuilder = new PrinterCapabilitiesInfo.Builder(printerId);
capBuilder.addMediaSize(PrintAttributes.MediaSize.ISO_A6, true);
capBuilder.addMediaSize(PrintAttributes.MediaSize.ISO_A3, false);
capBuilder.addResolution(new PrintAttributes.Resolution("resolutionId", "default resolution", 600, 600), true);
capBuilder.setColorModes(PrintAttributes.COLOR_MODE_COLOR | PrintAttributes.COLOR_MODE_MONOCHROME, PrintAttributes.COLOR_MODE_COLOR);
builder.setCapabilities(capBuilder.build());
printers.add(builder.build());
addPrinters(printers);
I am also getting Document object
final PrintDocument document = printJob.getDocument();
but I can not utilize this document to set in customer printer, my customer printer accept payload of text and bitmap.
here is code for printing from PAX A920
PrintPayload payload = new PrintPayload();
payload.append(bmp).align(Alignment.CENTER);
print(payload);
How can i convert this document object to bitmap?
How can i configure build in printer with android PrintService
I hope I'm not too late.
If you take a look at this question, you would find some helpful code and insights into the way I've solved this very issue you were/are having. My solution was some kind of union between the code in this Zaki50 PrintService, and this Thermal Print Service Repo. If it is helping, you could comment to that affect, and I will post the behaviour from the answer to my question here as well, so that you would accept it as an answer.
Related
Is it possible to create a zpl file and send it to a thermal printer automatically from the report designer? The use case is that we need to print "tags" for our stock and serial items. We have a custom output report and need to be able to send that as a zpl file format to a tag printer.
Acumatica DeviceHub has a "raw mode" that's specially designed for label printers. I tested it extensively with Zebra printers and ZPL while working on the advanced fulfillment module.
A recent blog post by Sergey Marenich talks about DeviceHub; you will not find any information on how to use the raw mode, but it does explain the basics of Device Hub, print queues and how to send a job. Device Hub is now part of Acumatica 2018 R2 (it used to be available as a separate download with the advanced fulfillment pre-release module) and from the Source Code browser you can find quite a few examples of where it is used, including this one from SOShipmentEntry that works with labels. PX.SM.SMPrintJobMaint.CreatePrintJobForRawFile is the function you need to call.
if (lableFiles.Count > 0)
{
FileInfo mergedFile = MergeFiles(lableFiles);
if (upload.SaveFile(mergedFile))
{
if (PXAccess.FeatureInstalled<FeaturesSet.deviceHub>())
PX.SM.SMPrintJobMaint.CreatePrintJobForRawFile(adapter, new NotificationUtility(this).SearchPrinter, SONotificationSource.Customer, SOReports.PrintLabels, Accessinfo.BranchID, new Dictionary<string, string> { { "FILEID", mergedFile.UID.ToString() } },
PXMessages.LocalizeFormatNoPrefix(SOShipmentEntryActionsAttribute.Messages.PrintLabels, mergedFile.ToString()));
targetUrl = PXRedirectToFileException.BuildUrl(mergedFile.UID);
}
else
{
throw new PXException(Messages.FailedToSaveMergedFile);
}
}
I'm making a gym management web app that handles sign-ins. Members have a barcode on a tag that they scan when they arrive to the gym.
I've heard that most barcode scanners simply act as a keyboard. This would require the scanning-in page to be open and in the foreground when a barcode is scanned.
If it's just a keyboard, how would I send the barcode scanner input to a single background process running on the computer, and have it ignore by all processes that may be in focus?
You're right that most scanner can support HID in keyboard emulation, but that's just the start.
If you want to have a bit more control over the data you can use a scanners that support the OPOS driver model.
Take a look at Zebra's Windows SDK to have a overview of the things that you can do. It may be a better solution than try to steal the barcode data coming in the OS as a keyboard entry to the foreground app.
Disclaimer: I work for Zebra Technologies
Other Barcode scanner vendor support a similar driver model.
I found an interesting post with a simple solution:
On the form constructor
InitializeComponent():
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.Form1_KeyPress);
Handler & supporting items:
DateTime _lastKeystroke = new DateTime(0);
List<char> _barcode = new List<char>(10);
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
// check timing (keystrokes within 100 ms)
TimeSpan elapsed = (DateTime.Now - _lastKeystroke);
if (elapsed.TotalMilliseconds > 100)
_barcode.Clear();
// record keystroke & timestamp
_barcode.Add(e.KeyChar);
_lastKeystroke = DateTime.Now;
// process barcode
if (e.KeyChar == 13 && _barcode.Count > 0) {
string msg = new String(_barcode.ToArray());
MessageBox.Show(msg);
_barcode.Clear();
}
}
Credits: #ltiong_sh
Original post: Here
Use RawInput API (https://www.codeproject.com/Articles/17123/Using-Raw-Input-from-C-to-handle-multiple-keyboard#_Toc156395975) and check device ID for incoming keystrokes. Different devices have different IDs. You can also block keystrokes from scanner from reaching your application and interfering with input fields.
One thing you might want to add is option for user to identity which device is used as a barcode scanner. I did it by asking user to test-scan barcode with scanner on first application startup or in settings.
Works with any barcode scanner which outputs keystrokes.
I'm building a MaskedWalletRequest:
return MaskedWalletRequest.newBuilder()
// required fields
.setCurrencyCode(CURRENCY_CODE)
.setEstimatedTotalPrice(String.valueOf(order.getTotal()))
// optional fields
.setShippingAddressRequired(false)
.setMerchantName(MERCHANT_NAME)
.setPhoneNumberRequired(false)
.setPaymentMethodTokenizationParameters(tokenizationParameters)
.setMerchantTransactionId(String.valueOf(order.getId()))
.addAllowedCardNetwork(123)
.build();
I then start SupportWalletFragment:
SupportWalletFragment supportWalletFragment
SupportWalletFragment.newInstance(walletFragmentOptions);
MaskedWalletRequest maskedWalletRequest = createMaskedWalletRequest();
WalletFragmentInitParams initParams =
createWalletFragmentInitParams(maskedWalletRequest);
supportWalletFragment.initialize(initParams);
When I click on generated Android Pay button, my onActivityResult gets correct request code, result code = 1, and data Intent has error value of 8.
I don't see this error code in the WalletConstants class (link ). What am I missing?
It looks like the "8" may be coming from the CommonStatusCodes class.
It turns out the allowed card network was invalid. I just dropped '123' in there for a quick test. I can only pass in one of these network ints. I was hoping for a much more clear error string like the other errors generated during the Android Pay process.
When you tap “Buy with Android Pay “ button more than once - errorCode 8 occurs.
With respect to the above Masked Wallet builder please refer to the documentation on allowedCardNetworks() for more information.
https://developers.google.com/android/reference/com/google/android/gms/wallet/MaskedWalletRequest.Builder#addAllowedCardNetwork(int)
I am running Win10 IoT on a pi 2. I need to be able to take pictures that are focused but cannot get the focus working. The application is a background app so I don't have a way of previewing the camera on a display. Is there any way of doing this? Currently I have
await _mediaCapture.StartPreviewAsync();
_mediaCapture.VideoDeviceController.FocusControl.Configure(new FocusSettings
{
Mode = FocusMode.Continuous,
WaitForFocus = true
});
await _mediaCapture.VideoDeviceController.FocusControl.FocusAsync();
await _mediaCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), stream);
await _mediaCapture.StopPreviewAsync();
but I am getting the error
WinRT information: Preview sink not set
when I try to focus. All of the examples I've seen online show that the preview is output to a control and I assume it wires a sink up automagically. Is there a way to do this manually through code? Possibly without the preview?
I wonder if the code may work even without FocusControl.
I propose you follow Customer Media Sink implementation example and use of StartPreviewToCustomSinkIdAsync method described at http://www.codeproject.com/Tips/772038/Custom-Media-Sink-for-Use-with-Media-Foundation-To
I didn't find a way to do this. I ended up converting the background app to a UI app with a Page containing a CaptureElement control in order to preview and focus.
Instead of adding a UI, just create a CaptureElement and set the source to the _mediaCapture before calling await _mediaCapture.StartPreviewAsync();
Something like:
_captureElement = new CaptureElement { Stretch = Stretch.Uniform };
_mediaCapture = new MediaCapture();
await _mediaCapture.InitializeAsync(...);
_captureElement.Source = _mediaCapture;
await _mediaCapture.StartPreviewAsync();
I'm developing an applications which I've got running on a server on my linux desktop. Due to the shortcomings of Flash on Linux (read: too hard) I'm developing the (small) flash portion of the app in Windows, which means there's a lot of frustrating back and forth. Now I'm trying to capture the output of the flash portion using flash tracer and that is proving very difficult also. Is there any other way I could monitor the output of trace on linux? Thanks...
Hope this helps too (for the sake of google search i came from):
In order to do trace, you need the debugger version of Flash Player from
http://www.adobe.com/support/flashplayer/downloads.html (look for "debugger" version specifically - they are hard to spot on first look)
Then an mm.cfg file in your home containing
ErrorReportingEnable=1 TraceOutputFileEnable=1 MaxWarnings=50
And then you are good to go - restart the browser. When traces start to fill in, you will find the log file in
~/.macromedia/Flash_Player/Logs/flashlog.txt
Something like
tail ~/.macromedia/Flash_Player/Logs/flashlog.txt -f
Should suffice to follow the trace.
A different and mind-bogglingly simple workaround that I've used for years is to simply create an output module directly within the swf. All this means is a keyboard shortcut that attaches a MovieClip with a textfield. All my traces go to this textfield instead of (or in addition to) the output window. Over the years I've refined it of course, making the window draggable, resizable, etc. But I've never needed any other approach for simple logging, and it's 100% reliable and reusable across all platforms.
[EDIT - response to comment]
There's no alert quite like javascript's alert() function. But using an internal textfield is just this simple:
ACTIONSCRIPT 1 VERSION
(See notes at bottom)
/* import ExternalInterface package */
import flash.external.*;
/* Create a movieclip for the alert. Set an arbitrary (but very high) number for the depth
* since we want the alert in front of everything else.
*/
var alert = this.createEmptyMovieClip("alert", 32000);
/* Create the alert textfield */
var output_txt = alert.createTextField("output_txt", 1, 0, 0, 300, 200);
output_txt.background = true;
output_txt.backgroundColor = 0xEFEFEF;
output_txt.selectable = false;
/* Set up drag behaviour */
alert.onPress = function()
{
this.startDrag();
}
alert.onMouseUp = function()
{
stopDrag();
}
/* I was using a button to text EI. You don't need to. */
testEI_btn.onPress = function()
{
output_txt.text = (ExternalInterface.available);
}
Notes: This works fine for AS1, and will translate well into AS2 (best to use strong data-typing if doing so, but not strictly required). It should work in Flash Players 8-10. ExternalInterface was added in Flash 8, so it won't work in previous player versions.
ACTIONSCRIPT 3 VERSION
var output_txt:TextField = new TextField();
addChild(output_txt);
output_txt.text = (String(ExternalInterface.available));
If you want to beef it out a bit:
var alert:Sprite = new Sprite();
var output_txt:TextField = new TextField();
output_txt.background = true;
output_txt.backgroundColor = 0xEFEFEF;
output_txt.selectable = false;
output_txt.width = 300;
output_txt.height = 300;
alert.addChild(output_txt);
addChild(alert);
alert.addEventListener(MouseEvent.MOUSE_DOWN, drag);
alert.addEventListener(MouseEvent.MOUSE_UP, stopdrag);
output_txt.text = (String(ExternalInterface.available));
function drag(e:MouseEvent):void
{
var alert:Sprite = e.currentTarget as Sprite;
alert.startDrag();
}
function stopdrag(e:MouseEvent):void
{
var alert:Sprite = e.currentTarget as Sprite;
alert.stopDrag();
}
[/EDIT]
If you only need the trace output at runtime, you can use Firebug in Firefox and then use Flash.external.ExternalInterface to call the console.log() Javascript method provided by Firebug.
I've used that strategy multiple times to a large degree of success.
Thunderbolt is a great logging framework with built-in firebug support.
I use the flex compiler on linux to build actionscript files, [embed(source="file")] for all my assets including images and fonts, I find actionscript development on linux very developer friendly.
Then again, I'm most interested in that flash has become Unix Friendly as aposed to the other way around :)
To implement FlashTracer, head to the following address and be sure you have the latest file. http://www.sephiroth.it/firefox/flashtracer/ . Install it and restart the browser.
Head over to adobe and get the latest flash debugger. Download and install the firefox version as FlashTracer is a firefox addition.
Now that firefox has the latest flash debugger and flash tracer we need to locate mm.cfg
Location on PC: C:\Documents and Settings\username
Inside of mm.cfg should be:
ErrorReportingEnable=1
TraceOutputFileEnable=1
MaxWarnings=100 //Change to your own liking.
Once that is saved, open firefox, head to the flash tracer window by heading to tools > flash tracer. In the panel that pops up there is two icons in the bottom right corner, click the wrench and make sure the path is set to where your log file is being saved. Also check to see that flash tracer is turned on, there is a play/pause button at the bottom.
I currently use this implementation and hope that it works for you. Flash Tracer is a little old, but works with the newest versions of FireFox. I am using it with FireFox 3.0.10.