GeezerVison is showing github.com — updated · cooper1986/Java@85914c1
File tree
Expand file treeCollapse file tree
Open diff view settings
src/main/java/com/hmkcode
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboard +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | +<classpath> |
| 3 | + <classpathentry kind="src" path="src/main/java" including="**/*.java"/> |
| 4 | + <classpathentry kind="output" path="target/classes"/> |
| 5 | + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> |
| 6 | + <classpathentry kind="var" path="M2_REPO/com/itextpdf/itextpdf/5.4.2/itextpdf-5.4.2.jar"/> |
| 7 | + <classpathentry kind="var" path="M2_REPO/com/itextpdf/tool/xmlworker/5.4.1/xmlworker-5.4.1.jar"/> |
| 8 | +</classpath> |
Collapse file
Copy file name to clipboard +20-32Lines changed: 20 additions & 32 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
2 | 2 | <html> |
3 | | -<head> |
4 | | -<title>HTML to PDF</title> |
5 | | -<link href="style.css" rel="stylesheet" type="text/css" /> |
6 | | -</head> |
7 | | -<body> |
8 | | -<h1>HTML to PDF</h1> |
9 | | -<table> |
10 | | - <tr> |
11 | | - <th>Id</th> |
12 | | - <th>Name</th> |
13 | | - </tr> |
14 | | - <tr> |
15 | | - <td>1</td> |
16 | | - <td>Brit</td> |
17 | | - </tr> |
18 | | - <tr> |
19 | | - <td>2</td> |
20 | | - <td>John</td> |
21 | | - </tr> |
22 | | -</table> |
23 | | - |
24 | | -<p> |
25 | | - <span class="itext">itext</span> 5.4.2 <span class="description"> converting HTML to PDF</span> |
26 | | -</p> |
27 | | -<p> |
28 | | -<div class="label">Title</div> |
29 | | -<span class="">iText - Java HTML to PDF</span> |
30 | | -<br/> |
31 | | - |
32 | | -</p> |
33 | | - |
34 | | -</body> |
| 3 | + <head> |
| 4 | + <title>HTML to PDF</title> |
| 5 | + <link href="style.css" rel="stylesheet" type="text/css" /> |
| 6 | + </head> |
| 7 | + <body> |
| 8 | + <h1>HTML to PDF</h1> |
| 9 | + <p> |
| 10 | + <span class="itext">itext</span> 5.4.2 <span class="description"> converting HTML to PDF</span> |
| 11 | + </p> |
| 12 | + <table> |
| 13 | + <tr> |
| 14 | + <th class="label">Title</th> |
| 15 | + <td>iText - Java HTML to PDF</td> |
| 16 | + </tr> |
| 17 | + <tr> |
| 18 | + <th>URL</th> |
| 19 | + <td>http://hmkcode.com/itext-html-to-pdf-using-java</td> |
| 20 | + </tr> |
| 21 | + </table> |
| 22 | + </body> |
35 | 23 | </html> |
Collapse file
Copy file name to clipboard Collapse file
Copy file name to clipboardExpand all lines: itext-java-html-pdf/src/main/java/com/hmkcode/App.java -4Lines changed: 0 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
3 | 3 | import java.io.FileInputStream; |
4 | 4 | import java.io.FileOutputStream; |
5 | 5 | import java.io.IOException; |
6 | | - |
7 | 6 | import com.itextpdf.text.Document; |
8 | 7 | import com.itextpdf.text.DocumentException; |
9 | 8 | import com.itextpdf.text.pdf.PdfWriter; |
10 | 9 | import com.itextpdf.tool.xml.XMLWorkerHelper; |
11 | | -import com.itextpdf.tool.xml.pipeline.css.CSSResolver; |
12 | 10 |
|
13 | 11 | public class App |
14 | 12 | { |
@@ -21,8 +19,6 @@ public static void main( String[] args ) throws DocumentException, IOException |
21 | 19 | // step 3 |
22 | 20 | document.open(); |
23 | 21 | // step 4 |
24 | | - //CSSResolver cssResolver = XMLWorkerHelper.getInstance().getDefaultCssResolver(true); |
25 | | - |
26 | 22 | XMLWorkerHelper.getInstance().parseXHtml(writer, document, |
27 | 23 | new FileInputStream("index.html")); |
28 | 24 | //step 5 |
|
Collapse file
Copy file name to clipboard +5-15Lines changed: 5 additions & 15 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | h1 { |
2 | 2 | color:#ccc; |
3 | 3 | } |
4 | | - |
5 | | -table tr td,th{ |
6 | | - width: 100px; |
7 | | - height: 50px; |
| 4 | +table tr td{ |
8 | 5 | text-align:center; |
9 | 6 | border:1px solid gray; |
| 7 | + padding:4px; |
10 | 8 | } |
11 | | - |
12 | 9 | table tr th{ |
13 | | - background-color: gray; |
| 10 | + background-color:#84C7FD; |
14 | 11 | color:#fff; |
| 12 | + width: 100px; |
15 | 13 | } |
16 | | - |
17 | 14 | .itext{ |
18 | 15 | color:#84C7FD; |
19 | 16 | font-weight:bold; |
20 | 17 | } |
21 | | - |
22 | 18 | .description{ |
23 | 19 | color:gray; |
24 | 20 | } |
25 | | -.label{ |
26 | | - width:70px; |
27 | | - height:30px; |
28 | | - display:inline-block; |
29 | | - background-color:#84C7FD; |
30 | | - color:#fff; |
31 | | -} |
| 21 | + |