Introduced a new `PdfSigningService` for digitally signing PDFs using a PFX certificate and DevExpress's `PdfDocumentSigner`. Updated `Program.cs` to register the service and added a new configuration section `PdfSigning` in `appsettings.json` for certificate management. Added a Razor Page `TestSignature.cshtml` and its page model `TestSignature.cshtml.cs` to provide a user interface for testing PDF signing. The page includes file upload, signature validation, and result display functionality. Implemented supporting classes `PdfSigningOptions` for signature customization and `SignatureInformation` for extracting and displaying signature details, including signer name, location, and certificate validity.
91 lines
3.7 KiB
Plaintext
91 lines
3.7 KiB
Plaintext
@page
|
|
@model DXApp.TemplateKitProject.Pages.TestSignatureModel
|
|
@{
|
|
ViewData["Title"] = "PDF-Signatur testen";
|
|
}
|
|
|
|
<div class="content-block">
|
|
<h2><i class="dx-icon-key"></i> PDF-Signatur Test</h2>
|
|
<p class="text-muted">Einfacher Test zum Signieren einer PDF mit dem DevExpress PdfDocumentSigner.</p>
|
|
|
|
<form method="post" enctype="multipart/form-data" class="mt-4">
|
|
<div class="mb-3">
|
|
<label for="pdfFile" class="form-label">PDF-Datei auswählen</label>
|
|
<input type="file" class="form-control" id="pdfFile" name="PdfFile" accept=".pdf" required />
|
|
<span asp-validation-for="PdfFile" class="text-danger"></span>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="dx-icon-key"></i> PDF signieren
|
|
</button>
|
|
</form>
|
|
|
|
@if (Model.Success)
|
|
{
|
|
<div class="alert alert-success mt-4">
|
|
<h5><i class="dx-icon-check"></i> ? PDF erfolgreich signiert!</h5>
|
|
<p class="mb-2">
|
|
<strong>Original:</strong> @Model.OriginalFileName (@Model.OriginalSizeKb KB)<br />
|
|
<strong>Signiert:</strong> @Model.SignedFileName (@Model.SignedSizeKb KB)<br />
|
|
<strong>Gespeichert:</strong> <code>@Model.OutputPath</code>
|
|
</p>
|
|
</div>
|
|
|
|
@if (Model.SignatureInfo != null && Model.SignatureInfo.Count > 0)
|
|
{
|
|
<div class="alert alert-info mt-3">
|
|
<h6><i class="dx-icon-info"></i> Signatur-Details:</h6>
|
|
@foreach (var sig in Model.SignatureInfo)
|
|
{
|
|
<div class="mb-3 p-2 border-start border-3 border-primary">
|
|
<strong>Signatur:</strong> @sig.FieldName<br />
|
|
<strong>Unterzeichner:</strong> @sig.SignerName<br />
|
|
<strong>Ort:</strong> @sig.Location<br />
|
|
<strong>Grund:</strong> @sig.Reason<br />
|
|
<strong>Datum:</strong> @sig.Date.ToString("dd.MM.yyyy HH:mm:ss")<br />
|
|
<strong>Signatur gültig:</strong>
|
|
@if (sig.IsSignatureValid)
|
|
{
|
|
<span class="badge bg-success">? Ja</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="badge bg-danger">? Nein</span>
|
|
}
|
|
<br />
|
|
<strong>Zertifikat gültig:</strong>
|
|
@if (sig.IsCertificateValid)
|
|
{
|
|
<span class="badge bg-success">? Ja</span>
|
|
}
|
|
else
|
|
{
|
|
<span class="badge bg-danger">? Nein</span>
|
|
}
|
|
<br />
|
|
<strong>Zertifikat gültig bis:</strong> @sig.CertificateValidUntil.ToString("dd.MM.yyyy")<br />
|
|
<small class="text-muted">Issuer: @sig.CertificateIssuer</small>
|
|
</div>
|
|
}
|
|
</div>
|
|
}
|
|
}
|
|
|
|
@if (!string.IsNullOrEmpty(Model.ErrorMessage))
|
|
{
|
|
<div class="alert alert-danger mt-4">
|
|
<i class="dx-icon-warning"></i> <strong>Fehler:</strong> @Model.ErrorMessage
|
|
</div>
|
|
}
|
|
|
|
<div class="alert alert-light mt-4">
|
|
<h6>?? Test-Schritte:</h6>
|
|
<ol class="mb-0">
|
|
<li>PDF-Datei auswählen (z.B. eine ZUGFeRD-Rechnung aus <code>/Invoices</code>)</li>
|
|
<li>Auf "PDF signieren" klicken</li>
|
|
<li>Signierte PDF wird in <code>C:\PdfResults</code> gespeichert</li>
|
|
<li>Mit Adobe Acrobat Reader öffnen und Signatur prüfen</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|