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

import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.font.FontTypes;
import com.ironsoftware.ironpdf.headerfooter.TextHeaderFooter;
import com.ironsoftware.ironpdf.headerfooter.HeaderFooterOptions;
import java.io.IOException;

// Initialize HeaderFooterOptions object.
HeaderFooterOptions options = new HeaderFooterOptions();
PdfDocument pdf = PdfDocument.renderUrlAsPdf("http://www.google.com");

// Add a header to every page easily
// Mergeable fields are:
// {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
options.setFirstPageNumber(1); // use 2 if a coverpage  will be appended
TextHeaderFooter textHeader = new TextHeaderFooter();
textHeader.setDrawDividerLine(true);
textHeader.setCenterText("{url}");
textHeader.setFont(FontTypes.getHelvetica());
textHeader.setFontSize(12);
pdf.addTextHeader(textHeader, options);

// Add a footer too
TextHeaderFooter textFooter = new TextHeaderFooter();
textFooter.setDrawDividerLine(true);
textFooter.setFont(FontTypes.getArial());
textFooter.setFontSize(10);
textFooter.setLeftText("{date} {time}");
textFooter.setRightText("{page} of {total-pages}");
pdf.addTextFooter(textFooter, options);

try {
    pdf.saveAs(Paths.get("assets/text_headers_footers.pdf"));
} catch (IOException e) {
    System.out.println("Failed to save PDF");
    throw new RuntimeException(e);
}
mvn install
클래식 텍스트 머리글 및 바닥글 추가

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

이 코드 예제는 IronPDF 사용하여 개발자가 파일 시스템에서 불러오거나 HTML 콘텐츠에서 생성된 PDF 문서에 대한 머리글과 바닥글을 정의하는 방법을 보여줍니다.

TextHeaderFooter 클래스는 개발자가 PDF 문서의 헤더 또는 바닥글의 왼쪽, 오른쪽 또는 중앙 영역에 포함되어야 하는 텍스트를 지정할 수 있도록 합니다. 위에서 알 수 있듯이 개발자는 IronPDF의 내장 템플릿 태그(예: `{date}` `, ` `{time}` `, and ` `{page}`)를 사용하여 빠르게 헤더와 바닥글을 구성할 수 있습니다. 사용자는 이러한 태그만 사용할 필요는 없습니다. IronPDF 사용자가 이러한 위치에 어떤 종류든, 어떤 양이든 자유롭게 삽입할 수 있도록 해줍니다.

문서 프레젠테이션을 향상시키기 위해 IronPDF 내에서 훨씬 더 유연한 디자인을 제공하는 HtmlHeaderFooter 클래스를 TextHeaderFooter 클래스 대신 사용하는 것을 고려하십시오.

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