FAQ TBarCode .NET
Lack of Barcode After Deployment to Microsoft Azure
Lack of Barcode After Deployment to Microsoft Azure
TBarCode employs Windows GDI API calls for drawing lines and rendering text output. However, a problem arises on Azure due to the Web App sandbox's blocking of GDI. This blockage is implemented for security reasons, as Microsoft restricts calls to the video/screen driver owing to security concerns. Consequently, the barcode is either drawn in a fragmented manner or is entirely absent. The complete functionality of GDI functions is only achievable with a server hosted on-premise.
Solution: Utilize the Custom Drawing Callback interface as an alternative to GDI API calls.
- Download the QR Code Web App Sample for .NET 6 (see folder ASPNETCoreWebApp).
- Refer to BarcodeController.cs: GetQRCodeImgNoGDI, which utilizes .NET functions through the Callback interface to draw the barcode. This method is suitable for Azure Services where GDI is inaccessible.
- If you are utilizing the SDK's precompiled Barcode Service (WebDeploy package), update to the latest version and set the UseGDI=false parameter.
Issues with Font Size on Azure
If your intention involves creating a linear barcode with human-readable text, text output via the Callback interface is also necessary (code is included in the ASP.NET Core sample linked above). Sometimes we saw an unwanted font scaling on Azure, in this case you have to use a font, which is installed and set the size.
barcode.Font = new System.Drawing.Font("Microsoft Sans Serif", 10, System.Drawing.FontStyle.Regular, GraphicsUnit.Point);
barcode.Font = new System.Drawing.Font("Microsoft Sans Serif", 12, System.Drawing.FontStyle.Regular, GraphicsUnit.Pixel);