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.
This commit is contained in:
@@ -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 @@
|
||||
</DxPopup>
|
||||
|
||||
<div class="receiver-viewer-wrapper">
|
||||
@if(!AppOptions.Value.ForceToUseFakeDocument && !string.IsNullOrWhiteSpace(EnvelopeKey) && PdfBytes is { Length: > 0 }) {
|
||||
<DxPdfViewer @key="ViewerKey" CssClass="w-100 h-100" DocumentContent="PdfBytes" />
|
||||
} else if(Report is not null) {
|
||||
@if(Report is not null) {
|
||||
<DxReportViewer @key="ViewerKey" @ref="reportViewer" Report="Report" RootCssClasses="w-100 h-100" />
|
||||
}
|
||||
</div>
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user