IRONSOFTWAREHOME
클래식 텍스트 머리글 및 바닥글 추가
import {PdfDocument, AffixFonts} from "@ironsoftware/ironpdf";

(async () => {
    // Configure render options
    const options = {
        firstPageNumber: 1, // Use 2 if a cover page will be appended

        // Add a header to every page
        textHeader: {
            dividerLine: true,
            centerText: "{html-title}",
            font: AffixFonts.Helvetica, // Use the font name or font file path
            fontSize: 12,
        },

        // Add a footer
        textFooter: {
            dividerLine: true,
            leftText: "{date} {time}",
            rightText: "{page} of {total-pages}",
            font: AffixFonts.Arial, // Use the font name or font file path
            fontSize: 10,
        },
        // Mergeable fields are: {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}

        margin: {
            top: 25, // Create 25mm space for the header
            bottom: 25, // Create 25mm space for the footer
        },
    };

    // Define HTML content
    const htmlContent = "<h1>Hello IronPDF</h1>";

    // Render HTML content to a PDF with headers and footers
    const pdf = await PdfDocument.fromHtml(htmlContent, {renderOptions: options });

    // Save the PDF with headers and footers
    await pdf.saveAs("header_footer.pdf");
})();
npm i @ironsoftware/ironpdf
클래식 텍스트 머리글 및 바닥글 추가

클래식 텍스트 머리글 및 바닥글 추가

HTML 콘텐츠를 렌더링할 때 PDF 문서에 텍스트 머리글과 바닥글을 추가하는 방법을 알아보세요.

텍스트 머리글과 바닥글을 포함하려면 렌더링 옵션 객체에 지정해야 합니다. 구분선, HTML 제목을 표시하는 가운데 정렬된 텍스트, 폰트 설정 및 폰트 크기로 헤더 내용을 정의합니다. 유사하게 textFooter 속성을 사용하여 푸터를 정의합니다. {page}, {total-pages}, {url}, {date}, {time}, {html-title}, {pdf-title} 같은 필드를 활용하여 콘텐츠를 개인화할 수 있습니다.

머리글과 바닥글에 맞게 여백을 적절히 조정하세요.

HTML 콘텐츠를 PDF로 변환하기 위해 PdfDocument.fromHtml 메서드를 사용하세요. renderOptions 객체를 옵션으로 전달하세요.

HTML에서 PDF를 생성하는 방법에 대한 자세한 내용은 IronPDF 문서를 참조하십시오.

머리글과 바닥글이 포함된 최종 PDF 문서는 "header_footer.pdf"라는 이름으로 저장됩니다.

GitHub 에서 헤더 및 푸터 예제 코드를 살펴보세요.
GitHub에서 보기

시작할 준비 되셨나요?

버전:2026.6방금 출시

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일 무료 체험판 키를 받으세요.
신용카드나 계정 생성은 필요하지 않습니다.