@page "/envelope/{EnvelopeKey}/DxReportViewer" @using XtraReport = DevExpress.XtraReports.UI.XtraReport @using DevExpress.Blazor.Reporting @using Microsoft.Extensions.Options @using EnvelopeGenerator.ReceiverUI.Options @using EnvelopeGenerator.ReceiverUI.Services @inject InMemoryReportStorageWebExtension ReportStorage @inject DocumentService DocumentService @inject IOptions AppOptions @if (_report is not null) { } @code { [Parameter] public string EnvelopeKey { get; init; } = null!; XtraReport? _report = null; protected override async Task OnInitializedAsync() { _report = await CreateReport(); } async Task CreateReport() { if (AppOptions.Value.UsePredefinedReports) { return PredefinedReports.ReportsFactory.GetReport("LargeDatasetReport"); } else { var pdfBytes = await DocumentService.GetDocumentAsync(EnvelopeKey); if (pdfBytes is null || pdfBytes.Length == 0) throw new InvalidOperationException($"No PDF bytes found for EnvelopeKey: {EnvelopeKey}"); 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 }); return report; } } }