QR code cannot be added to Word Doc in Azure function

I am using Aspose Barcode v21.9.0
Aspose Words v21.10.0

Attached is a sample durable function where i
create a qrcode using aspose barcode
and also SkiaSharp.

You will see that the aspose barcode is NOT able to create the QRcode
but the SkiaSharp component is able to create the QR code.

I have included the final rendered PDF and also the template .docx file with the merge fields.

steps to create issue:

  1. create a storage account in azure
  2. create a container called “testContainer”
  3. Upload the QrCodeTest.docx file into the container.
  4. Compile and run the code in vs2019

this is a timer trigger that runs every min at 2 secs.

QRCodeTest.zip (2.2 MB)

@tony.woods.bell.ca,
Is it possible for you to modify this project such that it can be tested locally without creating a storage account in Azure and a container? It will help us to observe the issue here and provide assistance at the earliest.

locally this code works fine.

To run this code locally.
Just create a new durable function project in vs2019 (timer triggered)
it will create a local storage for you.

and copy and paste my code.

But like I said, the project runs fine locally.
When I deploy it, the QR code does not get created using Aspose Barcode.
but the SkiaSharp is able to create the QRCode.

I added the SkiaSharp to the sample just to show you that
that is it possible to create barcode in azure durable functions using another component.

Thanks

@tony.woods.bell.ca,
I am afraid that I could not run the code in a newly created Azure Function as it fails while initializing BlobContainerClient object. It requires connection string and connection name that I tried but could not succeed while working with the emulator.

Please provide a complete runnable console application that can be used to test this scenario locally.

hi

of course you will need to have an azure account already setup.
I cannot send you mine.
I thought your company would have an account in Azure so that you can try the code.

I am sorry I cannot send you my companies Storage ID connection string.

Are you still able to help?

@tony.woods.bell.ca,
Sure, we have logged this issue in our database for a detailed analysis. You will be notified here once any update is ready for sharing.

This issue is logged as:
BARCODENET-37923 - QR code cannot be added to Word Doc in Azure function

Have a question, did you check System.Drawing.Common, because the problem can be with it? Aspose.Barcode currently uses System.Drawing.Common as main drawing library for .Net Core applications, situation could be changed but at this time it is as it.

Could you try to run this code and check the result?

System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(100, 100, PixelFormat.Format32bppPArgb);
using (System.Drawing.Graphics grf = System.Drawing.Graphics.FromImage(bmp))
{
    grf.Clear(System.Drawing.Color.Aquamarine);
}
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);

Yes your code worked.
I was able to create the sample image.
I have attached updated code and image also.
DurFunctionBarCodeTest.zip (25.2 KB)

@tony.woods.bell.ca,
We have noted your feedback with the ticket and will share our comments soon.

Thank you.

Yet one question, if you directly add System.Text.Encoding.CodePages.dll to references, does it help?

<ItemGroup>
  <PackageReference Include="System.Drawing.Common" Version="5.0.0" />
  <PackageReference Include="System.Text.Encoding.CodePages" Version="5.0.0" />
</ItemGroup>

hi Alex

I added your code to my project file but it did not solve the issue.
I still get the same pdf output with no QR Code (from Aspose Barcode component).

I have attached the pdf again.

output.zip (1.9 MB)

@tony.woods.bell.ca,
Thank you for the feedback. We are analyzing it further.

hello…

Were you able to find a solution to this issue?

@tony.woods.bell.ca,
This issue is not resolved yet and is still pending. We will write back here once any update is ready for sharing.

ok thank you!

@tony.woods.bell.ca

Issue is with BMP format. It seems that SkiaSharp can’t handle this format (and GIF as well) properly.
Check out this topic on SkiaSharp forum

The simplest way to fix this issue is just to use PNG instead:

generator.Save(stream, BarCodeImageFormat.Png);

Yes this does work thank you.

is there any settings for Aspose barcode that I can set to get the best quality QRcode
in my .docx file.

@tony.woods.bell.ca,
We are gathering information and will share our feedback soon.

@tony.woods.bell.ca,
We have discussed this requirement and observed that there is no other option than the one shared by @alkhimov here.

ok thank you.