From 84dd81136ebaf4007862be7a0222cb93151ce479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20der=20Garde?= Date: Wed, 10 Apr 2024 18:12:31 +0200 Subject: [PATCH] Improved: Overlay requests may use wrong number formatting --- src/BinaryKits.Zpl.Labelary/LabelaryClient.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/BinaryKits.Zpl.Labelary/LabelaryClient.cs b/src/BinaryKits.Zpl.Labelary/LabelaryClient.cs index 2314dd6..eb94965 100644 --- a/src/BinaryKits.Zpl.Labelary/LabelaryClient.cs +++ b/src/BinaryKits.Zpl.Labelary/LabelaryClient.cs @@ -1,5 +1,6 @@ using Microsoft.Extensions.Logging; using System; +using System.Globalization; using System.Net.Http; using System.Text; using System.Threading.Tasks; @@ -43,11 +44,14 @@ public async Task GetPreviewAsync( var dpi = printDensity.ToString().Substring(2); var zpl = Encoding.UTF8.GetBytes(zplData); - //without setting this a comma separator might be used for for the size numbers in the URL - System.Globalization.CultureInfo.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-EN"); + //without setting this, a comma separator might be used for for the size numbers in the URL + var specifier = "G"; + var culture = CultureInfo.CreateSpecificCulture("en-US"); + var width = labelSize.WidthInInch.ToString(specifier, culture); + var height = labelSize.HeightInInch.ToString(specifier, culture); using var byteContent = new ByteArrayContent(zpl); - using (var response = await _httpClient.PostAsync($"{_apiEndpoint}/{dpi}/labels/{labelSize.WidthInInch}x{labelSize.HeightInInch}/0/", byteContent)) + using (var response = await _httpClient.PostAsync($"{_apiEndpoint}/{dpi}/labels/{width}x{height}/0/", byteContent)) { if (!response.IsSuccessStatusCode) {