Print and dowsload buttons disabled
hi,
I have this simple blazor wasm tag
<SfPdfViewer2 @ref="@viewer"
Width="100%"
Height="800px"
EnablePrint="true"
EnableDownload="true" > <PdfViewerServices>
<PdfViewerPrintService />
<PdfViewerDownloadService />
</PdfViewerServices></SfPdfViewer2>
and this code to populate the viewer:
using MemoryStream stream = new();
document.Save(stream);
document.Close(true);
string base64Pure = Convert.ToBase64String(stream.ToArray());
await viewer.LoadAsync($"data:application/pdf;base64,{base64Pure}");
using MemoryStream stream = new();
document.Save(stream);
document.Close(true);
string base64Pure = Convert.ToBase64String(stream.ToArray());
await viewer.LoadAsync($"data:application/pdf;base64,{base64Pure}");
I'm using net8 and syncfusion 33.2.10 and this is the index.html:
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>MyApp</title>
<base rel='nofollow' href="/" />
<!-- Bootstrap da CDN -->
<link rel='nofollow' href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" />
<!-- Tema Syncfusion da CDN (solo CSS, ok) -->
<link rel='nofollow' href="https://cdn.syncfusion.com/blazor/33.2.8/styles/bootstrap5.css" rel="stylesheet" />
<!-- CSS applicazione -->
<link rel='nofollow' href="css/MyStyleSheet.css" rel="stylesheet" />
<link rel='nofollow' href="css/app.css" rel="stylesheet" />
<link rel="icon" type="image/png" rel='nofollow' href="favicon.png" />
<link rel='nofollow' href="Asclepio.Client.styles.css" rel="stylesheet" />
<link rel='nofollow' href="manifest.json" rel="manifest" />
<link rel="apple-touch-icon" sizes="512x512" rel='nofollow' href="icon-512.png" />
<link rel="apple-touch-icon" sizes="192x192" rel='nofollow' href="icon-192.png" />
</head>
<body>
<div id="app">
<svg class="loading-progress">
<circle r="40%" cx="50%" cy="50%" />
<circle r="40%" cx="50%" cy="50%" />
</svg>
<div class="loading-progress-text"></div>
</div>
<div id="blazor-error-ui">
An unhandled error has occurred.
<a rel='nofollow' href="" class="reload">Reload</a>
<a class="dismiss">đź—™</a>
</div>
<script src="_framework/blazor.webassembly.js"></script>
<script>navigator.serviceWorker.register('service-worker.js');</script>
<script src="JSUtilities.js"></script>
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js"></script>
<script src="_content/Syncfusion.Blazor.SfPdfViewer/scripts/pdfium.js"></script>
<script src="_content/Syncfusion.Blazor.SfPdfViewer/scripts/syncfusion-blazor-sfpdfviewer.min.js"></script>
</body>
</html>
Why is the viewer content correct but the print and download buttons are disabled
After closing the service screen,
Thanks.
Attachment: ServicePDF_a97a34a9.png
Hi egidio,
Thank you for the update. We were unable to reproduce the issue you reported. For your reference, we have attached a Blazor WebAssembly sample project created using version 33.2.10 with the .NET 8 framework.
Could you please share the PDF document you tested? Additionally, we request that you modify the provided sample by adding the missing code snippet required to reproduce the issue you are encountering.
For Blazor WebAssembly projects, the required .NET workloads and the SkiaSharp.Views.Blazor package must be installed to support PDF Viewer operations. Please ensure that you follow the Getting Started documentation to correctly integrate the Syncfusion Blazor PDF Viewer.
Furthermore, could you please confirm whether PdfViewerServices has been added as a Razor file using a custom approach? Please note that this Razor tag is not part of the official API. We recommend following the official documentation and using only the supported APIs for PDF Viewer integration.
Providing these details will help us better understand the scenario and enable us to deliver a more accurate and effective solution.
Getting started with Syncfusion Blazor WASM PDF Viewer
Regards,
Venkada Subramanian D
Attachment: WebAppWASMNet8_5eea2e17.zip
This is the complete code without <PdfViewerServices>
<SfPdfViewer2 @ref="@viewer"
Width="100%"
Height="800px"
EnablePrint="true"
EnableDownload="true"/>
@code {
[Parameter] public EventCallback<bool> OnExitCallback { get; set; }
[Parameter] public SBLCiclo Ciclo { get; set; }
SfPdfViewer2 viewer;
// Rimossa la proprietà string PdfDataUrl poiché carichiamo via software
void esci() => OnExitCallback.InvokeAsync(false);
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
// Aumentato il delay a 100ms per garantire la corretta
// inizializzazione del modulo JavaScript di Syncfusion in WASM
await Task.Delay(100);
await stampa();
}
}
async Task stampa()
{
try
{
// --- COSTANTI ---
const int MargSx = 40;
const int interlinea = 16;
int posizioneY = 100;
// --- DATI ANAGRAFICI ---
var anagrafica = new SBLAnagrafica();
await anagrafica.LoadByID((int)Ciclo.Paziente.IDAnagrafica);
// --- DOCUMENTO PDF ---
var cartaintestata = await SBLDocumentazione.PDFModelFile("CartaIntestata");
PdfLoadedDocument intestata = new(cartaintestata);
PdfDocument document = new();
PdfDocument.Merge(document, intestata);
PdfPage page = document.Pages[0];
PdfGraphics graphics = page.Graphics;
var font10 = new PdfStandardFont(PdfFontFamily.Courier, 10);
// --- RIGA: DATI OSPITE ---
graphics.DrawString($"Dati Ospite: {Ciclo.Paziente.Nominativo} {anagrafica.CodiceFiscale} al {DateTime.Now.ToddMMyyHHmm()}", font10, PdfBrushes.Black, new PointF(MargSx, posizioneY));
posizioneY += interlinea;
// --- RIGA: ALLERGIE ---
graphics.DrawString($"Allergie: {Ciclo.Paziente.Allergia}", font10, PdfBrushes.Black, new PointF(MargSx, posizioneY));
posizioneY += interlinea;
// --- RIGA: DIABETE ---
graphics.DrawString($"Diabete: {Ciclo.Paziente.Diabete.GetDisplayName()}", font10, PdfBrushes.Black, new PointF(MargSx, posizioneY));
posizioneY += interlinea;
// --- RIGA: ALTRO ---
string altro = $"{(Ciclo.Paziente.HIV ? "HIV " : "")} {(Ciclo.Paziente.HBSAG ? "HBSAG " : "")} {(Ciclo.Paziente.HCV ? "HCV " : "")} {(Ciclo.Paziente.Trasferimento != TrasferimentoEnum.NonDefinito ? "Trasferimento " + Ciclo.Paziente.Trasferimento.GetDisplayName() : "")}".Trim();
graphics.DrawString($"Altro: {altro}", font10, PdfBrushes.Black, new PointF(MargSx, posizioneY));
posizioneY += interlinea;
// --- RIGA: PATOLOGIE (con WORD WRAP) ---
if (Ciclo.ElencoPatologie?.Count > 0)
{
StringBuilder sbpatotogie = new("Patologie: ");
foreach (var patologia in Ciclo.ElencoPatologie)
{
sbpatotogie.Append($"{patologia.NomeMalattia}{patologia.NomePatologia} {(patologia.Note)?.Trim()}, ");
}
string stringapatologie = sbpatotogie.ToString().TrimEnd(',', ' ');
var textElement = new PdfTextElement(stringapatologie, font10, PdfBrushes.Black)
{
StringFormat = new PdfStringFormat { WordWrap = PdfWordWrapType.Word }
};
var layout = textElement.Draw(page, new RectangleF(MargSx, posizioneY, page.GetClientSize().Width - MargSx - 40, 300));
posizioneY = (int)layout.Bounds.Bottom + interlinea;
}
else
{
graphics.DrawString("Patologie: Nessuna segnalazione", font10, PdfBrushes.Black, new PointF(MargSx, posizioneY));
posizioneY += interlinea;
}
// --- RIGA: CONTATTI ---
var contatti = Ciclo.Paziente.ElencoContatti.Where(c => c.Autorizzazione).ToList();
if (contatti.Count > 0)
{
graphics.DrawString("Contatti:", font10, PdfBrushes.Black, new PointF(MargSx, posizioneY));
foreach (var n in contatti)
{
graphics.DrawString($"{n.Nominativo} {n.Rapporto.GetDisplayName()} {n.Telefono}", font10, PdfBrushes.Black, new PointF(MargSx + 56, posizioneY));
posizioneY += interlinea;
}
}
else
{
graphics.DrawString("Contatti: //", font10, PdfBrushes.Black, new PointF(MargSx, posizioneY));
posizioneY += interlinea;
}
// --- PRESCRIZIONI ---
graphics.DrawString("Prescrizioni farmaci da almeno 8 giorni:", font10, PdfBrushes.Black, new PointF(MargSx, posizioneY));
posizioneY += interlinea;
var lista = Ciclo.ElencoPrescrizioni
.Where(p => p.Tipo == TipoPrescrizioneEnum.Farmaco && ((p.Sospensione is null && p.Termine is null) || p.Termine > DateTime.Today.AddDays(-9) || p.Sospensione > DateTime.Today.AddDays(-9)))
.OrderBy(q => q.Avvio)
.ToList();
if (lista.Count > 0)
{
DataTable dt = new();
dt.Columns.Add("Inizio");
dt.Columns.Add("Termine");
dt.Columns.Add("Sospesa");
dt.Columns.Add("Prescrizione");
dt.Columns.Add("Giorni");
dt.Columns.Add("Orari");
dt.Columns.Add("Dose");
dt.Columns.Add("Al bis.");
foreach (var d in lista)
{
dt.Rows.Add(d.Avvio.ToddMMyy(), d.Termine.ToddMMyy(), d.Sospensione.ToddMMyy(), d.Descrizione, d.StringaGiorniSettimana, d.Orari, d.Dose, d.AlBisogno ? "X" : "");
}
PdfGrid pdfGrid = new() { DataSource = dt };
pdfGrid.Style = new PdfGridStyle { CellPadding = new PdfPaddings(2, 2, 2, 2) };
pdfGrid.Columns[0].Width = 36;
pdfGrid.Columns[1].Width = 36;
pdfGrid.Columns[2].Width = 36;
pdfGrid.Columns[3].Width = 160;
pdfGrid.Columns[4].Width = 84;
pdfGrid.Columns[5].Width = 86;
pdfGrid.Columns[6].Width = 56;
pdfGrid.Columns[7].Width = 28;
pdfGrid.Columns[7].Format = new PdfStringFormat(PdfTextAlignment.Center);
pdfGrid.Draw(page, new PointF(MargSx, posizioneY));
}
else
{
graphics.DrawString("dalla struttura non sono previste prescrizioni farmaci", font10, PdfBrushes.Black, new PointF(MargSx + 56, posizioneY));
}
// --- SALVATAGGIO E CARICAMENTO STRUTTURATO ---
using MemoryStream stream = new();
document.Save(stream);
document.Close(true);
string base64Pure = Convert.ToBase64String(stream.ToArray());
await viewer.LoadAsync($"data:application/pdf;base64,{base64Pure}");
}
catch (Exception ex)
{
SmartCoordinator.ShowMessageOk("Errore Stampa Prescrizione farmaci", $"Errore: {ex.Message}");
}
}
}
the packages are in the attached screenshot.
It is impossible to print because the button is blocked.
However, the PDF file is created correctly and visible in the viewer
Attachment: Packages_bfe5ac95.png
Hi egidio,
Thank you for the details. We have reviewed the code and were unable to reproduce the reported issue on our end.
For reference, we have attached a Blazor WebAssembly sample project that we tested. Kindly share the PDF document you used before loading it into the PDF Viewer. Additionally, please verify whether the reported issue occurs with the attached sample project.
If the issue still persists, please share a sample project that reproduces the problem. This will help us replicate the issue accurately and provide a more precise solution for the challenges you are facing with the PDF Viewer.
Furthermore, based on the installed packages list, it appears that you are using the latest version of SkiaSharp.Views.Blazor. For compatibility with Syncfusion packages, we recommend using version 3.119.1, as mentioned in our Getting Started documentation.
Regards,
Venkada Subramanian D
Attachment: WebAppWASMNet8_b1383a8c.zip
hi,
The project attached to the previous post loads the file /pdf-succinctly.pdf properly, but the code-generated portion isn't overwritten. The print and download buttons are active.
The content in my project is created properly, but I can't print it to share it with you.
Gulp, I found the mystery. The error is in the uploaded PDF file (var cartaintestata = await SBLDocumentazione.PDFModelFile("CartaIntestata");). The original file is composed of brush strokes of color and overwritten text. I simply reprinted the original file and worked on that. With the old PDF viewer, however, the problem didn't appear.
Thanks for your attention.
Hi egidio,
We’re glad to hear that the issue has been resolved and that you were able to identify the root cause. Thank you for sharing the details with us.
If you need any further assistance, please don’t hesitate to reach out.
Regards,
Venkada Subramanian D
- 6 Replies
- 2 Participants
-
EG egidio
- Jun 3, 2026 01:58 PM UTC
- Jun 8, 2026 06:38 AM UTC