IRONSOFTWAREHOME
CSHTML을 PDF로 변환(MVC 프레임워크)

// PM > Install-Package IronPdf.Extensions.Mvc.Framework

public ActionResult Persons()
{
    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")
    {
        // Provide the path to your view file
        var viewPath = "~/Views/Home/Persons.cshtml";
        ChromePdfRenderer renderer = new ChromePdfRenderer();

        // Render Razor view to PDF document
        PdfDocument pdf = renderer.RenderView(this.HttpContext, viewPath, persons);
        Response.Headers.Add("Content-Disposition", "inline");

        // View the PDF
        return File(pdf.BinaryData, "application/pdf");
    }
    return View(persons);
}
Public Function Persons() As ActionResult
    Dim persons = 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
        ' Provide the path to your view file
        Dim viewPath = "~/Views/Home/Persons.cshtml"
        Dim renderer As New ChromePdfRenderer()

        ' Render Razor view to PDF document
        Dim pdf As PdfDocument = renderer.RenderView(Me.HttpContext, viewPath, persons)
        Response.Headers.Add("Content-Disposition", "inline")

        ' View the PDF
        Return File(pdf.BinaryData, "application/pdf")
    End If

    Return View(persons)
End Function
NuGet Download
PM > Install-Package IronPdf
CSHTML을 PDF로 변환(MVC 프레임워크)

CSHTML을 PDF로 변환(MVC 프레임워크)

이 코드 예제는 뷰를 PDF 문서로 변환하는 방법을 보여줍니다.

이를 달성하기 위해 우리는 두 개의 패키지 IronPdf.Extensions.Mvc.Framework과(와) IronPdf를(을) 사용하여 Views를 PDF로 변환하는 작업을 용이하게 합니다. IronPdf.Extensions.Mvc.Framework 패키지는 IronPdf의 기능을 확장하여 특히 Views를 PDF로 렌더링할 수 있게 합니다.

변환을 수행하려면 RenderView 메서드를 사용하십시오. 이 메서드는 몇 가지 주요 입력값이 필요합니다: HttpContext, ".cshtml" 파일 경로, 그리고 ".cshtml" 템플릿을 채우기 위한 필요한 데이터. Persons 작업을 호출하여 현재 View를 PDF 문서로 원활하게 렌더링할 수 있습니다.

또한, RenderingOptions 클래스가 제공하는 포괄적인 기능 세트에 접근할 수 있습니다. 여기에는 IronPDF를 사용하여 페이지 번호를 추가하고, 텍스트 및 HTML 머리글과 바닥글을 삽입하고, 필요에 따라 PDF 용지 크기를 사용자 지정하는 기능이 포함됩니다. 필요에 따라 추가적인 수정을 하거나 결과 PDF 문서를 내보낼 수 있는 유연성을 제공합니다.

CSHTML을 PDF로 변환하는 가이드를 살펴보세요.
GitHub에서 보기

시작할 준비 되셨나요?

Nuget Downloads 20,756,830버전:2026.7방금 출시

Key in blue circle

무료 30일 체험 키를 즉시 받으세요.

Your trial license will be sent to your email address

제한 없음. 100% 무제한 이용. 신용카드 불필요.

bullet_checked신용카드나 계정 생성은 필요하지 않습니다.제한 없음. 100% 무제한 이용. 신용카드 불필요.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
무료 라이브 데모를 예약하세요
Booking Badge

전 세계 수백만 엔지니어들이 신뢰하는 제품입니다.

Iron Software의 고객 로고
부담 없는 무료 상담을 받아보세요
아래 양식을 작성하시거나 sales@ironsoftware.com으로 이메일을 보내주세요.
고객님의 정보는 항상 비밀로 유지됩니다.
전 세계 수백만 엔지니어들이 신뢰하는 제품입니다.
Iron Software의 고객 로고
지금 바로 30일 무료 체험판 키를 받으세요.
신용카드나 계정 생성은 필요하지 않습니다.