82 lines
2.8 KiB
C#
82 lines
2.8 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using QuestPDF.Fluent;
|
|
using QuestPDF.Helpers;
|
|
using QuestPDF.Infrastructure;
|
|
|
|
public class TarBallPDF : IDocument
|
|
{
|
|
public DocumentMetadata GetMetadata() => DocumentMetadata.Default;
|
|
|
|
public void Compose(IDocumentContainer container)
|
|
{
|
|
try
|
|
{
|
|
container.Page(page =>
|
|
{
|
|
// Page Setup
|
|
page.Size(PageSizes.A4);
|
|
page.Margin(2, Unit.Centimetre);
|
|
page.DefaultTextStyle(x => x.FontFamily("Arial").FontSize(12));
|
|
|
|
// Header Section
|
|
page.Header().Column(column =>
|
|
{
|
|
column.Spacing(10);
|
|
|
|
// Logo and Title
|
|
column.Item().AlignCenter().Text("Company Logo Placeholder").FontSize(12).Italic();
|
|
|
|
// Document Details
|
|
column.Item().Text("Document: F-MM06").FontSize(14);
|
|
column.Item().Text("Effective Date: 1 April 2025").FontSize(14);
|
|
column.Item().Text("Revision No.: 02").FontSize(14);
|
|
});
|
|
|
|
// Content Section
|
|
page.Content().Column(column =>
|
|
{
|
|
column.Spacing(20);
|
|
|
|
// Table Section
|
|
column.Item().Table(table =>
|
|
{
|
|
table.ColumnsDefinition(columns =>
|
|
{
|
|
columns.RelativeColumn(1); // Column 1
|
|
columns.RelativeColumn(2); // Column 2
|
|
});
|
|
|
|
table.Cell().Text("STATE").Bold();
|
|
table.Cell().Text("Your State Data Here");
|
|
|
|
table.Cell().Text("STATION ID").Bold();
|
|
table.Cell().Text("Your Station ID Here");
|
|
});
|
|
|
|
// Survey Findings Section
|
|
column.Item().Text("SURVEY FINDING").Bold().FontSize(14);
|
|
column.Item().Text("Tar Ball ☐ Yes ☐ No");
|
|
column.Item().Text("If YES, Tar Ball falls under the classification of:");
|
|
column.Item().Text("☐ Sand ☐ Non-sandy ☐ Coquina");
|
|
});
|
|
|
|
// Footer Section
|
|
page.Footer().AlignCenter().Text(x =>
|
|
{
|
|
x.Span("Page ");
|
|
x.CurrentPageNumber();
|
|
x.Span(" of ");
|
|
x.TotalPages();
|
|
});
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// Log the exception (you can use any logging framework or method you prefer)
|
|
Console.WriteLine($"Error generating PDF: {ex.Message}");
|
|
}
|
|
}
|
|
}
|
|
;
|
|
|