-1

So, I want to display a string as Barcode. I want to use Code128 Auto. And I dont want to use nuggets. How Can I do that? At the end I just want to have an TextBlock in WPF with the String of BarCode in it.

EDIT

So I already have an Font of Code128 in my Textblock in WPF. But my Problem is, that I cant scann the barcode font with an Barcode scanner.

  • ....barcode font? – ProgrammingLlama Dec 16 '21 at 10:31
  • I using the Code 128 Barcode font, but with that I cant scan the Barcode with an Barcode scanner –  Dec 16 '21 at 10:40
  • Barcode Fonts wont work since code128 does not have a 1:1 mapping of characters and needs checksum calculation / character substitution. @peter check https://stackoverflow.com/help/how-to-ask on how to ask questions and get better results in the future. – Th 00 mÄ s Dec 16 '21 at 10:41
  • I wonder what's the deal with all these barcode questions all of a sudden.. I haven't seen one for months and I've now seen 3 in the last 24h – Caius Jard Dec 16 '21 at 10:52

2 Answers2

0

For generating a barcode you could use a library like NetBarcode. It will create an image that you need to display in your app. Displaying the barcode in a Textbox might not be possible since bitmap data is generated for code128 barcodes.

Th 00 mÄ s
  • 3,776
  • 1
  • 27
  • 46
-1

Find a barcode font as suggested and do:

ont f = new Font("Free 3 of 9", 80);
this.Font = f;

Label l = new Label();
l.Text = "*STACKOVERFLOW*";
l.Size = new System.Drawing.Size(800, 600);
this.Controls.Add(l);

this.Size = new Size(800, 600);

I can't think any other way beside using nuggets.

EDIT: Since people are doing useless punctualization, of course you need to use a barcode 128 font instead of a 3 of 9. Here's one: https://fonts.google.com/specimen/Libre+Barcode+128

If you totally don't want dependencies, just go to github and implement the code of a library, so you don't have to go through nuggets.

I used successfully this one: https://github.com/Tagliatti/NetBarcode

Liquid Core
  • 1
  • 6
  • 27
  • 52
  • 3 of 9 barcode and code128 are different. Your example does not create a valid code128 barcode. Again code128 can not be generated by substituting char/num values one by one into a barcode font. – Th 00 mÄ s Dec 16 '21 at 10:45
  • I know with VB its possible to get that Code to work, But in C# i didnt find a way –  Dec 16 '21 at 10:47
  • @peter what it's not working exactly? – Liquid Core Dec 16 '21 at 10:49
  • When I try to scan the Barcode front of Code128 –  Dec 16 '21 at 10:54