-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathApp.java
More file actions
31 lines (21 loc) · 790 Bytes
/
App.java
File metadata and controls
31 lines (21 loc) · 790 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
package com.hmkcode;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import com.itextpdf.html2pdf.HtmlConverter;
public class App
{
public static final String HTML = "<h1>Hello</h1>"
+ "<p>This was created using iText</p>"
+ "<a href='hmkcode.com'>hmkcode.com</a>";
public static void main( String[] args ) throws FileNotFoundException, IOException
{
// String to PDF
HtmlConverter.convertToPdf(HTML, new FileOutputStream("string-to-pdf.pdf"));
// HTML file to PDF
HtmlConverter.convertToPdf(new FileInputStream("index.html"),
new FileOutputStream("index-to-pdf.pdf"));
System.out.println( "PDF Created!" );
}
}