question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Barcode Text not rendered in Viewer output

See original GitHub issue

Using:

.NET Framework 4.7.2 BinaryKits.Zpl.Label 3.1.0 BinaryKits.Zpl.Viewer 1.1.1

All other dependencies up to date.

Method for creating label preview:

DialogResult result = this.openFileDialog.ShowDialog();
if(result == DialogResult.OK) {
    string content = File.ReadAllText(this.openFileDialog.FileName);

    IPrinterStorage printerStorage = new PrinterStorage();
    ZplElementDrawer drawer = new ZplElementDrawer(printerStorage);

    ZplAnalyzer analyzer = new ZplAnalyzer(printerStorage);
    AnalyzeInfo analyzeInfo = analyzer.Analyze(content);

    foreach(LabelInfo labelInfo in analyzeInfo.LabelInfos) {
        byte[] labelData = drawer.Draw(labelInfo.ZplElements);
        File.WriteAllBytes("label.png", labelData);
    }
}

Using this sample label data:

^XA

^BY3,2,100
^FO100,750,^BC^FDTEST0123456789^FS

^XZ

Actual:

Expected (labelary.com reference):

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
primo-ppcgcommented, Jun 23, 2022

The problem is that the label can also be above the barcode

You can also set the LabelPosition of the BarcodeLib.Barcode to TOPCENTER, e.g.:

var barcodeElement = new Barcode {
    BarWidth = barcode.ModuleWidth,
    BackColor = Color.Transparent,
    Height = barcode.Height + barcode.LabelHeight,
    IncludeLabel = true,
    LabelPosition = LabelPositions.TOPCENTER,
    LabelFont = barcode.LabelFont
};
1reaction
ingfdoaguirrecommented, Jun 22, 2022

@ingfdoaguirre is your viewer also open source available? Is there a reason for porting to another language?

Hi Tino, first I’m dont have the sufficient knowledge of C#, also I used tried to use the viewer to create PDF files intead images.

The first approach was to only append the image to a pdf file, but the final file size, was big on a document with some labels.

Then I tried pdfSharp to make “native pdf file”, it worked well.

The problem came when I made some tests, the ram memory usage was increasingly, lets say that on every page added to document, ram was increased by 20mb. I tried some some solutions, but no one worked. Then I tried on my win11 partition, and the ram leak was not present (I develop on Ubuntu).

After some research I discovered that the “System.Drawing.Common” library only works on windows (: and the problem with memory leak, was pdfSharp that doesn’t already implemented a solution to that.

Also this is the only open source library to analyze Zpl, and I use Go in my microservices, so I made a port.

I will upload that port to github and make open source this week, I’m solving some details. And I will explicitily say that is a port from this library, thats the reality and not a problem to me.

Also was a personal challenge, and it was fun.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Barcode fonts not rendering in report view or PDF export
My understanding was that the barcode was embedded in the report, and that the .PDF export should support that. Users *are* able to...
Read more >
Barcode Reader - no output value to text box
Solved: Hi All, I'm trying to create a simple asset registry, part of this is has a barcode scanner function to make life...
Read more >
code 128 barcode font not displaying in pdf [closed]
I want to generate code 128 barcode via font. In my Report Viewer, barcode is working well. But when I exported it into...
Read more >
Barcode not showing up
How to check, open PDF file with a barcode in Reader/Acrobat, File>Properties> General, ... This could be the reason that the bar code...
Read more >
Custom barcode font doesn't render on PDF document #6448
Problem: barcode font doesn't render properly in pdf.js, as shown below: As you can see, Adobe Reader displays this font properly.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found