반응형
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;
import com.itextpdf.layout.element.Text;
public class Itext7_04 {
public static void main(String[] args) throws IOException {
try {
File file = new File("iText7_Text.pdf");
PdfWriter pdfWriter = new PdfWriter(file);
PdfDocument pdfDocument = new PdfDocument(pdfWriter);
Document document = new Document(pdfDocument);
Paragraph paragraph = new Paragraph();
Text text1 = new Text("BASIC Text ");
paragraph.add(text1);
Text text2 = new Text("Bold Text ");
text2.setBold();
paragraph.add(text2);
Text text3 = new Text("Underline Text ");
text3.setUnderline();
paragraph.add(text3);
Text text4 = new Text("LineThrough Text ");
text4.setItalic();
text4.setLineThrough();
paragraph.add(text4);
document.add(paragraph);
document.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
<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' 카테고리의 다른 글
[flask] 멀티채팅룸생성, 채팅창 상세화면 구현. flask chat serveer (0) | 2023.02.08 |
---|---|
springboot로 소켓통신 멀티룸 채팅 소스 (0) | 2023.02.08 |
[JAVA] POI 를 이용하지않고 pdfbox를 이용한 pdf 출력[초간단] (0) | 2023.02.07 |
[Nginx] nginx에서 rtmp를 트랜스코딩 하는 방법 480p, 720p, 1080p (0) | 2023.02.07 |
[Swift] 스마트폰 카메라에서 촬영한 영상을 rtmp 송출기능 (0) | 2023.02.07 |