Add PDF preview and improve document upload UX
Enhanced `CreateEnvelopeWizardPopup.razor` with PDF preview functionality using `SenderPdfImageEditor` and `PdfRenderService`. Added `_documentPagePreviews` to store rendered pages and `DocumentPdfDataUrl` for base64-encoded PDF data. Updated document upload logic to render pages and handle errors gracefully. Cleared `_documentPagePreviews` on reset. Modified `PdfFileDropZone.razor` to include a spacer for better layout when no document is present. Updated `sender-page.css` to improve layout responsiveness, add dynamic resizing, and refine styles for document preview and drop zone. Removed unused `sender-create-wizard__document-meta` class. These changes improve the user experience by providing PDF previews, enhancing layout consistency, and ensuring robust error handling during document uploads.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
@inject IStringLocalizer<Model> ModelLocalizer
|
||||
@inject IStringLocalizer<Resource> UiLocalizer
|
||||
@inject ReceiverService ReceiverService
|
||||
@inject PdfRenderService PdfRenderService
|
||||
|
||||
<DxPopup Visible="@_isVisible"
|
||||
VisibleChanged="OnPopupVisibleChangedAsync"
|
||||
@@ -396,6 +397,22 @@
|
||||
ReplaceText='@L("SenderWizard_DocumentUploadSimpleHint", "Dokument hinzufuegen: klicken oder per Drag-and-Drop ablegen")'
|
||||
UploadedHintText='@L("SenderWizard_DocumentReplaceHint", "Zum Ersetzen klicken oder eine Datei auf diese Fläche ziehen.")'
|
||||
FileSelected="OnDocumentSelectedAsync" />
|
||||
|
||||
@if (_documentBytes is { Length: > 0 })
|
||||
{
|
||||
<div class="sender-create-wizard__document-preview-card">
|
||||
<div class="sender-create-wizard__document-preview-wrap">
|
||||
<SenderPdfImageEditor IsPlacementMode="false"
|
||||
PageCount="@_documentPagePreviews.Count"
|
||||
Pages="@_documentPagePreviews"
|
||||
PdfDataUrl="@DocumentPdfDataUrl"
|
||||
PdfFileName="@_documentFileName"
|
||||
Fields="Array.Empty<SenderPdfFieldOverlay>()"
|
||||
SignatureOverlays="Array.Empty<SenderPdfSignatureOverlay>()"
|
||||
ShowFieldRemoveButton="false" />
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
@@ -509,6 +526,7 @@
|
||||
private byte[]? _documentBytes;
|
||||
private string? _documentFileName;
|
||||
private string _documentSizeText = string.Empty;
|
||||
private List<PdfPageImageDto> _documentPagePreviews = [];
|
||||
private bool _isDocumentUploading;
|
||||
private bool _isStepActionRunning;
|
||||
private bool _isFinishing;
|
||||
@@ -523,6 +541,9 @@
|
||||
private string? _validationMessage;
|
||||
|
||||
private bool IsActionLocked => _isDocumentUploading || _isStepActionRunning || _isFinishing;
|
||||
private string? DocumentPdfDataUrl => _documentBytes is { Length: > 0 }
|
||||
? $"data:application/pdf;base64,{Convert.ToBase64String(_documentBytes)}"
|
||||
: null;
|
||||
|
||||
private bool IsFirstStep => _currentStep <= 0;
|
||||
private bool IsLastStep => _currentStep >= TotalSteps - 1;
|
||||
@@ -742,6 +763,17 @@
|
||||
_documentFileName = file.Name;
|
||||
_documentSizeText = FormatSize(_documentBytes.Length);
|
||||
|
||||
try
|
||||
{
|
||||
_documentPagePreviews = (await PdfRenderService.RenderPagesAsync(_documentBytes))
|
||||
.OrderBy(p => p.PageNumber)
|
||||
.ToList();
|
||||
}
|
||||
catch
|
||||
{
|
||||
_documentPagePreviews = [];
|
||||
}
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -1257,6 +1289,7 @@
|
||||
_documentBytes = null;
|
||||
_documentFileName = null;
|
||||
_documentSizeText = string.Empty;
|
||||
_documentPagePreviews.Clear();
|
||||
|
||||
ApplyDefaultEnvelopeType();
|
||||
NormalizeSettings();
|
||||
|
||||
@@ -21,6 +21,11 @@
|
||||
{
|
||||
<div class="sender-pdf-dropzone__hint">@CurrentActionText</div>
|
||||
}
|
||||
|
||||
@if (!HasDocument)
|
||||
{
|
||||
<div class="sender-pdf-dropzone__initial-spacer" aria-hidden="true"></div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<InputFile OnChange="OnFileSelectedAsync"
|
||||
|
||||
Reference in New Issue
Block a user