Error when saving QR code

I am using https://help.syncfusion.com/file-formats/pdf/working-with-barcode#set-location-and-size-to-the-barcode to generate a QR code. I am however getting an error when generating the QR code image on my docker image. Does the ASP.Net Core PDF component have a dependency on other libraries for it to work? What am I missing?

StackTrace:

2022-01-03 05:31:14.753 +00:00 [ERR] 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.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, Int32 format, IntPtr scan0, IntPtr& bitmap)

at Syncfusion.Pdf.Barcode.PdfQRBarcodeHelper.ToImage(SizeF size)

at Syncfusion.Pdf.Graphics.PdfBarcodeExtension.ToImage(PdfBidimensionalBarcode barcode, SizeF size)

at InstaTranscribeServerSide.Pages.GenerateQRCode.UpdateQRCodeComponent.UploadFiles_Success(SuccessEventArgs args) in C:\t\InstaTranscribeServerSide-PurposeUI\InstaTranscribeServerSide\Pages\GenerateQRCode\UpdateQRCode.razor.cs:line 76

source code:

          var pdfQRBarcode = new PdfQRBarcode

          {

            ErrorCorrectionLevel = PdfErrorCorrectionLevel.Medium,

            XDimension = 3,

            Text = uploadedS3FilePath

          };

          var barcodeImage = pdfQRBarcode.ToImage(new System.Drawing.SizeF(300, 300));

          var memoryStream = new MemoryStream();

          barcodeImage.Save(memoryStream, ImageFormat.Jpeg);

          memoryStream.Position = 0;

Dockerfile: 

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base

#For InstaTranscribe

RUN apt-get -y update && apt-get -y upgrade && apt-get install -y ffmpeg

#For URLOrTextToPDF: WebKit Rendering

RUN apt-get update --yes && apt-get install xvfb --yes && apt-get install libssl1.1 --yes && apt-get install libx11-dev libx11-xcb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-render-util0-dev libxcb-render0-dev libxcb-shm0-dev libxcb-util0-dev libxcb-xfixes0-dev libxcb-xkb-dev libxcb1-dev libxfixes-dev libxrandr-dev libxrender-dev --yes

#For URLOrTextToPDF: Blink Rendering

RUN apt-get install libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 libnss3 --yes

WORKDIR /app

EXPOSE 80

EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build

WORKDIR /src

COPY ["InstaTranscribeServerSide/InstaTranscribeServerSide.csproj", "InstaTranscribeServerSide/"]

COPY ["Services/Services.csproj", "Services/"]

COPY ["DataAccess/DataAccess.csproj", "DataAccess/"]

RUN dotnet restore "InstaTranscribeServerSide/InstaTranscribeServerSide.csproj"

COPY . .

WORKDIR "/src/InstaTranscribeServerSide"

RUN dotnet build "InstaTranscribeServerSide.csproj" -c Release -o /app/build

FROM build AS publish

RUN dotnet publish "InstaTranscribeServerSide.csproj" -c Release -o /app/publish

FROM base AS final

VOLUME CREATE uploadedfiles

WORKDIR /app

COPY --from=publish /app/publish .

ENTRYPOINT ["dotnet", "InstaTranscribeServerSide.dll"]


3 Replies

GK Gowthamraj Kumar Syncfusion Team January 3, 2022 01:03 PM UTC

Hi Ajit, 

On our further analysis, we were able to reproduce the reported exception with System.Drawing.Common (version 6) Net6.0 . In our PDF.Imaging library ,we are internally using the System.Drawing.Common( version 4.5) package to perform barcode to image. Starting with .NET 6 System.Drawing.Common will only work on Windows, please refer the below link 
 
We have already considered this as feature request with “Add support for Barcode to Image in NET 6.0 for Non-windows platforms“ and we will implement this support and include this feature in our upcoming 2022 Volume 1 main release, which will be expected on end of April 2022 tentatively. 
 
Please use the below feedback link to track the status of this feature.  
 
Please let us know, if you need any further details on this.  

Regards, 
Gowthamraj K 



AG ajit goel January 4, 2022 05:25 AM UTC

Once the change has been implemented, would you have a beta release so syncfusion customers get access to it faster?

Also does the library work on linux if we use .Net 5.0?



GK Gowthamraj Kumar Syncfusion Team January 4, 2022 11:02 AM UTC

Hi Ajit, 

Once the change has been implemented, would you have a beta release so syncfusion customers get access to it faster? 
 
Yes. We will notify you with release version, once this support is included in our Volume release. 
    
You can track the status of the implementation in the below feedback.      
 
Also does the library work on linux if we use .Net 5.0? 

Yes. We can convert the Barcode to Image using Net 5.0 in Linux docker with help of our PDF library. We have created a simple docker 5.0 sample to convert Barcode to Image with required prerequisites packages. We have attached the sample and output image for your reference. Please try the below sample on your end and let us know the result. 
Docker file: 
 
FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base 
RUN apt-get update && \  
apt-get install -yq --no-install-recommends \  
libgdiplus libc6-dev   
WORKDIR /app 
EXPOSE 80 
EXPOSE 443 
 
 

Please let us know if you need any further assistance with this. 

Regards, 
Gowthamraj K 


Loader.
Up arrow icon