- Aspose.HTML version 24.1.0
- Usage in inside docker container
Docker file. ( This create issue.)
FROM mcr.microsoft.com/dotnet/aspnet:6.0-bookworm-slim AS base
RUN apt-get update \
&& apt-get install -y libgdiplus \
&& apt-get install -y libc6-dev \
&& apt-get install -y fonts-liberation \
&& apt-get install -y fonts-crosextra-carlito \
&& apt-get install -y libfreetype6 \
&& apt-get install -y libfontconfig1 \
&& apt-get install -y libgxps-utils \
&& apt-get install -y curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY /publish6 /app
WORKDIR /app
EXPOSE 80
ENTRYPOINT ["dotnet", "DockerRelatedCheck.dll"]
Docker file works fine.
FROM mcr.microsoft.com/dotnet/aspnet:6.0.26-bullseye-slim AS base
RUN apt-get update \
&& apt-get install -y libgdiplus \
&& apt-get install -y libc6-dev \
&& apt-get install -y fonts-liberation \
&& apt-get install -y fonts-crosextra-carlito \
&& apt-get install -y libfreetype6 \
&& apt-get install -y libfontconfig1 \
&& apt-get install -y libgxps-utils \
&& apt-get install -y curl \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY /publish6 /app
WORKDIR /app
EXPOSE 80
ENTRYPOINT ["dotnet", "DockerRelatedCheck.dll"]
Following is the sample code.
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/test", (ILogger<Program> looger) =>
{
DrawHtmlToTextComponent richTextBoxRenderer = new DrawHtmlToTextComponent();
var byteArray = richTextBoxRenderer.DrawText();
return Results.File(byteArray, "image/png");
});
app.Run();
public class DrawHtmlToTextComponent
{
private const float ImageResolutionDpi = 300;
private const int ImageWidthWithResolution = 1;
private const int LeftImageMargin = 2;
private const int TopImageMargin = 1;
public DrawHtmlToTextComponent()
{
}
public byte[] DrawText()
{
var RESOLUTION = 300;
var richTextBoxHtmlText = "<b> This is test. </b>";
Aspose.Html.HTMLDocument html_document = new Aspose.Html.HTMLDocument(richTextBoxHtmlText, string.Empty);
Aspose.Html.Saving.ImageSaveOptions options = new Aspose.Html.Saving.ImageSaveOptions(Aspose.Html.Rendering.Image.ImageFormat.Png);
options.PageSetup.FirstPage = new Aspose.Html.Drawing.Page()
{
Size = new Aspose.Html.Drawing.Size((200 / (RESOLUTION / 96)), 300),
Margin = new Aspose.Html.Drawing.Margin(0, 0, 0, 0),
};
options.HorizontalResolution = ImageResolutionDpi;
options.VerticalResolution = ImageResolutionDpi;
Aspose.Html.Converters.Converter.ConvertHTML(html_document, options, "temp.png");
return System.IO.File.ReadAllBytes("temp.png");
}
private void setAsposeLicence()
{
try
{
// get the resource name of the Embedded Aspose License File
string resourceName = Assembly.GetExecutingAssembly()
.GetManifestResourceNames()
.Single(str => str.EndsWith("Aspose.Total.lic", StringComparison.InvariantCulture));
Aspose.Html.License htmlLicence = new Aspose.Html.License();
htmlLicence.SetLicense(resourceName);
}
catch (Exception ex)
{
throw ex;
}
}
}
Non working ( Bookwarm )
image.png (1.1 KB)
Working (Bullseye)
image.jpg (26.3 KB)