I have HardwareStation for PDF printing, copied from RetailSDK example.
In HardwareStation.Extension.Config. I add assembly for new extensions and 3rd party library.
<add source="assembly" value="FreeSpire.PDF" />
<add source="assembly" value="XXX.Commerce.HardwareStation.Extension.PDFPrinter" />
<add source="assembly" value="XXX.Commerce.HardwareStation.Extension.WindowsPrinter" />
In Controller as below
namespace XXX
{
namespace Commerce.HardwareStation.PDFPrinter
{
using System;
using System.Threading.Tasks;
using Microsoft.Dynamics.Commerce.HardwareStation;
using Microsoft.Dynamics.Commerce.Runtime.Hosting.Contracts;
using Spire.Pdf;
/// <summary>
/// PDF printer web API controller class.
/// </summary>
[RoutePrefix("PDFPrinterController")]
public class PDFPrinterController : IController
{
/// <summary>
/// Prints the content.
/// </summary>
/// <param name="printRequest">The print request.</param>
/// <exception cref="System.Web.Http.HttpResponseException">Exception thrown when an error occurs.</exception>
[HttpPost]
public Task<bool> Print(PrintPDFRequest printRequest)
{
ThrowIf.Null(printRequest, "printRequests");
try
{
byte[] receivedFile = Convert.FromBase64String(printRequest.EncodedBinary);
// Add here the code to send the PDF file to the printer.
PdfDocument pdf = new PdfDocument(receivedFile);
pdf.PrintSettings.PrinterName = printRequest.DeviceName;
pdf.Print();
return Task.FromResult(true);
}
catch (PeripheralException ex)
{
Console.WriteLine(ex.Message);
throw;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw new PeripheralException(PeripheralException.PrinterError, ex.Message, ex);
}
}
}
}
}
In POS Web AppBar extension, I call the HardwareStationRequest as in red text:
protected execute(): void {
this.isProcessing = true;
window.setTimeout((): void => {
this.isProcessing = false;
}, 2000);
this.getHardwareProfile();
this.getDataArea();
let pdfTransferOrders = this.getTransferOrderPDF(this._order.orderId, this.transferDataAreaId, this.hardwareProfileId);
pdfTransferOrders.then((response: Commerce.Proxy.Entities.Receipt[]):
Promise<ClientEntities.ICancelableDataResult<PrinterPrintResponse>> => {
let receipts: ProxyEntities.Receipt[] = response;
// Prints the receipts.
//let printerPrintRequest: PrinterPrintRequest<PrinterPrintResponse> = new PrinterPrintRequest(receipts);
//return this.context.runtime.executeAsync(printerPrintRequest);
let receipt: Commerce.Proxy.Entities.Receipt = Commerce.ArrayExtensions.firstOrUndefined(
receipts,
(p): boolean => { return Commerce.ArrayExtensions.hasElements(p.Printers) }
);
let printRequest: PrintPDFRequest = new PrintPDFRequest(receipt.Header, receipt.Printers[0].Name);
let hwsRequest: Commerce.HardwareStationDeviceActionRequest<Commerce.HardwareStationDeviceActionResponse>
= new Commerce.HardwareStationDeviceActionRequest<Commerce.HardwareStationDeviceActionResponse>(
"PDFPrinterController", // controller's name
"Print", // method name
printRequest
);
return this.context.runtime.executeAsync(hwsRequest)
.then((hwsResponse: ClientEntities.ICancelableDataResult<Commerce.HardwareStationDeviceActionResponse>)
: ClientEntities.ICancelableDataResult<PrintPackingSlipClientResponse> => {
this.isProcessing = false;
return <ClientEntities.ICancelableDataResult<PrintPackingSlipClientResponse>>{ canceled: hwsResponse.canceled };
});
}).then((): Promise<void> => {
// Resolves to a void result when fulfilled.
this.isProcessing = false;
return Promise.resolve();
}).catch((reason: any): Promise<void> => {
// Resolves to a void result when rejected. This matches existing POS printing behavior.
this.context.logger.logError("Print transfer order execute error: " + JSON.stringify(reason));
this.isProcessing = false;
return Promise.resolve();
});
}
But once I run MPOS and click the AppBar button, I got error.
The description for Event ID 46802 from source Microsoft-Dynamics-Commerce-ModernPos cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
Request.HardwareStationDeviceActionRequest.HardwareStationDeviceActionRequest
Pos_Extensibility_XXX
xxxxxx
7.3.0.0
["{\"number\":0,\"description\":\"\",\"stack\":\"CommerceError\\n at Error (ms-appx://microsoft.dynamics.retail.pos/Commerce.AsyncResult.js:29:21)\\n at HardwareStationRequestHandler.prototype._validateHardwareStationRequestUri (ms-appx://microsoft.dynamics.retail.pos/Pos.Core.js:56004:25)\\n at Anonymous function (ms-appx://microsoft.dynamics.retail.pos/Pos.Core.js:55965:25)\\n at Anonymous function (ms-appx://microsoft.dynamics.retail.pos/Pos.Framework.js:178:25)\",\"name\":\"CommerceError\",\"_canRetry\":false,\"_errorCode\":\"string_4908\",\"_externalLocalizedErrorMessage\":\"\",\"_handled\":false,\"_formatData\":[],\"_errorTitleResourceId\":\"\",\"_isUserError\":false,\"message\":\"\",\"ErrorCode\":\"string_4908\",\"ExternalLocalizedErrorMessage\":\"\",\"formatData\":[],\"errorTitleResourceId\":\"\",\"canRetry\":false,\"handled\":false,\"isUserError\":false,\"__proto__\":{}}"]
ff92ebb3-2add-c5e3-d120-0a432970c6b3
2e092f26-d287-70ae-9c51-480fdf5c7a0f
88a84cdc-b5f8-904e-5480-c9a581ce7688
1605156676546
1
The publisher has been disabled and its resource is not available. This usually occurs when the publisher is in the process of being uninstalled or upgraded
I check in folder C:\Program Files (x86)\Microsoft Dynamics 365\70\Retail Modern POS\ClientBroker, those HardwareStation extension files are there already.
Is it correct code for calling HardwareStation extension from POS?
Hello AyePKA,
I corrected a typo on my earlier post, it was meant to say "Could you confirm if you are PAIRED TO theHardwareStation?"
I'm very sorry for your experience. I'm not too familiar with the Support Plans, However I do see there are topics related to development and customizations.
I'm hoping the community can contribute more to this topic, but if not, I believe the following two support topics should help with development issues.
Selecting Technical and System Administration > Development and customization:
or I believe Commerce > Developer Experience
I hope this helps,
Oriol Machin
Support Engineer / Microsoft Dynamics 365 Commerce
North America Customer Services and Support
I don't know if we have to pay for HardwareStation extensibility.
Actually, my company has Technical support with ASfP Plan that will forward to China team (same timezone). They always reject to help if it's about extensibility. They mention "Out of scope".
Hello AeyPKA,
Could you please confirm if you are paired to the HardwareStation?
if you will not get any advice from the community, please create a support ticket for us so we can investigate it further.
Thank you for using Microsoft Dynamics 365 Communities,
Oriol Machin
Support Engineer / Microsoft Dynamics 365 Commerce
North America Customer Services and Support
Zain Mehmood
237
Moderator
Siv Sagar
109
Super User 2025 Season 1
Danny Bilodeau
88
Moderator