Welcome to the WinForms feedback portal. We’re happy you’re here! If you have feedback on how to improve the WinForms, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
From the second call to PdfCode128Barcode.Draw onwards, the bar height of the barcode is (re)set to the initial bar height + 3.752. As the first barcode is drawn with bar height 80 and not 83.752 and as this doesn't happen when you use PdfCode128XBarcode.Draw where X in {A, B, C}, I assume this is a bug.
static void ShowPdf128BarcodeBarHeightBug()
{
PdfDocument document = new PdfDocument();
// setting margin to 0 and drawing barcode at (0, 0)
// so it's easy to read the size using the ruler
// in Adobe Acrobat Reader DC
document.PageSettings.SetMargins(0f);
PdfUnidimensionalBarcode barcode = new PdfCode128Barcode("1234567890");
// light gray background to see the barcode size
barcode.BackColor = new PdfColor(Color.WhiteSmoke);
barcode.BarHeight = 80f;
Console.WriteLine($"before {barcode.BarHeight}"); // 80
PdfPage page = document.Pages.Add();
barcode.Draw(page); // bar height in the document is correctly 80
Console.WriteLine($"after {barcode.BarHeight}"); // 80
foreach (int index in Enumerable.Range(1, 9))
{
barcode.BarHeight = 80f+(float)index;
Console.WriteLine($"before {barcode.BarHeight}"); // 80+index
PdfPage _page = document.Pages.Add();
barcode.Draw(_page); // bar height in the document is 83.65
Console.WriteLine($"after {barcode.BarHeight}"); // 83.752 but should be 80+index
}
document.Save($"{System.Reflection.MethodBase.GetCurrentMethod().Name}.pdf");
document.Close();
}