Skip to content

Commit

Permalink
Improved: Overlay requests may use wrong number formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniël van der Garde committed Apr 10, 2024
1 parent f69c5c7 commit 84dd811
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/BinaryKits.Zpl.Labelary/LabelaryClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Extensions.Logging;
using System;
using System.Globalization;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -43,11 +44,14 @@ public async Task<byte[]> 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)
{
Expand Down

0 comments on commit 84dd811

Please sign in to comment.