Giter Club home page Giter Club logo

netbarcode's People

Contributors

dependabot[bot] avatar deviousasti avatar emrekara37 avatar grauenwolf avatar greg84 avatar savissimo avatar shortdevelopment avatar tagliatti avatar variel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

netbarcode's Issues

New Property: LabelFont

Expose the LabelFont as a property so that it can be changed as necessary. For example, when generating larger than normal barcodes we'll want to also have a larger than normal font to match.

Add new constructor

Hi,
I'm trying to create a barcode specifying the width and height, but when I'm doing that It's not possible to specify the code type, could you add a new constructor with those parameters?

Thanks.

Codabar invert lettter C and B

Hi,

when I try to generate a Codabar with C letter, but when I Scan the code I read letter B instead of C

Example:

var barcode = new Barcode("C123456789C", NetBarcode.Type.Codabar, true, width, height);
barcodeImage = barcode.GetBase64Image();

when I view the image in a tag with embded data I view in the image data C123456789C, but when I scan the barcode the result is B123456789B

So I try to invert the code with:

var barcode = new Barcode("B123456789B", NetBarcode.Type.Codabar, true, width, height);
barcodeImage = barcode.GetBase64Image();

and now when I scan the barcode the result is C123456789C

128 barcode are not accurate

Hi,
I've tried to encode "10500400412728169" using 128 and 128C. They are the same. I've tried to decode using an online tool and it decodes as "010500400412728169".
This is the generated barcode
image
And this is the correct one that should be generated
image001
Any thoughts on this?

barcode.SaveImage does not save image

Hi,

Below code does not save image nor returning any exception:

Dim barcode = New Barcode("123456789", TYPE.CODE128)
barcode.SaveImage("test.png", SaveTypes.PNG)

Using NetBarcode 1.4.0 installed via NuGet

Also Looks like docs are not up to date, barcode.SaveImageFile does not exist.

Regards,

Crashes when no fonts are found. Even if showLabel is set to false.

I'm doing this:

var barcode = new Barcode(barcodeData, Type.Code39, false, 321, 38);

The application is running in a Linux container with no fonts installed so the SystemFonts.Collection.Families collection is empty.

Because of this it crashes with a "Sequence contains no elements" error in Barcode.cs on line 79.

It would be nice if it only checked the fonts when showLabel is set to true, as otherwise the font is not used.

Could replace First with FirstOrDefault and then crash if font is null before rendering the label?

Linux high memory usage .net 5

Is there any way to diagnose Unmanaged memory leak ?

I am using .NET 5.0 Console App with NetCode. The program it self is simple it calls barcode library & creates a base64string from Image 5000 times, I am using 'using blocks' therefore disposing is also being handled.

static void Main(string[] args)
{
    Console.ReadKey();
    for (int i = 0; i < 5000; i++)
    {
        Barcode bar = new Barcode("123456789123456", Type.Code128);
        using (var image = bar.GetImage())
        {
            using (MemoryStream ms = new MemoryStream())
            {
                image.Save(ms,ImageFormat.Png);
                var base64 = Convert.ToBase64String(ms.ToArray());
                Console.WriteLine(i);
            }
        }
    }
    Console.ReadKey();
    Console.ReadKey();
}

On windows this program consumes 15-25 MB (doesn't go above that) but on Linux Unmanaged memory constantly increases with each iteration but never goes down at all (goes upto 600MB on 5000 iterations).

enter image description here

Linux dotMemory:

enter image description here

enter image description here

Windows dotMemory:

enter image description here

I have tried the same program after fixing the Font, FontFamily disposing issue but the results are same.

I am using docker with:

FROM mcr.microsoft.com/dotnet/aspnet:5.0.15-focal as base
FROM mcr.microsoft.com/dotnet/sdk:5.0.406-focal AS build

Whole demo with dockerfile & dotmemory snapshots can be found here.

Support for Skia Canvas

Hi, in my work we are using QuestPdf, which has a Skia Canvas API to draw on the PDF file.

I think it would be useful to have an adapter to generate the Skia Canvas from the binary string generated from IBarcode.GetEncoding(), maybe NetBarcode.Skia :) But I am not sure whether I should create a PR for it or does SkiaSharp is worth a separate adapter at all.

I made a dirty prototype here:

Fork link

For now, it's just for exploration with fixed-size canvas, but if you are okay I am willing to make a PR.

Let me know what you think. Thank you!

Offer - Variable bar length and better label positioning for EAN barcodes

While they are working for scan readers, the barcodes generated for EAN codes don't comply with the industry standard representation (with longer bars where the markers are, and "broken" label - see https://en.wikipedia.org/wiki/International_Article_Number#/media/File:EAN13.svg for an example).

I appreciate the elegance of your solution for rendering the barcode, and as I said there is no practical or functional necessity to improve the rendering, but it would be cool to obtain an image that is 100% similar to what you would find on a commercial product package.

I offer to implement a better rendering for EAN-8 and EAN-13 through polymorphism. Is this something you would be interested in adding, or would you rather keep it simpler in your library?

DrawLines method from ImageSharp does not render the barcode lines correctly

Hi @Tagliatti, first of all, thank you for your library!

I have been using the library for some time, namely for Code128C. I encountered a problem with versions 1.5+, which I already wrote about (Issue #29).

var barcode = new Barcode("660004005000080000221020220529113509", NetBarcode.Type.Code128C, false, 466, 40);
barcode.SaveImageFile(@"C:\Temp\barcode.png", ImageFormat.Png);

Result for version 1.4.5
barcode145
Result for version 1.6.0
barcode16original

In the latest version barcode lines are rendered as thicker and when I use barcode.GetBase64Image(); the barcode is really corrupted.
barcode-B64

I tried to figure out the cause of the problem and found that the problem is in this part of the code:

imageContext.DrawLines(drawingOptions, pen,
    new PointF(pos * iBarWidth + shiftAdjustment + halfBarWidth, 0),
    new PointF(pos * iBarWidth + shiftAdjustment + halfBarWidth, _height - labelHeight)
);

The problem is with ImageSharp method DrawLines. This method will not draw a line in the form of a solid rectangle if the pen width is equal to or greater than 2 :-(

I suggest using the method FillPolygon, and the corresponding code would look like this:

imageContext.FillPolygon(drawingOptions, _foregroundColor,
    new PointF(pos * iBarWidth + shiftAdjustment + halfBarWidth, 0),
    new PointF(pos * iBarWidth + shiftAdjustment + halfBarWidth + iBarWidth / iBarWidthModifier, 0),
    new PointF(pos * iBarWidth + shiftAdjustment + halfBarWidth + iBarWidth / iBarWidthModifier, _height - labelHeight),
    new PointF(pos * iBarWidth + shiftAdjustment + halfBarWidth, _height - labelHeight));

The variable pen is no longer needed.
And result for modified version 1.6.0 is the same as the one generated by the library version 1.4.5!
barcode16modified

What do you think? Wouldn't it work better this way?

Bars width and image size

Hi,

I am trying to figure out how can I set widths of bars (wide and thin) and based on that, to calculate what width barcode will be. As I unerstand, now barcodes are scaled to desired width. What I need is to have fixed bars width and variable width of generated image.

Thanks in advance.

Support .NET 6 on Linux

Hi,

I'm trying to use this library with .NET 6 on a docker alpine image. However I'm running into this issue. Are there plans of swapping out the System.Drawing dependencies for one of the recommended libraries?

Thanks!

New Method: Barcode.GetByteArray(ImageFormat)

When generating barcodes for ASP.NET Core, we need them as a Byte[] so that we can wrap them in a file content result. For example:

    public FileContentResult Code128(string barcode)
    {
        var bc = new NetBarcode.Barcode(barcode, true);
        var result = Convert.FromBase64String(bc.GetBase64Image());

        Stream stream = new MemoryStream(result);
        return new FileContentResult(result, "image/png");

    }

Currently the way this is done is by asking Barcode to concert the image into a Byte[] which is then turned into a Base64 string, after which we turn it back into a Byte[],

This new method would just omit the Base64 step.

V1.5 Feedback

In this version it was Replaced System.Drawing by ImageSharp, comment if you find any problems.
Thanks

DllNotFoundException: Unable to load DLL 'libgdiplus' on mac

I really like this feature, but am using a mac and getting the error below :

System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libgdiplus': The specified module could not be found.
at System.Runtime.InteropServices.FunctionWrapper`1.get_Delegate()
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
at System.Drawing.SafeNativeMethods.Gdip..cctor()
--- End of inner exception stack trace ---
at System.Drawing.SafeNativeMethods.Gdip.GdipGetGenericFontFamilySansSerif(IntPtr& fontfamily)
at System.Drawing.FontFamily.GetGdipGenericSansSerif()
at System.Drawing.FontFamily.get_GenericSansSerif()
at System.Drawing.Font.CreateFont(String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte charSet, Boolean isVertical)
at NetBarcode.Barcode..ctor(String data)
at ICFERApp.Controllers.StudentController.Details(Int64 id) in /Users/idrislutaaya/RiderProjects/ICFERApp/ICFERApp/Controllers/StudentController.cs:line 176
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)

I also tried to install libgdiplus with this brew install mono-libgdiplus command , but it didn't workout. What caused this issue ?

System.ArgumentNullException: 'Parameter "name" must be not null. (Parameter 'name')'

I am trying to generate an image using the NetBarcode library.
However I get a ArgumentNullException.
My code looks like this:

    var bc = new NetBarcode.Barcode(code, NetBarcode.Type.EAN13, true);
    var b64 = bc.GetBase64Image();

Am I doing something wrong, or is there an error in the library?
I am running this in Blazor (server side). .NET version 7.0

Thanks in advance!

image

System.NullReferenceException: Object reference not set to an instance of an object.

System.NullReferenceException: Object reference not set to an instance of an object.
at NetBarcode.Types.EAN13.GetEncoding()} | System.NullReferenceException

CODE:

var barcode = new Barcode(newStringValue, TypeNet.EAN13, true); <--- Exception origen

use implement

using NetBarcode;
using TypeNet = NetBarcode.Type;

Ambient:

Ubuntu 20.04
NetCore 3.1

generated barcode is incorrect

I'm trying to generate a barcode based on the code below,

var barcode = new Barcode("G7G95FTU"); var barcodeBytes = barcode.GetByteArray();

but here is the barcode that's generated by the library, and when I scanned it with a barcode scanner I got this ("G7GFTU")

image

Incorrect generation result

I use an online generator and decrypt through an online reader and everything is correct.

But when I use this package, 0 is added to the beginning of the string when decrypting.

To repeat my case, you need to use Code128 and generate the string "765256359354976758112".

Version 1.7.0

Could not load file or assembly

Netstandard 2.0 Error generate ๐Ÿ‘
"Could not load file or assembly 'NetBarcode, Version=1.0.5.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified."
this error I get when trying to consume the library class installed or referenced in a NetCore 2.0 project !!!

Change Label font size

How to change label font size?

My Bar code is look like this. I want to change to smaller font size.

image

produce with this code.

var bc = new Barcode(stringdata, NetBarcode.Type.Code128,true,170,50));

EAN 13 check digit

Good morning, please I would like to note that I can't find a way to generate a check digit to add it to the database and the label.
I tried 123456789012 as a barcode and when displaying the label I only get the 12 digits without the check digit included.
Please, can you add a method to get it or include it directly in the label.
THANKS IN ADVANCE.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.