Am trying to generate a barcode using aspose.barcode but am having the below error when running the code on Linux:
System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception. —> System.DllNotFoundException: Unable to load shared library ‘libgdiplus’ or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibgdiplus: cannot open shared object file: No such file or directory 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 System.Drawing.Font…ctor(String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont) at System.Drawing.Font…ctor(String familyName, Single emSize, FontStyle style, GraphicsUnit unit) at .(String , Unit , FontStyle ) at Aspose.BarCode.Generation.FontUnit.() at . (Int32 ) at .(BaseGenerationParameters ) at .() at .(Stream , BarCodeImageFormat ) at Aspose.BarCode.Generation.BarcodeGenerator.Save(Stream stream, BarCodeImageFormat format)
The below is a sample of how am trying to generate the barcode:
public byte[] Generate(BarcodeModel barcode)
{
byte[] retValue = null;
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Pdf417, barcode.BarCodeText);
generator.Parameters.AutoSizeMode = AutoSizeMode.Interpolation;
generator.Parameters.ImageWidth.Pixels = (float)barcode.ImageWidth;
generator.Parameters.ImageHeight.Pixels = (float)barcode.ImageHeight;
generator.Parameters.Barcode.BarHeight.Pixels = barcode.BarHeight;
generator.Parameters.Barcode.Pdf417.Pdf417ErrorLevel = Pdf417ErrorLevel.Level1;
generator.Parameters.Barcode.Pdf417.CodeTextEncoding = Encoding.Unicode;
generator.Parameters.Barcode.CodeTextParameters.TwoDDisplayText = barcode.BarCodeText;
if (!barcode.CodeTextVisible)
{
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.None;
}
else
{
generator.Parameters.Barcode.CodeTextParameters.Font.FamilyName = barcode.CodeTextFontFamily;
generator.Parameters.Barcode.CodeTextParameters.Font.Size.Pixels = (float)barcode.CodeTextFontSize;
generator.Parameters.Barcode.CodeTextParameters.Color = ColorTranslator.FromHtml(barcode.CodeTextColor);
generator.Parameters.Barcode.CodeTextParameters.Alignment = (TextAlignment)Enum.Parse(typeof(TextAlignment), barcode.CodeTextAlign);
}
generator.Parameters.CaptionAbove.Visible = barcode.CaptionAboveVisible;
if (barcode.CaptionAboveVisible)
{
generator.Parameters.CaptionAbove.Text = barcode.CaptionAboveText;
generator.Parameters.CaptionAbove.Alignment = (TextAlignment)Enum.Parse(typeof(TextAlignment), barcode.CaptionAboveAlign);
generator.Parameters.CaptionAbove.TextColor = ColorTranslator.FromHtml(barcode.CaptionAboveColor);
generator.Parameters.CaptionAbove.Font.FamilyName = barcode.CaptionAboveFontFamily;
generator.Parameters.CaptionAbove.Font.Size.Pixels = (float)barcode.CaptionAboveFontSize;
}
generator.Parameters.CaptionBelow.Visible = barcode.CaptionBelowVisible;
if (barcode.CaptionBelowVisible)
{
generator.Parameters.CaptionBelow.Text = barcode.CaptionBelowText;
generator.Parameters.CaptionBelow.Alignment = (TextAlignment)Enum.Parse(typeof(TextAlignment), barcode.CaptionBelowAlign);
generator.Parameters.CaptionBelow.TextColor = ColorTranslator.FromHtml(barcode.CaptionBelowColor);
generator.Parameters.CaptionBelow.Font.FamilyName = barcode.CaptionBelowFontFamily;
generator.Parameters.CaptionBelow.Font.Size.Pixels = (float)barcode.CaptionBelowFontSize;
}
using (MemoryStream barcodeOutStream = new MemoryStream())
{
generator.Save(barcodeOutStream, BarCodeImageFormat.Jpeg);
retValue = barcodeOutStream.ToArray();
}
return retValue;
}
Could you help me regarding this issue?
Regards,