반응형
import java.io.File;
import java.io.FileNotFoundException;
import com.itextpdf.io.IOException;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.element.Paragraph;
public class Itext7_03 {
public static void main(String[] args) throws IOException {
try {
File file = new File("Hello_PDF.pdf");
PdfWriter pdfWriter;
pdfWriter = new PdfWriter(file);
PdfDocument pdfDocument = new PdfDocument(pdfWriter);
Document document = new Document(pdfDocument);
Paragraph paragraph = new Paragraph("Hello PDF iText7");
paragraph.add("\n");
paragraph.add("www.TokyoAJ.com.");
document.add(paragraph);
document.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
Maven 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_02(Image) (0) | 2023.02.08 |
---|---|
[spring boot] PDF 출력 - iText7_01(Image) (0) | 2020.07.05 |