PDFSimpleExport - Font Selection Ignored in PDF Export
Raffaele-Doti opened this issue · comments
As suggested in Issue #623 I tried to install fonts in my Docker Image throught Dockerfile. Anyway fonts still continue to be ignored from PDFSimpleExport in FastReport.
P.S. Suggested command sudo apt-get install ttf-mscorefonts-installer
doesn't work after some Googling I ended up with this :
RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
RUN apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig
Steps to Reproduce:
Open the FastReport Community Edition desktop designer.
Create a new report or open an existing one.
Add a text box to the report.
Change the font of the text box to a different font (e.g., Comic Sans MS).
Save the .frx template to a project folder.
Install fonts throught Dockerfile
Import the template by code using the Report class.
Export the report to PDF using the PDFSimpleExport class.
Observe that the exported PDF does not have the font applied as expected.
Environment:
FastReport.Export.PdfSimple.PDFSimpleExport version: 2023.2.23
Operating System: Docker Linux Container
Expected Behavior:
The PDF export should use the font selected in the designer for the text boxes.
Actual Behavior:
The PDF export is using a default font, ignoring the font selected in the designer.
Code Snippet:
// This is a simplified version of the method from my codebase.
try
{
// Create a new report and load the FRX template
Report report = Report.FromFile(@"path/to/file");
// Update existing connection from the report with our json data source.
var jsonConnection = report.Dictionary.FindByName("existingConnectionName") as FastReport.Data.DataConnectionBase;
var builder = new FastReport.Data.JsonConnection.JsonDataSourceConnectionStringBuilder(jsonConnection.ConnectionString)
{
Json = jsonDataSource
};
jsonConnection.ConnectionString = builder.ConnectionString;
// Prepare the report by compiling the data
report.Prepare();
// Export the report to the specified output file path with the provided filename (e.g., PDF)
report.Export(simplyPdfExporter, exportFilePath);
// Dispose of the report after use
report.Dispose();
// Report generation successful
return true;
}
catch (Exception e)
{
// Handle any exceptions that might occur during report generation
logger.LogError(e.Message);
// Report generation failed
return false;
}
Hello!
I send you an example of a working DockerFile below:
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
USER app
WORKDIR /app
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
RUN apt-get update \
&& apt-get install -y wget \
&& rm -rf /var/lib/apt/lists/*
RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula \
select true | debconf-set-selections
RUN apt-get update \
&& wget http://ftp.fr.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.8_all.deb -P /Downloads \
&& apt-get install -y /Downloads/ttf-mscorefonts-installer_3.8_all.deb \
&& rm /Downloads/ttf-mscorefonts-installer_3.8_all.deb \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["ConsoleApp13/ConsoleApp13.csproj", "ConsoleApp13/"]
RUN dotnet restore "./ConsoleApp13/./ConsoleApp13.csproj"
COPY . .
WORKDIR "/src/ConsoleApp13"
RUN dotnet build "./ConsoleApp13.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./ConsoleApp13.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ConsoleApp13.dll"]
Best regards,
Bogdan