Cómo convertir vistas a PDF en ASP.NET MVC con C#
IronPDF te permite convertir Vistas de ASP.NET MVC a documentos PDF usando el método ChromePdfRenderer.RenderView() con solo unas pocas líneas de código. El paquete IronPdf.Extensions.Mvc.Framework proporciona una integración directa con proyectos ASP.NET MVC para renderizar vistas CSHTML como PDFs.
Una Vista es un componente en el marco de ASP.NET utilizado para generar marcado HTML en aplicaciones web. Forma parte del patrón Modelo-Vista-Controlador (MVC), utilizado habitualmente en aplicaciones ASP.NET MVC y ASP.NET Core MVC. Las Vistas son responsables de presentar datos al usuario renderizando contenido HTML dinámicamente. El poder del Chrome PDF Rendering Engine de IronPDF asegura que tus vistas se rendericen con precisión de píxel, manteniendo todo el estilo, los diseños y elementos interactivos.
ASP.NET Web Application (.NET Framework) MVC es un marco de aplicación web proporcionado por Microsoft. Sigue un patrón arquitectónico estructurado conocido como Model-View-Controller (MVC) para organizar y simplificar el desarrollo de aplicaciones web.
- Modelo: Gestiona datos, lógica de negocio e integridad de datos.
- Vista: Presenta la interfaz de usuario y renderiza información.
- Controlador: gestiona las entradas de los usuarios, procesa las solicitudes y organiza las interacciones entre el modelo y la vista.
IronPDF simplifica el proceso de creación de archivos PDF a partir de Vistas dentro de un proyecto ASP.NET MVC. Esto hace que la generación de PDF sea fácil y directa en ASP.NET MVC. Ya sea que esté generando facturas, informes o cualquier documento desde sus vistas web, IronPDF proporciona las herramientas necesarias para una salida PDF profesional. Para una guía completa de configuración, visita la página de Descripción General de la Instalación.
Inicio rápido: Convierta la vista ASP.NET MVC a PDF sin esfuerzoAprende cómo convertir rápidamente tus Vistas de ASP.NET MVC en documentos PDF usando IronPDF. Con solo unas pocas líneas de código, puedes renderizar tus vistas CSHTML a PDFs de alta calidad, mejorando la funcionalidad de tu aplicación. IronPDF simplifica el proceso, haciéndolo accesible para desarrolladores de todos los niveles. Comienza integrando IronPDF en tus proyectos ASP.NET Core para generar PDFs fácilmente desde tus Vistas.
-
1Instalar IronPDF con NuGet Package Manager
-
2Copie y ejecute este fragmento de código.
// Install-Package IronPdf.Extensions.Mvc.Framework ChromePdfRenderer renderer = new ChromePdfRenderer(); PdfDocument pdf = renderer.RenderView(this.HttpContext, "~/Views/Home/Persons.cshtml", persons);' Install-Package IronPdf.Extensions.Mvc.Framework Dim renderer As New ChromePdfRenderer() Dim pdf As PdfDocument = renderer.RenderView(Me.HttpContext, "~/Views/Home/Persons.cshtml", persons)' Install-Package IronPdf.Extensions.Mvc.Framework Dim renderer As New ChromePdfRenderer() Dim pdf As PdfDocument = renderer.RenderView(Me.HttpContext, "~/Views/Home/Persons.cshtml", persons) -
3Despliegue para probar en su entorno real
Empiece a usar IronPDF en su proyecto hoy con una prueba gratuita
Flujo de trabajo mínimo (5 pasos)
- Descarga la biblioteca C# para convertir Vistas a PDFs en ASP.NET MVC
- Agregar una clase de modelo para los datos.
- Crea una acción "Person" en el controlador y utiliza el método
RenderView - Agregar una vista usando la vista Scaffolded de MVC 5
- Descarga el proyecto de ejemplo para un inicio rápido.
¿Qué paquete de extensión necesito?
¿Por qué IronPDF requiere un paquete de extensión?
El paquete IronPdf.Extensions.Mvc.Framework es una extensión del paquete principal IronPDF. Ambos paquetes IronPdf.Extensions.Mvc.Framework y IronPdf son necesarios para renderizar Vistas a documentos PDF en ASP.NET MVC. Esta separación permite optimizar la funcionalidad específica del marco MVC al tiempo que se mantienen las capacidades básicas de renderizado de PDF.
¿Cómo instalar el paquete de extensión?
Instalar con NuGet
Install-Package IronPdf.Extensions.Mvc.Framework
¿Cómo renderizar vistas en PDF?
¿Qué tipo de proyecto necesito?
Para convertir vistas en archivos PDF, se necesita un proyecto MVC de aplicación web ASP.NET (.NET Framework). IronPDF admite varias versiones de MVC y proporciona extensas Opciones de Renderizado para personalizar la salida de tu PDF de acuerdo a tus requisitos.
¿Cómo añado una clase modelo?
¿Dónde debo crear el modelo?
- Navega hasta la carpeta "Models"
- Crea un nuevo archivo de clase C# llamado
Person. Esta clase sirve como un modelo para representar datos individuales. Utilice el siguiente código:
namespace ViewToPdfMVCSample.Models
{
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
}namespace ViewToPdfMVCSample.Models
{
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
}Namespace ViewToPdfMVCSample.Models
Public Class Person
Public Property Id() As Integer
Public Property Name() As String
Public Property Title() As String
Public Property Description() As String
End Class
End NamespaceNamespace ViewToPdfMVCSample.Models
Public Class Person
Public Property Id() As Integer
Public Property Name() As String
Public Property Title() As String
Public Property Description() As String
End Class
End Namespace¿Cómo edito el controlador?
¿Qué código debo añadir al controlador?
Navega a la carpeta "Controllers" y abre el archivo HomeController. Agrega la acción Persons usando el siguiente código:
En el código proporcionado, primero se crea la clase ChromePdfRenderer. Para usar el método RenderView, proporciónale un HttpContext, especifica la ruta al archivo "Persons.cshtml", y proporciona un List<Person> que contenga los datos necesarios. Al renderizar la Vista, puedes utilizar RenderingOptions para personalizar márgenes, agregar textos personalizados y encabezados y pies de página HTML, y aplicar números de página al documento PDF resultante.
File(pdf.BinaryData, "application/pdf", "viewToPdfMVC.pdf").using IronPdf;
using System.Collections.Generic;
using System.Web.Mvc;
using ViewToPdfMVCSample.Models;
namespace ViewToPdfMVCSample.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
// GET: Person
public ActionResult Persons()
{
// Create a list of Person objects
var persons = new List<Person>
{
new Person { Name = "Alice", Title = "Mrs.", Description = "Software Engineer" },
new Person { Name = "Bob", Title = "Mr.", Description = "Software Engineer" },
new Person { Name = "Charlie", Title = "Mr.", Description = "Software Engineer" }
};
if (HttpContext.Request.HttpMethod == "POST")
{
// Define the path to the View file
var viewPath = "~/Views/Home/Persons.cshtml";
// Instantiate the ChromePdfRenderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render the view to a PDF document
PdfDocument pdf = renderer.RenderView(this.HttpContext, viewPath, persons);
// Set headers to view the PDF in-browser
Response.Headers.Add("Content-Disposition", "inline");
// Return the generated PDF file
return File(pdf.BinaryData, "application/pdf");
}
return View(persons);
}
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
}using IronPdf;
using System.Collections.Generic;
using System.Web.Mvc;
using ViewToPdfMVCSample.Models;
namespace ViewToPdfMVCSample.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
// GET: Person
public ActionResult Persons()
{
// Create a list of Person objects
var persons = new List<Person>
{
new Person { Name = "Alice", Title = "Mrs.", Description = "Software Engineer" },
new Person { Name = "Bob", Title = "Mr.", Description = "Software Engineer" },
new Person { Name = "Charlie", Title = "Mr.", Description = "Software Engineer" }
};
if (HttpContext.Request.HttpMethod == "POST")
{
// Define the path to the View file
var viewPath = "~/Views/Home/Persons.cshtml";
// Instantiate the ChromePdfRenderer
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Render the view to a PDF document
PdfDocument pdf = renderer.RenderView(this.HttpContext, viewPath, persons);
// Set headers to view the PDF in-browser
Response.Headers.Add("Content-Disposition", "inline");
// Return the generated PDF file
return File(pdf.BinaryData, "application/pdf");
}
return View(persons);
}
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
}Imports IronPdf
Imports System.Collections.Generic
Imports System.Web.Mvc
Imports ViewToPdfMVCSample.Models
Namespace ViewToPdfMVCSample.Controllers
Public Class HomeController
Inherits Controller
Public Function Index() As ActionResult
Return View()
End Function
' GET: Person
Public Function Persons() As ActionResult
' Create a list of Person objects
'INSTANT VB NOTE: The local variable persons was renamed since Visual Basic will not allow local variables with the same name as their enclosing function or property:
Dim persons_Conflict = New List(Of Person) From {
New Person With {
.Name = "Alice",
.Title = "Mrs.",
.Description = "Software Engineer"
},
New Person With {
.Name = "Bob",
.Title = "Mr.",
.Description = "Software Engineer"
},
New Person With {
.Name = "Charlie",
.Title = "Mr.",
.Description = "Software Engineer"
}
}
If HttpContext.Request.HttpMethod = "POST" Then
' Define the path to the View file
Dim viewPath = "~/Views/Home/Persons.cshtml"
' Instantiate the ChromePdfRenderer
Dim renderer As New ChromePdfRenderer()
' Render the view to a PDF document
Dim pdf As PdfDocument = renderer.RenderView(Me.HttpContext, viewPath, persons_Conflict)
' Set headers to view the PDF in-browser
Response.Headers.Add("Content-Disposition", "inline")
' Return the generated PDF file
Return File(pdf.BinaryData, "application/pdf")
End If
Return View(persons_Conflict)
End Function
Public Function About() As ActionResult
ViewBag.Message = "Your application description page."
Return View()
End Function
Public Function Contact() As ActionResult
ViewBag.Message = "Your contact page."
Return View()
End Function
End Class
End NamespaceImports IronPdf
Imports System.Collections.Generic
Imports System.Web.Mvc
Imports ViewToPdfMVCSample.Models
Namespace ViewToPdfMVCSample.Controllers
Public Class HomeController
Inherits Controller
Public Function Index() As ActionResult
Return View()
End Function
' GET: Person
Public Function Persons() As ActionResult
' Create a list of Person objects
'INSTANT VB NOTE: The local variable persons was renamed since Visual Basic will not allow local variables with the same name as their enclosing function or property:
Dim persons_Conflict = New List(Of Person) From {
New Person With {
.Name = "Alice",
.Title = "Mrs.",
.Description = "Software Engineer"
},
New Person With {
.Name = "Bob",
.Title = "Mr.",
.Description = "Software Engineer"
},
New Person With {
.Name = "Charlie",
.Title = "Mr.",
.Description = "Software Engineer"
}
}
If HttpContext.Request.HttpMethod = "POST" Then
' Define the path to the View file
Dim viewPath = "~/Views/Home/Persons.cshtml"
' Instantiate the ChromePdfRenderer
Dim renderer As New ChromePdfRenderer()
' Render the view to a PDF document
Dim pdf As PdfDocument = renderer.RenderView(Me.HttpContext, viewPath, persons_Conflict)
' Set headers to view the PDF in-browser
Response.Headers.Add("Content-Disposition", "inline")
' Return the generated PDF file
Return File(pdf.BinaryData, "application/pdf")
End If
Return View(persons_Conflict)
End Function
Public Function About() As ActionResult
ViewBag.Message = "Your application description page."
Return View()
End Function
Public Function Contact() As ActionResult
ViewBag.Message = "Your contact page."
Return View()
End Function
End Class
End Namespace¿Cómo puedo personalizar las opciones de renderizado de PDF?
Para escenarios más avanzados, puede personalizar la salida PDF utilizando varias opciones de renderizado. He aquí un ejemplo con márgenes personalizados, tamaño de papel y ajustes adicionales:
// Advanced rendering with custom options
public ActionResult PersonsAdvanced()
{
var persons = GetPersonsList();
if (HttpContext.Request.HttpMethod == "POST")
{
var viewPath = "~/Views/Home/Persons.cshtml";
// Configure the renderer with custom options
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Set custom rendering options
renderer.RenderingOptions.MarginTop = 40;
renderer.RenderingOptions.MarginBottom = 40;
renderer.RenderingOptions.MarginLeft = 20;
renderer.RenderingOptions.MarginRight = 20;
// Set custom paper size
renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A4;
renderer.RenderingOptions.PaperOrientation = IronPdf.Rendering.PdfPaperOrientation.Portrait;
// Add header and footer
renderer.RenderingOptions.TextHeader.DrawDividerLine = true;
renderer.RenderingOptions.TextHeader.CenterText = "{pdf-title}";
renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica;
renderer.RenderingOptions.TextHeader.FontSize = 12;
renderer.RenderingOptions.TextFooter.DrawDividerLine = true;
renderer.RenderingOptions.TextFooter.Font = IronPdf.Font.FontTypes.Arial;
renderer.RenderingOptions.TextFooter.FontSize = 10;
renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}";
// Enable JavaScript execution if needed
renderer.RenderingOptions.EnableJavaScript = true;
renderer.RenderingOptions.RenderDelay = 500; // Wait for JS to execute
// Render the view to PDF
PdfDocument pdf = renderer.RenderView(this.HttpContext, viewPath, persons);
// Optional: Apply compression to reduce file size
pdf.CompressImages(60);
Response.Headers.Add("Content-Disposition", "inline");
return File(pdf.BinaryData, "application/pdf");
}
return View("Persons", persons);
}// Advanced rendering with custom options
public ActionResult PersonsAdvanced()
{
var persons = GetPersonsList();
if (HttpContext.Request.HttpMethod == "POST")
{
var viewPath = "~/Views/Home/Persons.cshtml";
// Configure the renderer with custom options
ChromePdfRenderer renderer = new ChromePdfRenderer();
// Set custom rendering options
renderer.RenderingOptions.MarginTop = 40;
renderer.RenderingOptions.MarginBottom = 40;
renderer.RenderingOptions.MarginLeft = 20;
renderer.RenderingOptions.MarginRight = 20;
// Set custom paper size
renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A4;
renderer.RenderingOptions.PaperOrientation = IronPdf.Rendering.PdfPaperOrientation.Portrait;
// Add header and footer
renderer.RenderingOptions.TextHeader.DrawDividerLine = true;
renderer.RenderingOptions.TextHeader.CenterText = "{pdf-title}";
renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica;
renderer.RenderingOptions.TextHeader.FontSize = 12;
renderer.RenderingOptions.TextFooter.DrawDividerLine = true;
renderer.RenderingOptions.TextFooter.Font = IronPdf.Font.FontTypes.Arial;
renderer.RenderingOptions.TextFooter.FontSize = 10;
renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}";
// Enable JavaScript execution if needed
renderer.RenderingOptions.EnableJavaScript = true;
renderer.RenderingOptions.RenderDelay = 500; // Wait for JS to execute
// Render the view to PDF
PdfDocument pdf = renderer.RenderView(this.HttpContext, viewPath, persons);
// Optional: Apply compression to reduce file size
pdf.CompressImages(60);
Response.Headers.Add("Content-Disposition", "inline");
return File(pdf.BinaryData, "application/pdf");
}
return View("Persons", persons);
}' Advanced rendering with custom options
Public Function PersonsAdvanced() As ActionResult
Dim persons = GetPersonsList()
If HttpContext.Request.HttpMethod = "POST" Then
Dim viewPath = "~/Views/Home/Persons.cshtml"
' Configure the renderer with custom options
Dim renderer As New ChromePdfRenderer()
' Set custom rendering options
renderer.RenderingOptions.MarginTop = 40
renderer.RenderingOptions.MarginBottom = 40
renderer.RenderingOptions.MarginLeft = 20
renderer.RenderingOptions.MarginRight = 20
' Set custom paper size
renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A4
renderer.RenderingOptions.PaperOrientation = IronPdf.Rendering.PdfPaperOrientation.Portrait
' Add header and footer
renderer.RenderingOptions.TextHeader.DrawDividerLine = True
renderer.RenderingOptions.TextHeader.CenterText = "{pdf-title}"
renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica
renderer.RenderingOptions.TextHeader.FontSize = 12
renderer.RenderingOptions.TextFooter.DrawDividerLine = True
renderer.RenderingOptions.TextFooter.Font = IronPdf.Font.FontTypes.Arial
renderer.RenderingOptions.TextFooter.FontSize = 10
renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}"
' Enable JavaScript execution if needed
renderer.RenderingOptions.EnableJavaScript = True
renderer.RenderingOptions.RenderDelay = 500 ' Wait for JS to execute
' Render the view to PDF
Dim pdf As PdfDocument = renderer.RenderView(Me.HttpContext, viewPath, persons)
' Optional: Apply compression to reduce file size
pdf.CompressImages(60)
Response.Headers.Add("Content-Disposition", "inline")
Return File(pdf.BinaryData, "application/pdf")
End If
Return View("Persons", persons)
End Function' Advanced rendering with custom options
Public Function PersonsAdvanced() As ActionResult
Dim persons = GetPersonsList()
If HttpContext.Request.HttpMethod = "POST" Then
Dim viewPath = "~/Views/Home/Persons.cshtml"
' Configure the renderer with custom options
Dim renderer As New ChromePdfRenderer()
' Set custom rendering options
renderer.RenderingOptions.MarginTop = 40
renderer.RenderingOptions.MarginBottom = 40
renderer.RenderingOptions.MarginLeft = 20
renderer.RenderingOptions.MarginRight = 20
' Set custom paper size
renderer.RenderingOptions.PaperSize = IronPdf.Rendering.PdfPaperSize.A4
renderer.RenderingOptions.PaperOrientation = IronPdf.Rendering.PdfPaperOrientation.Portrait
' Add header and footer
renderer.RenderingOptions.TextHeader.DrawDividerLine = True
renderer.RenderingOptions.TextHeader.CenterText = "{pdf-title}"
renderer.RenderingOptions.TextHeader.Font = IronPdf.Font.FontTypes.Helvetica
renderer.RenderingOptions.TextHeader.FontSize = 12
renderer.RenderingOptions.TextFooter.DrawDividerLine = True
renderer.RenderingOptions.TextFooter.Font = IronPdf.Font.FontTypes.Arial
renderer.RenderingOptions.TextFooter.FontSize = 10
renderer.RenderingOptions.TextFooter.RightText = "{page} of {total-pages}"
' Enable JavaScript execution if needed
renderer.RenderingOptions.EnableJavaScript = True
renderer.RenderingOptions.RenderDelay = 500 ' Wait for JS to execute
' Render the view to PDF
Dim pdf As PdfDocument = renderer.RenderView(Me.HttpContext, viewPath, persons)
' Optional: Apply compression to reduce file size
pdf.CompressImages(60)
Response.Headers.Add("Content-Disposition", "inline")
Return File(pdf.BinaryData, "application/pdf")
End If
Return View("Persons", persons)
End FunctionPara más información sobre la optimización de márgenes, visita nuestra guía sobre Establecer Márgenes Personalizados. Si necesitas trabajar con dimensiones de papel específicas, consulta nuestra documentación de Tamaño de Papel Personalizado.
¿Qué puedo hacer con el PDF generado?
Una vez que obtienes el objeto PdfDocument a través del método RenderView, puedes realizar varias mejoras y ajustes en él. Puedes convertir el PDF a formatos PDFA o PDFUA, aplicar firmas digitales al PDF creado, o fusionar y dividir documentos PDF según sea necesario. La biblioteca te permite rotar páginas, insertar anotaciones o marcadores, y aplicar marcas de agua distintas a tus archivos PDF.
Para optimización del tamaño del archivo, considera usar técnicas de Compresión PDF. Al trabajar con contenido intensivo en JavaScript, nuestra guía de renderización de JavaScript proporciona información detallada sobre cómo manejar retrasos de renderización personalizados. Para diferentes opciones de exportación, consulta nuestra guía sobre Guardar y Exportar Documentos PDF.
¿Cómo añado una vista?
¿Qué pasos debo seguir para crear la vista?
-
Haz clic derecho en la acción Person añadida recientemente y selecciona "Add View".

-
Elige "Vista MVC 5" para el nuevo elemento Scaffold.

-
Selecciona la plantilla "List" y la clase de modelo
Person.
Esto crea un archivo .cshtml llamado "Personas"
¿Cómo añadir un botón de impresión a la vista?
- Navega a la carpeta "Views" -> carpeta "Home" -> archivo "Persons.cshtml".
Para agregar un botón que invoque la acción Persons, usa el siguiente código:
@using (Html.BeginForm("Persons", "Home", FormMethod.Post))
{
<input type="submit" value="Print Person" />
}
¿Cómo añado una sección a la barra de navegación superior?
¿Dónde debo actualizar la navegación?
- En la carpeta "Views", navega a la carpeta "Shared" -> archivo "_Layout.cshtml". Coloca el elemento de navegación "Person" después de "Home".
Asegúrate de que los valores para el método ActionLink coincidan exactamente con nuestro nombre de archivo, que es "Persons."
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-dark bg-dark">
<div class="container">
@Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
<button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" title="Toggle navigation" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li>@Html.ActionLink("Home", "Index", "Home", new { area = "" }, new { @class = "nav-link" })</li>
<li>@Html.ActionLink("Persons", "Persons", "Home", new { area = "" }, new { @class = "nav-link" })</li>
<li>@Html.ActionLink("About", "About", "Home", new { area = "" }, new { @class = "nav-link" })</li>
<li>@Html.ActionLink("Contact", "Contact", "Home", new { area = "" }, new { @class = "nav-link" })</li>
</ul>
</div>
</div>
</nav>
¿Cómo ejecutar y probar el proyecto?
Ejecutar el proyecto
Aquí se muestra cómo ejecutar el proyecto y generar un documento PDF.
PDF de salida
¿Dónde puedo descargar el proyecto completo?
¿Qué incluye el proyecto de muestra?
Puede descargar el código completo de esta guía. Se trata de un archivo comprimido que puede abrirse en Visual Studio como un proyecto ASP.NET Web Application (.NET Framework) MVC. La muestra incluye todas las configuraciones, clases de modelos, controladores y vistas necesarios para empezar rápidamente con la generación de PDF en sus aplicaciones MVC.
Descarga el proyecto de muestra MVC para conversión a PDF
Preguntas frecuentes
¿Cómo puedo convertir vistas CSHTML a PDF en ASP.NET MVC?
Puede usar IronPDF para convertir vistas CSHTML a documentos PDF en ASP.NET MVC aprovechando el método ChromePdfRenderer.RenderView(). Esto le permite renderizar vistas como PDFs con precisión exacta manteniendo el diseño y el estilo.
¿Para qué se utiliza el paquete IronPdf.Extensions.Mvc.Framework?
El paquete IronPdf.Extensions.Mvc.Framework es una extensión del paquete principal IronPDF, diseñado específicamente para renderizar vistas de ASP.NET MVC a documentos PDF. Este paquete proporciona una integración adaptada a proyectos MVC, manteniendo las funcionalidades principales de PDF.
¿Qué tipos de proyectos son compatibles para renderizar vistas a PDFs usando IronPDF?
IronPDF admite proyectos MVC de ASP.NET Web Application (.NET Framework), lo que le permite convertir vistas en archivos PDF dentro de estos proyectos.
¿Cómo puedo instalar el paquete IronPdf.Extensions.Mvc.Framework?
Puede instalar el paquete IronPdf.Extensions.Mvc.Framework usando el NuGet Package Manager en Visual Studio con el comando: Install-Package IronPdf.Extensions.Mvc.Framework.
¿Cuáles son los pasos clave para generar un PDF desde una vista de ASP.NET MVC?
Para generar un PDF desde una vista de ASP.NET MVC, necesita descargar la biblioteca C#, agregar una clase de modelo, crear una acción de controlador usando el método RenderView y esbozar una vista usando MVC 5.
¿Cómo personalizo las opciones de renderización de PDF en IronPDF?
IronPDF le permite personalizar la renderización de PDF a través de varias opciones como establecer márgenes personalizados, tamaños de papel, añadir encabezados y pies de página, y habilitar la ejecución de JavaScript. Esto se puede lograr configurando las ChromePdfRenderer.RenderingOptions.
¿Puedo aplicar firmas digitales a PDFs generados con IronPDF?
Sí, con IronPDF, puede aplicar firmas digitales a sus documentos PDF para mayor seguridad y validación.
¿Qué características adicionales puede ofrecer IronPDF para mejoramientos de PDF?
IronPDF ofrece características como la conversión de PDFs a PDFA o PDFUA, fusionar o dividir documentos PDF, rotar páginas, añadir anotaciones o marcadores, y aplicar marcas de agua.
¿Cómo puedo optimizar los tamaños de PDF usando IronPDF?
Puede optimizar los tamaños de PDF usando las técnicas de compresión de IronPDF, que permiten reducir el tamaño de los archivos manteniendo la calidad.
¿Dónde puedo encontrar un proyecto de ejemplo para la conversión a PDF en ASP.NET MVC?
Puede descargar un proyecto de ejemplo completo desde el sitio web de IronPDF, que incluye todas las configuraciones necesarias para ayudarle a comenzar rápidamente con la generación de PDF en aplicaciones de ASP.NET MVC.
Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien estructurados y visualmente atractivos.