This commit is contained in:
misya 2025-04-29 16:23:08 +08:00
parent e220868d72
commit 0556e4763e
2 changed files with 16 additions and 17 deletions

View File

@ -27,19 +27,18 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
private readonly bool _isSand = isSand; private readonly bool _isSand = isSand;
private readonly bool _isNonSandy = isNonSandy; private readonly bool _isNonSandy = isNonSandy;
private readonly bool _isCoquina = isCoquina; private readonly bool _isCoquina = isCoquina;
private readonly string? _photoPath1 = photoPath1; private readonly string? _photoPath1 = photoPath1; //having '?' makes it nullable, ELSE the string must always have a value
private readonly string? _photoPath2 = photoPath2; private readonly string? _photoPath2 = photoPath2; //"but why keep '?' for photopath 1 to 4?
private readonly string? _photoPath3 = photoPath3; private readonly string? _photoPath3 = photoPath3; //A: to make
private readonly string? _photoPath4 = photoPath4; private readonly string? _photoPath4 = photoPath4;
private readonly string? _photoPath5 = photoPath5; private readonly string? _photoPath5 = photoPath5;
private readonly string? _photoPath6 = photoPath6; private readonly string? _photoPath6 = photoPath6;
private readonly string? _photoPath7 = photoPath7; private readonly string? _photoPath7 = photoPath7;
private readonly string? _photoPath8 = photoPath8; private readonly string? _photoPath8 = photoPath8;
//INSERT LOADIMAGE() HERE
private Image? LoadImage(string? imagePath) private Image? LoadImage(string? imagePath)
{ {
if (string.IsNullOrEmpty(imagePath)) // Fixed: Added closing ) if (string.IsNullOrEmpty(imagePath))
{ {
return null; return null;
} }
@ -54,7 +53,6 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
} }
} }
// Metadata for the PDF document
public DocumentMetadata GetMetadata() => new() public DocumentMetadata GetMetadata() => new()
{ {
Title = "TARBALL SAMPLING FORM", Title = "TARBALL SAMPLING FORM",
@ -72,7 +70,8 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
page.Margin(1.1f, Unit.Centimetre); page.Margin(1.1f, Unit.Centimetre);
page.DefaultTextStyle(x => x.FontFamily("Arial").FontSize(10)); page.DefaultTextStyle(x => x.FontFamily("Arial").FontSize(10));
// Header Section //HEADER SECTION ==========================================================================
//will be included in each page
page.Header().Row(row => page.Header().Row(row =>
{ {
row.RelativeItem(1).Element(CellStyle).Column(column => row.RelativeItem(1).Element(CellStyle).Column(column =>
@ -122,8 +121,10 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
=> container.Border(0.5f).Padding(5); => container.Border(0.5f).Padding(5);
}); });
//HEADER SECTION END ==========================================================================
// Content Section
// CONTENT SECTION ============================================================================
page.Content().Column(column => page.Content().Column(column =>
{ {
// Observations Table // Observations Table
@ -164,7 +165,6 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
.Bold(); .Bold();
table.Cell().Element(CellStyle).Text($"{_longitude}, {_latitude}"); table.Cell().Element(CellStyle).Text($"{_longitude}, {_latitude}");
// Display DateSample and TimeSample together in the table
table.Cell() table.Cell()
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("DATE / TIME") .Background(Colors.Grey.Lighten2).Element(CellStyle).Text("DATE / TIME")
.Bold(); .Bold();
@ -173,14 +173,13 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
column.Spacing(3); column.Spacing(3);
// Survey Findings - ALWAYS shows all options // Survey Findings =======================================================================================
column.Item() column.Item()
.PaddingTop(10) .PaddingTop(10)
.PaddingBottom(10) .PaddingBottom(10)
.Text("SURVEY FINDING:") .Text("SURVEY FINDING:")
.Bold().FontSize(12); .Bold().FontSize(12);
// 1. Tar Ball YES/NO (always shown)
column.Item() column.Item()
.PaddingBottom(10) .PaddingBottom(10)
.Text(text => .Text(text =>
@ -189,7 +188,6 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
text.Span(_classifyID == "NO" ? " ☐ YES ☑ NO" : " ☑ YES ☐ NO").Style(TextStyle.Default.FontSize(10)); text.Span(_classifyID == "NO" ? " ☐ YES ☑ NO" : " ☑ YES ☐ NO").Style(TextStyle.Default.FontSize(10));
}); });
// 2. Classification (always shown)
column.Item() column.Item()
.PaddingBottom(10) .PaddingBottom(10)
.Text("If YES, Tar Ball falls under the Classification of:") .Text("If YES, Tar Ball falls under the Classification of:")
@ -228,16 +226,16 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
columns.RelativeColumn(1); columns.RelativeColumn(1);
}); });
// Row 1: Photos // Row 1: Photos ====================================
table.Cell().Element(CellStyle).Height(150) table.Cell().Element(CellStyle).Height(150)
.Image(LoadImage(_photoPath1) ?? null) // Just pass null if no image .Image(LoadImage(_photoPath1) ?? null) // Just pass null if no image
.FitArea(); .FitArea();
table.Cell().Element(CellStyle).Height(150) table.Cell().Element(CellStyle).Height(150)
.Image(LoadImage(_photoPath2) ?? null) // Just pass null if no image .Image(LoadImage(_photoPath2) ?? null)
.FitArea(); .FitArea();
// Row 1: Captions // Row 2: Captions for figure 1 & 2 =================
table.Cell().Element(CellStyle) table.Cell().Element(CellStyle)
.Text("Figure 1: Left Side Coastal View") .Text("Figure 1: Left Side Coastal View")
.FontSize(12).AlignLeft(); .FontSize(12).AlignLeft();
@ -246,7 +244,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
.Text("Figure 2: Right Side Coastal View") .Text("Figure 2: Right Side Coastal View")
.FontSize(12).AlignLeft(); .FontSize(12).AlignLeft();
// Row 2: Photos // Row 3 =============================================
table.Cell().Element(CellStyle).Height(150) table.Cell().Element(CellStyle).Height(150)
.Image(LoadImage(_photoPath3) ?? null) // Just pass null if no image .Image(LoadImage(_photoPath3) ?? null) // Just pass null if no image
.FitArea(); .FitArea();
@ -255,7 +253,7 @@ namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
.Image(LoadImage(_photoPath4) ?? null) // Just pass null if no image .Image(LoadImage(_photoPath4) ?? null) // Just pass null if no image
.FitArea(); .FitArea();
// Row 2: Captions // Row 4: Captions for figure 3 & 4 =================
table.Cell().Element(CellStyle) table.Cell().Element(CellStyle)
.Text("Figure 3: Drawing Vertical Lines") .Text("Figure 3: Drawing Vertical Lines")
.FontSize(12).AlignLeft(); .FontSize(12).AlignLeft();

View File

@ -7,6 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Lemonade" Version="1.0.276" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.11" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.11" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.11" /> <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />