Hi Leonardo,
Thank you for contacting Syncfusion support.
We can create a PDF document with auto tags in Blazor using PDF library. For this, we need to install Syncfusion.PDF.Net.Core NuGet package to the Blazor project. We have attached the simple sample for your reference. Kindly please try the sample on your end let us know the result.
Please refer the below links for more information,
Note: Run the application à Go to Fetch Dataà Click Export to PDF button to create PDF document.
Please let us know if you need any further assistance with this.
Regards,
Gowthamraj K
Thank you very much for the feedback.
last question sir. the ExportService seems have given string data, but how do I add this weather data in PDF into ExportService.cs?
@page "/fetchdata"
@using BlazorApp1.Data
@inject WeatherForecastService ForecastService
@inject ExportService exportService
@inject Microsoft.JSInterop.IJSRuntime JS
@using System.IO;
<h1>Weather forecast</h1>
<p>This component demonstrates fetching data from a service.</p>
<button class="btn btn-primary" @onclick="@ExportToPdf">Export to PDF</button>
@functions
{
protected async Task ExportToPdf()
{
using (MemoryStream excelStream = ExportService.CreatePdf(forecasts))
{
await JS.SaveAs("Sample.pdf", excelStream.ToArray());
}
}
}
@if (forecasts == null)
{
<p><em>Loading...</em></p>
}
else
{
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Temp. (C)</th>
<th>Temp. (F)</th>
<th>Summary</th>
</tr>
</thead>
<tbody>
@foreach (var forecast in forecasts)
{
<tr>
<td>@forecast.Date.ToShortDateString()</td>
<td>@forecast.TemperatureC</td>
<td>@forecast.TemperatureF</td>
<td>@forecast.Summary</td>
</tr>
}
</tbody>
</table>
}
@code {
private WeatherForecast[] forecasts;
protected override async Task OnInitializedAsync()
{
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
}
}