IRONSOFTWAREHOME
HTML 헤더 및 푸터 추가
using IronPdf;
using System;

// Instantiate Renderer
var renderer = new IronPdf.ChromePdfRenderer();


// Build a footer using html to style the text
// mergeable fields are:
// {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
{
    MaxHeight = 15, //millimeters
    HtmlFragment = "<center><i>{page} of {total-pages}<i></center>",
    DrawDividerLine = true
};

// Use sufficient MarginBottom to ensure that the HtmlFooter does not overlap with the main PDF page content.
renderer.RenderingOptions.MarginBottom = 25; //mm


// Build a header using an image asset
// Note the use of BaseUrl to set a relative path to the assets
renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
{
    MaxHeight = 20, //millimeters
    HtmlFragment = "<img src='logo.png'>",
    BaseUrl = new Uri(@"C:\assets\images\").AbsoluteUri
};

// Use sufficient MarginTop to ensure that the HtmlHeader does not overlap with the main PDF page content.
renderer.RenderingOptions.MarginTop = 25; //mm
Imports IronPdf
Imports System

' Instantiate Renderer
Dim renderer = New IronPdf.ChromePdfRenderer()

' Build a footer using html to style the text
' mergeable fields are:
' {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter() With {
    .MaxHeight = 15, 'millimeters
    .HtmlFragment = "<center><i>{page} of {total-pages}<i></center>",
    .DrawDividerLine = True
}

' Use sufficient MarginBottom to ensure that the HtmlFooter does not overlap with the main PDF page content.
renderer.RenderingOptions.MarginBottom = 25 'mm

' Build a header using an image asset
' Note the use of BaseUrl to set a relative path to the assets
renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter() With {
    .MaxHeight = 20,  'millimeters
    .HtmlFragment = "<img src='logo.png'>",
    .BaseUrl = New Uri("C:\assets\images\").AbsoluteUri
}

' Use sufficient MarginTop to ensure that the HtmlHeader does not overlap with the main PDF page content.
renderer.RenderingOptions.MarginTop = 25 'mm
NuGet Download
PM > Install-Package IronPdf
HTML 헤더 및 푸터 추가

HTML 헤더 및 푸터 추가

HTML 헤더와 푸터는 PDF 문서에 동적인 헤더와 푸터를 만들 수 있는 유연한 방법을 제공합니다. 이 방법을 통해 헤더와 푸터를 추가하면 개발자는 헤더와 푸터의 모양을 완벽하게 제어할 수 있습니다. 헤더와 푸터는 자체적인 에셋과 스타일시트를 포함할 수 있는 독립적인 HTML 문서로 렌더링되기 때문입니다.

IronPDF 사용하여 PDF에 사용자 지정 HTML 머리글과 바닥글을 추가하는 단계

우선, HTML 콘텐츠를 픽셀 단위로 정확하게 PDF 문서로 변환하는 ChromePdfRenderer 클래스의 인스턴스를 생성해야 합니다.

다음으로, HtmlHeaderFooter 클래스를 사용하여 푸터를 정의합니다. 여기에는 푸터의 MaxHeight, HTML 콘텐츠(이번 경우에는 페이지 번호 포함) 및 이미지 해상도를 위한 기본 URL을 지정합니다. 푸터는 페이지 정보를 가운데 정렬하여 표시하도록 스타일이 지정되어 있습니다.

푸터와 PDF의 주요 콘텐츠 간의 겹침을 피하기 위해, MarginBottom 속성을 사용하여 하단 여백을 설정하십시오. 마찬가지로, 이미지(예: 로고)를 포함하는 헤더를 HtmlHeaderFooter 클래스를 사용하여 만듭니다. 여기에서는 이미지 자산이 있는 디렉터리에 대한 BaseUrl를 설정하여 렌더링 중에 적절한 이미지 해상도가 되도록 하였습니다.

마지막으로, MarginTop 속성을 사용하여 헤더와 콘텐츠 간의 겹침을 방지하기 위한 상단 여백을 설정합니다. 이 예제는 IronPDF 사용하여 PDF 문서에 사용자 지정 HTML 머리글과 바닥글을 얼마나 쉽게 구현할 수 있는지 보여줍니다.

IronPDF 사용하여 PDF에 HTML 머리글과 바닥글을 추가하는 방법을 알아보세요.
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일 무료 체험판 키를 받으세요.
신용카드나 계정 생성은 필요하지 않습니다.