IRONSOFTWAREHOME
HTML 헤더 및 푸터 추가

import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.headerfooter.HtmlHeaderFooter;
import java.io.IOException;
import java.nio.file.Paths;

PdfDocument pdf = PdfDocument.renderUrlAsPdf("https://ironpdf.com");
// Build a footer using HTML
// Merge Fields are: {page} {total-pages} {url} {date} {time} {html-title} & {pdf-title}
HtmlHeaderFooter footer = new HtmlHeaderFooter();
footer.setMaxHeight(15); // millimeters
footer.setHtmlFragment("<center><i>{page} of {total-pages}</i></center>");
footer.setDrawDividerLine(true);
pdf.addHtmlFooter(footer);
List<PdfDocument> pdfs = new ArrayList<>();

// Build a header using an image asset
// Note the use of BaseUrl to set a relative path to the assets
HtmlHeaderFooter header = new HtmlHeaderFooter();
header.setMaxHeight(20); // millimeters
header.setHtmlFragment("<img src=\"logo.png\" />");
header.setBaseUrl("./assets/");
pdf.addHtmlHeader(header);
try {
    pdf.saveAs(Paths.get("assets/html_headers_footers.pdf"));
} catch (IOException e) {
    throw new RuntimeException(e);
}
mvn install
HTML 헤더 및 푸터 추가

HTML 헤더 및 푸터 추가

IronPDF 사용하면 개발자가 PDF 문서에 사용자 지정 머리글과 바닥글을 사용할 수 있도록 수정할 수 있습니다. 이 코드 예제는 개발자가 ChromePdfRenderOptions 클래스와 함께 HtmlHeaderFooter 클래스를 사용하여 이를 달성하는 방법을 보여줍니다.

HtmlHeaderFooter 클래스는 개발자가 단순한 텍스트(이 경우 TextHeaderFooter 클래스와 같이)가 아닌 HTML을 사용하여 PDF의 헤더 또는 바닥글을 사용자 정의할 수 있도록 합니다. 클래스의 인스턴스에서 addHtmlFragment 메서드를 호출하여 헤더 또는 바닥글의 HTML 마크업을 지정합니다. 이 메서드는 유효한 HTML5, CSS3 및 JavaScript (ECMAScript 6)를 포함하는 문자열을 인수로 받습니다. IronPDF 이 문자열의 내용을 풍부한 하이퍼텍스트 마크업으로 해석하여 웹 브라우저에서 표시하는 것과 동일한 방식으로 결과 PDF 문서에 표시합니다.

개발자는 이 클래스를 사용하여 이미지, 색상, 특수 글꼴 및 기타 복잡한 디자인 요소를 포함하는 헤더를 만들 수 있습니다.

보다 전통적이고 단순화된 텍스트 기반 헤더/바닥글 사용자 정의를 위해서는 TextHeaderFooter 클래스를 선택하는 것을 고려하십시오.

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