반응형
import java.io.File;
import com.itextpdf.io.image.ImageData;
import com.itextpdf.io.image.ImageDataFactory;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.element.Image;
public class Itext7_01 {
public static void main(String[] args) throws Exception {
File file = new File("iText7_Image_01.pdf");
PdfWriter pdfWriter = new PdfWriter(file);
PdfDocument pdfDocument = new PdfDocument(pdfWriter);
Document document = new Document(pdfDocument);
ImageData imageFile = ImageDataFactory.create("google.png");
Image pdfImg = new Image(imageFile);
document.add(pdfImg);
document.close();
}
}
pom.xml
<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>io</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>RELEASE</version>
</dependency>
</dependencies>
반응형
'Spring Boot > Unit Code' 카테고리의 다른 글
[spring boot] PDF 출력 - iText7_01(TEXT) (0) | 2023.02.08 |
---|---|
[spring boot] PDF 출력 - iText7_02(Image) (0) | 2023.02.08 |