This commit is contained in:
Claudio Schaad 2025-09-06 14:15:15 +02:00
parent 1f91779dac
commit 6dd909a05b
8 changed files with 15 additions and 43 deletions

View file

@ -14,7 +14,6 @@ namespace ShiftScheduler.Services
static PdfExportService()
{
QuestPDF.Settings.License = LicenseType.Community;
QuestPDF.Settings.FontDiscoveryPaths.Add("fonts");
}
public byte[] GenerateMonthlySchedulePdf(List<ShiftWithTransport> shiftsWithTransport)
@ -99,26 +98,20 @@ namespace ShiftScheduler.Services
foreach (var day in Enumerable.Range(0, dayInWeek))
{
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
var shift = shiftWithTransport?.Shift;
if (shiftWithTransport != null)
{
var shift = shiftWithTransport.Shift;
if (shift.IsPngIcon)
{
var iconPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "icons", shift.Icon);
if (File.Exists(iconPath))
{
table.Cell().Height(24).Element(CellStyleMiddle).Image(iconPath).FitArea();
continue;
}
}
if (shift != null && shift.IsPngIcon)
{
// For PNG icons, embed the image
var iconPath = Path.Combine(AppContext.BaseDirectory, "wwwroot", "icons", shift.Icon);
if (File.Exists(iconPath))
{
table.Cell().Height(24).Element(CellStyleMiddle).Image(iconPath).FitArea();
}
else
{
table.Cell().Element(CellStyleMiddle).Text(shift.Name);
}
}
else
{
// For text/emoji icons, render as text
var icon = shift?.Icon ?? shift?.Name;
table.Cell().Element(CellStyleMiddle).Text(icon);
table.Cell().Element(CellStyleMiddle).Text(shift.Name);
}
}
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
@ -130,7 +123,7 @@ namespace ShiftScheduler.Services
foreach (var day in Enumerable.Range(0, dayInWeek))
{
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
var morningTime = shiftWithTransport?.Shift.MorningTime.Length > 0 ? $"🌅 {shiftWithTransport?.Shift.MorningTime}" : "";
var morningTime = shiftWithTransport?.Shift.MorningTime.Length > 0 ? $"{shiftWithTransport?.Shift.MorningTime}" : "";
table.Cell().Element(CellStyleMiddle).Text(morningTime);
}
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
@ -142,7 +135,7 @@ namespace ShiftScheduler.Services
foreach (var day in Enumerable.Range(0, dayInWeek))
{
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
var afternoonTime = shiftWithTransport?.Shift.AfternoonTime.Length > 0 ? $"🌆 {shiftWithTransport?.Shift.AfternoonTime}" : "";
var afternoonTime = shiftWithTransport?.Shift.AfternoonTime.Length > 0 ? $"{shiftWithTransport?.Shift.AfternoonTime}" : "";
table.Cell().Element(CellStyleMiddle).Text(afternoonTime);
}
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
@ -155,7 +148,7 @@ namespace ShiftScheduler.Services
{
var shiftWithTransport = shiftsWithTransport.GetValueOrDefault(weekDates.ElementAtOrDefault(day));
var transportInfo = GetTransportSummary(shiftWithTransport);
table.Cell().Element(CellStyleLast).Text(transportInfo).FontFamily("NotoEmoji-Regular");
table.Cell().Element(CellStyleLast).Text(transportInfo);
}
foreach (var day in Enumerable.Range(dayInWeek, 7 - dayInWeek))
{
@ -196,7 +189,7 @@ namespace ShiftScheduler.Services
{
var departure = transport.DepartureTime.ToString("HH:mm");
var arrival = transport.ArrivalTime.ToString("HH:mm");
return $"🚂 {departure}→{arrival}";
return $"{transport.Platform}: {departure}→{arrival}";
}
private static void RenderEmptyCell(TableDescriptor table)

View file

@ -16,25 +16,4 @@
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="9.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="fonts\NotoEmoji-Bold.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="fonts\NotoEmoji-Light.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="fonts\NotoEmoji-Medium.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="fonts\NotoEmoji-Regular.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="fonts\NotoEmoji-SemiBold.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="fonts\NotoEmoji-VariableFont_wght.ttf">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.