Skip to content

Commit

Permalink
Added configurable roles to signature fields
Browse files Browse the repository at this point in the history
  • Loading branch information
thgossler committed Apr 20, 2023
1 parent a56cf0c commit c4bad8e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions PdfEnvelopeSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class CoverPage
public string Date { get; set; } = string.Empty;
public string Disclaimer { get; set; } = string.Empty;
public bool ShowSignatureArea { get; set; } = false;
public string RoleAuthor { get; set; } = "AR";

public string RoleApprover { get; set; } = "AR";
}

public class PageHeader
Expand Down
12 changes: 10 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,23 @@
.SetLineWidth(1.0f)
.Rectangle(pageSideMargin + textSideMargin, sigAreaTop, (pageSize.GetWidth() - 2 * pageSideMargin - 2 * textSideMargin)/2, -sigAreaHeight)
.Stroke();
canvas.Add(new Paragraph(ResolvePlaceholders("Author", coverPdf, 1, settings.PageNumberOffset))
var authorText = "Author";
if (!string.IsNullOrWhiteSpace(settings.CoverPage.RoleAuthor)) {
authorText += $" ({settings.CoverPage.RoleAuthor})";
}
canvas.Add(new Paragraph(ResolvePlaceholders(authorText, coverPdf, 1, settings.PageNumberOffset))
.SetTextAlignment(TextAlignment.LEFT)
.SetFontSize(12)
.SetFixedPosition(1, pageSideMargin + textSideMargin + 10, sigAreaTop - 20, pageSize.GetWidth() / 3));
canvas.GetPdfCanvas().SetStrokeColor(ColorConstants.BLACK)
.SetLineWidth(1.0f)
.Rectangle(pageSideMargin + textSideMargin + (pageSize.GetWidth() - 2 * pageSideMargin - 2 * textSideMargin) / 2, sigAreaTop, (pageSize.GetWidth() - 2 * pageSideMargin - 2 * textSideMargin) / 2, -sigAreaHeight)
.Stroke();
canvas.Add(new Paragraph(ResolvePlaceholders("Approver", coverPdf, 1, settings.PageNumberOffset))
var approverText = "Approver";
if (!string.IsNullOrWhiteSpace(settings.CoverPage.RoleApprover)) {
approverText += $" ({settings.CoverPage.RoleApprover})";
}
canvas.Add(new Paragraph(ResolvePlaceholders(approverText, coverPdf, 1, settings.PageNumberOffset))
.SetTextAlignment(TextAlignment.LEFT)
.SetFontSize(12)
.SetFixedPosition(1, pageSideMargin + textSideMargin + (pageSize.GetWidth() - 2 * pageSideMargin - 2 * textSideMargin) / 2 + 10, sigAreaTop - 20, pageSize.GetWidth() / 3));
Expand Down
4 changes: 3 additions & 1 deletion appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"Author": "Author: Surname, Given name",
"Date": "Date: {date:dd.MM.yyyy}",
"Disclaimer": "This printed copy is not subject to any change control.",
"ShowSignatureArea": true
"ShowSignatureArea": true,
"RoleAuthor": "AR",
"RoleApprover": "AR"
},
"PageHeader": {
"TextLeft1": "Product Name, Version 2022",
Expand Down

0 comments on commit c4bad8e

Please sign in to comment.