-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextToPDF.java
More file actions
41 lines (28 loc) · 1 KB
/
TextToPDF.java
File metadata and controls
41 lines (28 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.pdf.ravishankarcode;
import java.io.BufferedReader;
import java.io.FileReader;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.element.Paragraph;
/**
*
* @author Ravishankar.kumar
*
*/
public class TextToPDF {
public static final String SOURCE_FILE = "C:\\temp\\Test.txt";
public static final String CREATED_PDF = "C:\\temp\\Result.pdf";
public static void main(String[] args) throws java.io.IOException {
BufferedReader br = new BufferedReader(new FileReader(SOURCE_FILE));
PdfDocument pdf = new PdfDocument(new PdfWriter(CREATED_PDF));
Document document = new Document(pdf);
String line;
while ((line = br.readLine()) != null) {
document.add(new Paragraph(line));
}
br.close();
document.close();
System.out.println("Awesome Text to PDF Conversion completed!");
}
}