278 lines
12 KiB
C#
278 lines
12 KiB
C#
using QuestPDF.Fluent;
|
|
using QuestPDF.Infrastructure;
|
|
using QuestPDF.Helpers;
|
|
using Google.Protobuf.WellKnownTypes;
|
|
using PSTW_CentralSystem.Models;
|
|
|
|
namespace PSTW_CentralSystem.Areas.MMS.Models.PDFGenerator
|
|
{
|
|
public class TarBallPDF(string stationID, string stateName, string locationName, string longitude, string latitude, DateTime dateSample, TimeSpan timeSample) : IDocument
|
|
{
|
|
private readonly string _stationId = stationID;
|
|
private readonly string _stateName = stateName;
|
|
private readonly string _locationName = locationName;
|
|
private readonly string _longitude = longitude;
|
|
private readonly string _latitude = latitude;
|
|
private readonly DateTime _dateSample = dateSample;
|
|
private readonly TimeSpan _timeSample = timeSample;
|
|
|
|
|
|
// Metadata for the PDF document
|
|
public DocumentMetadata GetMetadata() => new()
|
|
{
|
|
Title = "TarBall Sampling Form",
|
|
Author = "PAKAR SCIENO TW Integrated Environmental Solutions",
|
|
Subject = "Environmental Survey and Observations"
|
|
};
|
|
|
|
// Compose the PDF content
|
|
public void Compose(IDocumentContainer container)
|
|
{
|
|
container.Page(page =>
|
|
{
|
|
// Page Setup
|
|
page.Size(PageSizes.A4);
|
|
page.Margin(1.1f, Unit.Centimetre);
|
|
page.DefaultTextStyle(x => x.FontFamily("Arial").FontSize(10));
|
|
|
|
// Header Section
|
|
page.Header().Row(row =>
|
|
{
|
|
row.RelativeItem(1).Element(CellStyle).Column(column =>
|
|
{
|
|
column.Item()
|
|
.AlignMiddle()
|
|
.AlignCenter()
|
|
.Text("Logo Placeholder");
|
|
});
|
|
|
|
row.RelativeItem(1).Element(CellStyle)
|
|
.AlignMiddle()
|
|
.AlignCenter()
|
|
.Text("TARBALL SAMPLING FORM")
|
|
.FontSize(16)
|
|
.FontColor("#4B0082");
|
|
|
|
row.RelativeItem(1).Column(column =>
|
|
{
|
|
column.Spacing(0);
|
|
|
|
column.Item().Row(innerRow =>
|
|
{
|
|
innerRow.RelativeItem(1).Element(CellStyle).Text("Document:")
|
|
.AlignLeft();
|
|
innerRow.RelativeItem(1).Element(CellStyle).Text("F-MM06")
|
|
.AlignLeft().Bold();
|
|
});
|
|
column.Item().Row(innerRow =>
|
|
{
|
|
innerRow.RelativeItem(1).Element(CellStyle).Text("Effective Date:")
|
|
.AlignLeft();
|
|
innerRow.RelativeItem(1).Element(CellStyle).Text("1 April 2025")
|
|
.AlignLeft();
|
|
});
|
|
column.Item().Row(innerRow =>
|
|
{
|
|
innerRow.RelativeItem(1).Element(CellStyle).Text("Revision No.")
|
|
.AlignLeft();
|
|
innerRow.RelativeItem(1).Element(CellStyle).Text("02")
|
|
.AlignLeft();
|
|
});
|
|
});
|
|
|
|
static IContainer CellStyle(IContainer container)
|
|
=> container.Border(0.5f).Padding(5);
|
|
});
|
|
|
|
// Content Section
|
|
page.Content().Column(column =>
|
|
{
|
|
// Observations Table
|
|
column.Item().Element(container =>
|
|
{
|
|
container
|
|
.PaddingTop(20)
|
|
.PaddingBottom(10)
|
|
.Text("Please be informed that we have observed the following conditions:");
|
|
});
|
|
column.Item().Table(table =>
|
|
{
|
|
column.Spacing(0);
|
|
|
|
table.ColumnsDefinition(columns =>
|
|
{
|
|
columns.RelativeColumn(3);
|
|
columns.RelativeColumn(3);
|
|
});
|
|
|
|
table.Cell()
|
|
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("STATE")
|
|
.Bold();
|
|
table.Cell().Element(CellStyle).Text(_stateName);
|
|
|
|
table.Cell()
|
|
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("STATION ID")
|
|
.Bold();
|
|
table.Cell().Element(CellStyle).Text(_stationId);
|
|
|
|
table.Cell()
|
|
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("LOCATION")
|
|
.Bold();
|
|
table.Cell().Element(CellStyle).Text(_locationName);
|
|
|
|
table.Cell()
|
|
.Background(Colors.Grey.Lighten2).Element(CellStyle).Text("TARBALL SURVEY LOCATION LONGITUDE & LATITUDE")
|
|
.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();
|
|
table.Cell().Element(CellStyle).Text($"{_dateSample:yyyy-MM-dd} {_timeSample:hh\\:mm\\:ss}");
|
|
});
|
|
|
|
column.Spacing(3);
|
|
|
|
// Survey Findings
|
|
column.Item()
|
|
.PaddingTop(10)
|
|
.PaddingBottom(10)
|
|
.Text("SURVEY FINDING:")
|
|
.Bold().FontSize(12);
|
|
column.Item()
|
|
.PaddingBottom(10)
|
|
.Text("Tar Ball: [☐] YES [☐] NO").FontSize(10);
|
|
column.Item()
|
|
.PaddingBottom(10)
|
|
.Text("If YES, Tar Ball falls under the classification of:").FontSize(10);
|
|
column.Item()
|
|
.PaddingBottom(10)
|
|
.Text("[☐] Sand [☐] Non-sandy [☐] Coquina").FontSize(10);
|
|
column.Item()
|
|
.PaddingBottom(10)
|
|
.Text("*tick wherever applicable");
|
|
|
|
// Photos Section Title
|
|
column.Item()
|
|
.PaddingBottom(5)
|
|
.Text("PHOTOGRAPHS OF SAMPLING")
|
|
.AlignCenter()
|
|
.Bold()
|
|
.FontSize(14);
|
|
|
|
// Table for Photos
|
|
column.Item().Table(table =>
|
|
{
|
|
column.Spacing(0);
|
|
|
|
table.ColumnsDefinition(columns =>
|
|
{
|
|
columns.RelativeColumn(1);
|
|
columns.RelativeColumn(1);
|
|
});
|
|
|
|
table.Cell().Element(CellStyle).Height(150);
|
|
table.Cell().Element(CellStyle).Height(150);
|
|
|
|
table.Cell().Element(CellStyle).Text("Figure 1: Left Side Coastal View").FontSize(12).AlignLeft();
|
|
table.Cell().Element(CellStyle).Text("Figure 2: Right Side Coastal View").FontSize(12).AlignLeft();
|
|
|
|
table.Cell().Element(CellStyle).Height(150);
|
|
table.Cell().Element(CellStyle).Height(150);
|
|
|
|
table.Cell().Element(CellStyle).Text("Figure 3: Drawing Vertical Lines").FontSize(12).AlignLeft();
|
|
table.Cell().Element(CellStyle).Text("Figure 4: Drawing Horizontal Lines (Racking)").FontSize(12).AlignLeft();
|
|
});
|
|
|
|
// Page Break
|
|
column.Item().PageBreak();
|
|
|
|
// Additional Photos Section
|
|
column.Item().Table(table =>
|
|
{
|
|
column.Spacing(0);
|
|
|
|
table.ColumnsDefinition(columns =>
|
|
{
|
|
columns.RelativeColumn(1);
|
|
columns.RelativeColumn(1);
|
|
});
|
|
|
|
table.Cell().Element(CellStyle).Height(150);
|
|
table.Cell().Element(CellStyle).Height(150);
|
|
|
|
table.Cell().Element(CellStyle).Text("Figure 5:").FontSize(12).AlignLeft();
|
|
table.Cell().Element(CellStyle).Text("Figure 6:").FontSize(12).AlignLeft();
|
|
|
|
table.Cell().Element(CellStyle).Height(150);
|
|
table.Cell().Element(CellStyle).Height(150);
|
|
|
|
table.Cell().Element(CellStyle).Text("Figure 7:").FontSize(12).AlignLeft();
|
|
table.Cell().Element(CellStyle).Text("Figure 8:").FontSize(12).AlignLeft();
|
|
});
|
|
|
|
// Note Section
|
|
column.Item()
|
|
.PaddingTop(10)
|
|
.PaddingBottom(20)
|
|
.Text("* If there are any event observe at the current station it is compulsory to add optional photo with description (figure 5 to figure 8)")
|
|
.FontSize(10)
|
|
.AlignLeft();
|
|
|
|
// Signature Section
|
|
column.Item().Table(table =>
|
|
{
|
|
table.ColumnsDefinition(columns =>
|
|
{
|
|
columns.RelativeColumn(2);
|
|
columns.RelativeColumn(1);
|
|
columns.RelativeColumn(2);
|
|
columns.RelativeColumn(1);
|
|
columns.RelativeColumn(1);
|
|
});
|
|
|
|
table.Cell().RowSpan(2).Element(CellStyle).Text("REPORTED BY :").Bold().FontSize(12);
|
|
table.Cell().Element(CellStyle).Text("Signature").FontSize(12);
|
|
table.Cell().Element(CellStyle).Text("");
|
|
table.Cell().Element(CellStyle).Text("Date").FontSize(12);
|
|
table.Cell().Element(CellStyle).Text("");
|
|
|
|
table.Cell().Element(CellStyle).Text("Designation").FontSize(12);
|
|
table.Cell().ColumnSpan(3).Element(CellStyle).Text("");
|
|
|
|
table.Cell().RowSpan(2).Element(CellStyle).Text("CHECKED BY :").Bold().FontSize(12);
|
|
table.Cell().Element(CellStyle).Text("Signature").FontSize(12);
|
|
table.Cell().Element(CellStyle).Text("");
|
|
table.Cell().Element(CellStyle).Text("Date").FontSize(12);
|
|
table.Cell().Element(CellStyle).Text("");
|
|
|
|
table.Cell().Element(CellStyle).Text("Designation").FontSize(12);
|
|
table.Cell().ColumnSpan(3).Element(CellStyle).Text("");
|
|
|
|
table.Cell().RowSpan(2).Element(CellStyle).Text("VERIFIED BY :").Bold().FontSize(12);
|
|
table.Cell().Element(CellStyle).Text("Signature").FontSize(12);
|
|
table.Cell().Element(CellStyle).Text("");
|
|
table.Cell().Element(CellStyle).Text("Date").FontSize(12);
|
|
table.Cell().Element(CellStyle).Text("");
|
|
|
|
table.Cell().Element(CellStyle).Text("Designation").FontSize(12);
|
|
table.Cell().ColumnSpan(3).Element(CellStyle).Text("");
|
|
});
|
|
});
|
|
|
|
// Footer Section
|
|
page.Footer().AlignCenter().Text(text =>
|
|
{
|
|
text.Span("Page ");
|
|
text.CurrentPageNumber();
|
|
text.Span(" of ");
|
|
text.TotalPages();
|
|
});
|
|
|
|
static IContainer CellStyle(IContainer container) => container.Border(0.5f).Padding(5);
|
|
});
|
|
}
|
|
}
|
|
}
|