File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
itext-java-html-pdf/main/java/com/hmkcode Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments