IRONSOFTWAREHOME
이미지를 PDF로 변환

import com.ironsoftware.ironpdf.*;  
import java.io.IOException;  
import java.nio.file.*;  
import java.util.ArrayList;  
import java.util.List;  

// Reference to the directory containing the images that we desire to convert
Path imageDirectory = Paths.get("assets/images");

// Create an empty List to contain Paths to images from the directory.
List<Path> imageFiles = new ArrayList<>();

// Use a DirectoryStream to populate the List with paths for each image in the directory
// that we want to convert (this example uses a glob pattern to target only png and jpg images)
try (DirectoryStream<Path> stream = Files.newDirectoryStream(imageDirectory, "*.{png,jpg}")) {
    for (Path entry : stream) {
        imageFiles.add(entry);
    }

    // Render all targeted images as PDF content and save them together in one PDF document.
    PdfDocument.fromImage(imageFiles).saveAs(Paths.get("assets/composite.pdf"));
} catch (IOException exception) {
    throw new RuntimeException(String.format("Error converting images to PDF from directory: %s: %s",
            imageDirectory,
            exception.getMessage()),
            exception);
}
mvn install
이미지를 PDF로 변환

이미지를 PDF로 변환

개발자는 IronPDF 사용하여 여러 이미지를 하나의 PDF 문서로 결합할 수 있습니다.

PdfDocument.fromImage 메서드는 로컬 파일 시스템에 저장된 이미지에 대한 올바른 경로를 참조하는 Path 객체의 목록을 수락합니다. 이는 개발자에게 세부적인 사항에 대한 상당한 자유를 제공합니다. 개발자는 여러 디렉터리에 걸친 이미지 그룹을 포함하기 위해, 특정 명명 또는 입력 기준과 일치하는 이미지를 포함하는 등의 목록을 작성할 수 있습니다. 이미지가 같은 디렉토리에서 소싱될 경우(아래 예시와 같은 경우), 개발자는 DirectoryStreamjava.nio.file 클래스 중 하나를 사용하여 디렉토리에 포함된 모든 이미지의 목록을 신속하게 구축할 수 있습니다.

PdfDocument.fromImage은 리스트에서 참조된 각 이미지를 PDF 문서의 개별 페이지에 렌더링합니다.

이미지를 하나의 PDF 문서에 병합하지 않고 각각 별도의 PDF 문서에 배치해야 하는 경우, 개발자는 다음 두 가지 방법 중 하나를 사용할 수 있습니다.

  1. 하나의 Path 객체만 포함하는 목록을 사용하여 PdfDocument.fromImage을 반복적으로 호출합니다.
  2. 위의 예와 같이 모든 이미지를 하나의 PDF 문서로 결합한 다음, PdfDocument.copyPage 메서드를 사용하여 각 페이지를 새로운 PDF 문서로 복사합니다.
Java를 사용하여 PDF를 이미지로 변환하는 방법을 알아보세요.
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일 무료 체험판 키를 받으세요.
신용카드나 계정 생성은 필요하지 않습니다.