From 390f2d2cae180a34ea356fd14cb9422e3777b96a Mon Sep 17 00:00:00 2001 From: TekH Date: Sun, 31 May 2026 08:14:07 +0200 Subject: [PATCH] Replace DxPdfViewer with DxReportViewer for PDF handling Replaced `DxPdfViewer` with `DxReportViewer` to unify handling of both PDF and report rendering. Removed conditional logic for `PdfBytes` and directly initialized `XtraReport` with PDF content using `XRPdfContent`. Simplified `OnInitializedAsync` to fetch PDF content, create a report, and store it in `ReportStorage`. Removed unused fields (`PdfViewerUrl`, `PdfBytes`, and `SignedPdfBytes`) and redundant code related to PDF handling. --- .../Pages/ReportViewer.razor | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/EnvelopeGenerator.ReceiverUI/Pages/ReportViewer.razor b/EnvelopeGenerator.ReceiverUI/Pages/ReportViewer.razor index 6514c3cb..aae71118 100644 --- a/EnvelopeGenerator.ReceiverUI/Pages/ReportViewer.razor +++ b/EnvelopeGenerator.ReceiverUI/Pages/ReportViewer.razor @@ -2,7 +2,6 @@ @page "/receiver/{EnvelopeKey}" @using System.Drawing @using DevExpress.Blazor -@using DevExpress.Blazor.PdfViewer @using DevExpress.Drawing @using DevExpress.Utils @using DevExpress.XtraPrinting @@ -128,9 +127,7 @@
-@if(!AppOptions.Value.ForceToUseFakeDocument && !string.IsNullOrWhiteSpace(EnvelopeKey) && PdfBytes is { Length: > 0 }) { - -} else if(Report is not null) { +@if(Report is not null) { }
@@ -159,9 +156,6 @@ DxReportViewer? reportViewer; XtraReport? Report; - string PdfViewerUrl = string.Empty; - byte[]? PdfBytes; - byte[]? SignedPdfBytes; bool SignatureApplied; bool SignaturePopupVisible; string? SignatureValidationMessage; @@ -177,8 +171,16 @@ protected override async Task OnInitializedAsync() { if (!AppOptions.Value.ForceToUseFakeDocument && !string.IsNullOrWhiteSpace(EnvelopeKey)) { - (PdfBytes, _) = await DocumentService.GetDocumentAsync(EnvelopeKey); - return; + var (pdfBytes, _) = await DocumentService.GetDocumentAsync(EnvelopeKey); + if (pdfBytes is { Length: > 0 }) { + var report = new XtraReport(); + var detail = new DevExpress.XtraReports.UI.DetailBand(); + report.Bands.Add(detail); + detail.Controls.Add(new DevExpress.XtraReports.UI.XRPdfContent { Source = pdfBytes, GenerateOwnPages = true }); + ReportStorage.SetData(report, EnvelopeKey); + Report = ReportStorage.TryGetReport(EnvelopeKey, out var stored) ? stored : report; + return; + } } Report = CreateReportInstance();