| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,33 @@ | |||
| 1 | + package com.hmkcode; | ||
| 2 | + | ||
| 3 | + import java.io.FileInputStream; | ||
| 4 | + import java.io.FileOutputStream; | ||
| 5 | + import java.io.IOException; | ||
| 6 | + | ||
| 7 | + import com.itextpdf.text.Document; | ||
| 8 | + import com.itextpdf.text.DocumentException; | ||
| 9 | + import com.itextpdf.text.pdf.PdfWriter; | ||
| 10 | + import com.itextpdf.tool.xml.XMLWorkerHelper; | ||
| 11 | + import com.itextpdf.tool.xml.pipeline.css.CSSResolver; | ||
| 12 | + | ||
| 13 | + public class App | ||
| 14 | + { | ||
| 15 | + public static void main( String[] args ) throws DocumentException, IOException | ||
| 16 | + { | ||
| 17 | + // step 1 | ||
| 18 | + Document document = new Document(); | ||
| 19 | + // step 2 | ||
| 20 | + PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("pdf.pdf")); | ||
| 21 | + // step 3 | ||
| 22 | + document.open(); | ||
| 23 | + // step 4 | ||
| 24 | + //CSSResolver cssResolver = XMLWorkerHelper.getInstance().getDefaultCssResolver(true); | ||
| 25 | + | ||
| 26 | + XMLWorkerHelper.getInstance().parseXHtml(writer, document, | ||
| 27 | + new FileInputStream("index.html")); | ||
| 28 | + //step 5 | ||
| 29 | + document.close(); | ||
| 30 | + | ||
| 31 | + System.out.println( "PDF Created!" ); | ||
| 32 | + } | ||
| 33 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments