tidy up pdf

This commit is contained in:
HARRIS BIN MUSLISHAM 2025-11-10 15:25:14 +08:00
parent 4a1edba2c8
commit c0e285545e
3 changed files with 53 additions and 94 deletions

View File

@ -26,13 +26,13 @@ namespace PSTW_CentralSystem.Areas.IT.Printing
page.Content().Column(col => page.Content().Column(col =>
{ {
col.Item().Element(e => HeaderStrip(e, m)); col.Item().Element(e => HeaderStrip(e, m));
col.Item().PaddingTop(4).LineHorizontal(0.8f);
col.Item().PaddingTop(4).Text( col.Item().PaddingTop(4).Text(
"Submit this form into http://support.transwater.com.my"); "This form is digitally generated. Submit to http://support.transwater.com.my");
// ===== SECTION A ===== // ===== SECTION A =====
#region SECTION A
col.Item().PaddingTop(4).Text("Section A").Bold().FontSize(7); col.Item().PaddingTop(4).Text("Section A").Bold().FontSize(7);
col.Item().Element(e => SectionA_IdentityEmployment(e, m)); col.Item().Element(e => SectionA_IdentityEmployment(e, m));
@ -61,61 +61,8 @@ namespace PSTW_CentralSystem.Areas.IT.Printing
.Element(x => x.MinHeight(380)) // same floor as left .Element(x => x.MinHeight(380)) // same floor as left
.Element(e => SectionA_RightPane_EmailInternetShared(e, m)); .Element(e => SectionA_RightPane_EmailInternetShared(e, m));
}); });
// -- Hardware + Email
#region SECTION A Hardware Requirements
// Rendered together inside SectionA_HardwareEmail (Hardware block)
#endregion
#region SECTION A Email
// Rendered together inside SectionA_HardwareEmail (Email block)
#endregion
// -- Internet Permissions
#region SECTION A Internet Permissions
#endregion
// -- OS Requirements
#region SECTION A OS Requirements
#endregion
// -- Software & Shared Permissions
#region SECTION A Software (General, Utility, Custom)
#endregion
#region SECTION A Shared Permissions
#endregion
// -- Copier (kept as-is)
// -- Form Arrangement
#region SECTION A Form Arrangement
col.Item().Element(e => FormArrangementBlock(e, m)); col.Item().Element(e => FormArrangementBlock(e, m));
#endregion
// -- Approvals table
#endregion // SECTION A
// ===== SECTION B =====
#region SECTION B
col.Item().Element(e => SectionB_TwoBlocks(e, m)); col.Item().Element(e => SectionB_TwoBlocks(e, m));
// -- Asset Information
#region SECTION B Asset Information
#endregion
// -- Remarks
#region SECTION B Remarks
#endregion
// -- Signatures
#region SECTION B Requestor Acknowledgement / Completed By
#endregion
#endregion // SECTION B
}); });
}); });
}).GeneratePdf(); }).GeneratePdf();
@ -130,28 +77,55 @@ namespace PSTW_CentralSystem.Areas.IT.Printing
static IContainer CellMandatory(IContainer x) => x.Background(Colors.Grey.Lighten2).Border(1).BorderColor(Colors.Grey.Lighten2).Padding(4); static IContainer CellMandatory(IContainer x) => x.Background(Colors.Grey.Lighten2).Border(1).BorderColor(Colors.Grey.Lighten2).Padding(4);
#endregion #endregion
// ================= HEADER ================= // ================= HEADER (boxed like your screenshot) =================
#region HEADER
void HeaderStrip(IContainer c, ItRequestReportModel m) void HeaderStrip(IContainer c, ItRequestReportModel m)
{ {
c.Row(row => c.Border(1).Padding(0).Table(t =>
{ {
row.RelativeItem().Column(left => t.ColumnsDefinition(cols =>
{ {
left.Item().Text("I.T. REQUEST FORM").SemiBold().FontSize(14); cols.RelativeColumn(2); // LEFT: big title
left.Item().Text("(Group IT)").Italic().FontSize(10); cols.RelativeColumn(1); // RIGHT: meta table
}); });
row.ConstantItem(230).Column(right => // LEFT pane: centered title
t.Cell().BorderRight(1).Padding(8).MinHeight(10).AlignCenter().AlignMiddle().Column(left =>
{ {
right.Item().Text($"Document No. {m.DocumentNo}").AlignRight(); left.Item().Text("I.T. REQUEST FORM").SemiBold().FontSize(14).AlignCenter();
right.Item().Text($"Effective Date {(m.EffectiveDate == default ? "" : m.EffectiveDate.ToString("dd/MM/yyyy"))}").AlignRight(); left.Item().Text("(Group IT)").SemiBold().FontSize(14).AlignCenter();
right.Item().Text($"Rev. No {m.RevNo}").AlignRight();
right.Item().Text($"Doc. Page No {m.DocPageNo}").AlignRight();
}); });
// RIGHT pane: 2-column grid with borders
t.Cell().Padding(0).Element(x => RightMetaBox(x, m));
}); });
} }
#endregion
// draws the right-side 2-column table with boxed rows
void RightMetaBox(IContainer c, ItRequestReportModel m)
{
c.Table(t =>
{
t.ColumnsDefinition(cols =>
{
cols.RelativeColumn(1); // label
cols.RelativeColumn(1); // value
});
void Row(string label, string value, bool isLast = false)
{
// label cell (left)
t.Cell().BorderBottom(1).Padding(2).Text(label);
// value cell (right) — add vertical divider between label/value
t.Cell().BorderLeft(1).BorderBottom(1).Padding(0).AlignMiddle().Text(value ?? "");
}
Row("Document No.", m.DocumentNo);
Row("Effective Date", (m.EffectiveDate == default) ? "" : m.EffectiveDate.ToString("dd/MM/yyyy"));
Row("Rev. No", m.RevNo); // <- shows dynamic StatusId value
Row("Doc. Page No", m.DocPageNo); // last row still gets bottom border for boxed look
});
}
// ================= SECTION A ================= // ================= SECTION A =================
#region SECTION A Identity & Employment #region SECTION A Identity & Employment
@ -230,7 +204,7 @@ namespace PSTW_CentralSystem.Areas.IT.Printing
#endregion #endregion
#region SECTION A Hardware Requirements + Email #region SECTION A HardwareOsSoftware
// ===================== SECTION A HARDWARE + OS + SOFTWARE ===================== // ===================== SECTION A HARDWARE + OS + SOFTWARE =====================
void SectionA_HardwareOsSoftware(IContainer c, ItRequestReportModel m) void SectionA_HardwareOsSoftware(IContainer c, ItRequestReportModel m)
@ -349,7 +323,7 @@ namespace PSTW_CentralSystem.Areas.IT.Printing
#endregion #endregion
#region SECTION A Internet Permissions #region SECTION A EmailInternetSharedperm
// ===================== SECTION A RIGHT PANE ===================== // ===================== SECTION A RIGHT PANE =====================
void SectionA_RightPane_EmailInternetShared(IContainer c, ItRequestReportModel m) void SectionA_RightPane_EmailInternetShared(IContainer c, ItRequestReportModel m)
{ {
@ -390,13 +364,13 @@ namespace PSTW_CentralSystem.Areas.IT.Printing
}); });
// ===== Shared Permissions ===== // ===== Shared Permissions =====
col.Item().PaddingTop(6).Element(x => x.Background(Colors.Black).Padding(3)) col.Item().PaddingTop(0).Element(x => x.Background(Colors.Black).Padding(3))
.Text("Shared Permissions").FontColor(Colors.White).Bold(); .Text("Shared Permissions").FontColor(Colors.White).Bold();
col.Item().Border(1).Padding(0).Element(x => SharedPermissionsTable(x, m)); col.Item().Border(1).Padding(0).Element(x => SharedPermissionsTable(x, m));
// ===== Copier ===== // ===== Copier =====
col.Item().PaddingTop(6).Element(x => x.Border(1).Padding(8)).Column(cc => col.Item().PaddingTop(0).Element(x => x.Border(1).Padding(8)).Column(cc =>
{ {
cc.Item().Row(rr => cc.Item().Row(rr =>
{ {
@ -481,7 +455,7 @@ namespace PSTW_CentralSystem.Areas.IT.Printing
#region SECTION A OS Requirements #region SECTION A OS Requirements
// ===================== SECTION A Form Arrangement ===================== // ===================== SECTION A Form Arrangement =====================
// ===================== SECTION A Form Arrangement (BOXED) =====================
void FormArrangementBlock(IContainer c, ItRequestReportModel m) void FormArrangementBlock(IContainer c, ItRequestReportModel m)
{ {
// tiny helper: draws the vertical borders for each cell so it looks like 5 boxed panels // tiny helper: draws the vertical borders for each cell so it looks like 5 boxed panels
@ -550,15 +524,6 @@ namespace PSTW_CentralSystem.Areas.IT.Printing
}); });
} }
#endregion
#region SECTION A Software (General, Utility, Custom) & Shared Permissions
#endregion
#region SECTION A Copier
#endregion #endregion
#region SECTION A Approvals #region SECTION A Approvals
@ -637,8 +602,8 @@ namespace PSTW_CentralSystem.Areas.IT.Printing
#endregion #endregion
// ================= SECTION B ================= // ================= SECTION B =================
#region SECTION B Asset Information #region SECTION B Asset Information/ Acknowledgment
// ===================== SECTION B EXACT TWO-BLOCK, TWO-PANE LAYOUT =====================
void SectionB_TwoBlocks(IContainer c, ItRequestReportModel m) void SectionB_TwoBlocks(IContainer c, ItRequestReportModel m)
{ {
c.Column(col => c.Column(col =>
@ -761,12 +726,5 @@ namespace PSTW_CentralSystem.Areas.IT.Printing
} }
#endregion #endregion
#region SECTION B Requestor Acknowledgement / Completed By
#endregion
// Naive text wrap for justification box
#region HELPER JointLines
#endregion
} }
} }

View File

@ -4,7 +4,7 @@
{ {
// Header/meta // Header/meta
public string DocumentNo { get; set; } = "GITRF_01"; public string DocumentNo { get; set; } = "GITRF_01";
public string RevNo { get; set; } = "05"; public string RevNo { get; set; } = "";
public string DocPageNo { get; set; } = "1 of 1"; public string DocPageNo { get; set; } = "1 of 1";
public DateTime EffectiveDate { get; set; } = DateTime.Today; public DateTime EffectiveDate { get; set; } = DateTime.Today;

View File

@ -204,6 +204,7 @@ namespace PSTW_CentralSystem.Controllers.API
{ {
ItRequestId = status.ItRequestId, ItRequestId = status.ItRequestId,
StatusId = status.StatusId, StatusId = status.StatusId,
RevNo = status.StatusId.ToString(),
OverallStatus = status.OverallStatus ?? "Pending", OverallStatus = status.OverallStatus ?? "Pending",
SubmitDate = req.SubmitDate, // if nullable: req.SubmitDate ?? DateTime.MinValue SubmitDate = req.SubmitDate, // if nullable: req.SubmitDate ?? DateTime.MinValue
@ -329,8 +330,8 @@ namespace PSTW_CentralSystem.Controllers.API
return BadRequest(new { message = "PDF available after both acceptances." }); return BadRequest(new { message = "PDF available after both acceptances." });
var pdf = new ItRequestPdfService().Generate(m); var pdf = new ItRequestPdfService().Generate(m);
var fileName = $"IT_Request_{m.ItRequestId}_SectionB.pdf"; //var fileName = $"IT_Request_{m.ItRequestId}_SectionB.pdf";
return File(pdf, "application/pdf", fileName); return File(pdf, "application/pdf");
} }