67 lines
2.7 KiB
C#
67 lines
2.7 KiB
C#
using Entidades;
|
|
using Entidades.Dto;
|
|
using QuestPDF.Fluent;
|
|
using QuestPDF.Helpers;
|
|
using QuestPDF.Infrastructure;
|
|
using System.IO;
|
|
|
|
namespace AlquilaFacil.Facade;
|
|
public class DocumentoGeneradorPdf {
|
|
public MemoryStream GenerarPdf(ContratoDto cd, Recibo r)
|
|
{
|
|
var pdfStream = new MemoryStream();
|
|
QuestPDF.Settings.License = LicenseType.Community;
|
|
Document.Create(container =>
|
|
{
|
|
container.Page(page =>
|
|
{
|
|
page.Size(PageSizes.A4);
|
|
page.Margin(2, Unit.Centimetre);
|
|
page.Header().Text("AlquilaFácil").FontSize(20).SemiBold().FontColor(Colors.White);
|
|
page.Content().Column(column =>
|
|
{
|
|
column.Spacing(10);
|
|
|
|
column.Item().Border(1).Padding(10).Column(card =>
|
|
{
|
|
card.Item().Row(row =>
|
|
{
|
|
row.RelativeItem().Text("Detalles").FontSize(16).SemiBold();
|
|
});
|
|
|
|
card.Item().Column(body =>
|
|
{
|
|
body.Spacing(5);
|
|
body.Item().Text($"ID: {cd.id}").FontSize(12).Bold();
|
|
body.Item().Text($"Ubicación: {cd.Ubicacion}").FontSize(12);
|
|
body.Item().Text($"Tipo de Propiedad: {cd.TipoPropiedad}").FontSize(12);
|
|
body.Item().Text($"Fecha de Inicio: {cd.Fechainicio}").FontSize(12);
|
|
body.Item().Text($"Inquilino: {cd.Inquilino}").FontSize(12);
|
|
body.Item().Text($"Propietario: {cd.Propietario}").FontSize(12);
|
|
});
|
|
});
|
|
|
|
column.Item().Border(1).Padding(10).Column(card =>
|
|
{
|
|
card.Item().Row(row =>
|
|
{
|
|
row.RelativeItem().Text("Detalles del Recibo").FontSize(16).SemiBold();
|
|
});
|
|
|
|
card.Item().Column(body =>
|
|
{
|
|
body.Spacing(5);
|
|
body.Item().Text($"ID del Recibo: {r.Id}").FontSize(12).Bold();
|
|
body.Item().Text($"Fecha: {r.Fecha}").FontSize(12);
|
|
body.Item().Text($"Monto: {r.Monto}").FontSize(12);
|
|
body.Item().AlignCenter().Text("PAGO").FontSize(20).Bold();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}).GeneratePdf(pdfStream);
|
|
|
|
pdfStream.Position = 0;
|
|
return pdfStream;
|
|
}
|
|
} |