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}"
|
@page "/receiver/{EnvelopeKey}"
|
||||||
@using System.Drawing
|
@using System.Drawing
|
||||||
@using DevExpress.Blazor
|
@using DevExpress.Blazor
|
||||||
@using DevExpress.Blazor.PdfViewer
|
|
||||||
@using DevExpress.Drawing
|
@using DevExpress.Drawing
|
||||||
@using DevExpress.Utils
|
@using DevExpress.Utils
|
||||||
@using DevExpress.XtraPrinting
|
@using DevExpress.XtraPrinting
|
||||||
@@ -128,9 +127,7 @@
|
|||||||
</DxPopup>
|
</DxPopup>
|
||||||
|
|
||||||
<div class="receiver-viewer-wrapper">
|
<div class="receiver-viewer-wrapper">
|
||||||
@if(!AppOptions.Value.ForceToUseFakeDocument && !string.IsNullOrWhiteSpace(EnvelopeKey) && PdfBytes is { Length: > 0 }) {
|
@if(Report is not null) {
|
||||||
<DxPdfViewer @key="ViewerKey" CssClass="w-100 h-100" DocumentContent="PdfBytes" />
|
|
||||||
} else if(Report is not null) {
|
|
||||||
<DxReportViewer @key="ViewerKey" @ref="reportViewer" Report="Report" RootCssClasses="w-100 h-100" />
|
<DxReportViewer @key="ViewerKey" @ref="reportViewer" Report="Report" RootCssClasses="w-100 h-100" />
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -159,9 +156,6 @@
|
|||||||
|
|
||||||
DxReportViewer? reportViewer;
|
DxReportViewer? reportViewer;
|
||||||
XtraReport? Report;
|
XtraReport? Report;
|
||||||
string PdfViewerUrl = string.Empty;
|
|
||||||
byte[]? PdfBytes;
|
|
||||||
byte[]? SignedPdfBytes;
|
|
||||||
bool SignatureApplied;
|
bool SignatureApplied;
|
||||||
bool SignaturePopupVisible;
|
bool SignaturePopupVisible;
|
||||||
string? SignatureValidationMessage;
|
string? SignatureValidationMessage;
|
||||||
@@ -177,8 +171,16 @@
|
|||||||
protected override async Task OnInitializedAsync() {
|
protected override async Task OnInitializedAsync() {
|
||||||
|
|
||||||
if (!AppOptions.Value.ForceToUseFakeDocument && !string.IsNullOrWhiteSpace(EnvelopeKey)) {
|
if (!AppOptions.Value.ForceToUseFakeDocument && !string.IsNullOrWhiteSpace(EnvelopeKey)) {
|
||||||
(PdfBytes, _) = await DocumentService.GetDocumentAsync(EnvelopeKey);
|
var (pdfBytes, _) = await DocumentService.GetDocumentAsync(EnvelopeKey);
|
||||||
return;
|
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();
|
Report = CreateReportInstance();
|
||||||
|
|||||||
Reference in New Issue
Block a user