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

View File

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