forked from eugenejade/JavaTPCProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject04_C.java
More file actions
31 lines (25 loc) · 792 Bytes
/
Project04_C.java
File metadata and controls
31 lines (25 loc) · 792 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
import java.io.FileOutputStream;
import com.itextpdf.text.Document;
import com.itextpdf.text.Image;
import com.itextpdf.text.pdf.PdfWriter;
public class Project04_C {
public static void main(String[] args) {
// https://cdn.inflearn.com/assets/images/main/ufo2.png
Document doc=new Document();
try {
PdfWriter.getInstance(doc, new FileOutputStream("ImageDemo.pdf"));
doc.open();
String fileName="inflearn.png";
Image image=Image.getInstance(fileName);
doc.add(image);
String url="https://cdn.inflearn.com/assets/images/main/ufo2.png";
image=Image.getInstance(url);
doc.add(image);
System.out.println("»ý¼º¿Ï·á");
} catch (Exception e) {
e.printStackTrace();
} finally {
doc.close();
}
}
}