Files
GestionIntegralWeb/Backend/GestionIntegral.Api/Services/Pdf/IPdfGeneratorService.cs
dmolinari 975a1e6d26
All checks were successful
Build and Deploy / remote-build-and-deploy (push) Successful in 28m23s
Test Reportes con Razor y Puppeteer
2025-06-19 14:47:43 -03:00

35 lines
1.5 KiB
C#

using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
using PuppeteerSharp.Media;
namespace GestionIntegral.Api.Services.Pdf
{
/// <summary>
/// Define las opciones de configuración para la generación de un PDF.
/// </summary>
public class PdfGenerationOptions
{
public PaperFormat? Format { get; set; } = PaperFormat.A4;
public MarginOptions? Margin { get; set; }
public string? HeaderTemplate { get; set; }
public string? FooterTemplate { get; set; }
public bool PrintBackground { get; set; } = true;
public bool Landscape { get; set; } = false;
}
/// <summary>
/// Servicio para generar documentos PDF a partir de plantillas Razor.
/// </summary>
public interface IPdfGeneratorService
{
/// <summary>
/// Genera un archivo PDF a partir de una plantilla Razor y un modelo de datos.
/// </summary>
/// <typeparam name="T">El tipo del modelo de datos.</typeparam>
/// <param name="templatePath">La ruta relativa de la plantilla Razor (ej: "Controllers/Reportes/Templates/MiReporte.cshtml").</param>
/// <param name="model">El objeto con los datos para rellenar la plantilla.</param>
/// <param name="options">Opciones de configuración para el PDF (márgenes, formato, etc.).</param>
/// <returns>Un array de bytes representando el archivo PDF generado.</returns>
Task<byte[]> GeneratePdfFromRazorTemplateAsync<T>(string templatePath, T model, PdfGenerationOptions? options = null);
}
}