forked from eugenejade/JavaTPCProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject04_B.java
More file actions
39 lines (33 loc) · 1017 Bytes
/
Project04_B.java
File metadata and controls
39 lines (33 loc) · 1017 Bytes
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
import java.io.FileOutputStream;
import com.itextpdf.text.Chunk;
import com.itextpdf.text.Document;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
public class Project04_B {
public static void main(String[] args) {
Document doc=new Document();
try {
FileOutputStream fos=new FileOutputStream("paragraphDemo.pdf");
PdfWriter.getInstance(doc, fos);
doc.open();
String content="Your word is a lamp to my feet and a light for my path";
Paragraph par1=new Paragraph(32);
par1.setSpacingBefore(50);
par1.setSpacingAfter(50);
for(int i=0;i<20;i++) {
Chunk chunk=new Chunk(content);
par1.add(chunk);
}
doc.add(par1);
Paragraph par2=new Paragraph();
for(int i=0;i<10;i++) {
par2.add(new Chunk(content));
}
doc.add(par2);
doc.close();
System.out.println("paragraphDemo »ý¼º");
} catch (Exception e) {
e.printStackTrace();
}
}
}