码迷,mamicode.com
首页 > Web开发 > 详细

Converting HTML to PDF with pdfHTML

时间:2017-12-14 03:42:42      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:tput   mod   tps   div   class   body   padding   attribute   itext   

https://itextpdf.com/itext7/pdfHTML

pdfHTML 的一个例子

一个基本的例子将显示使用 pdfHTML。为此, 我们将使用下面的 HTML 和 CSS。

 

        <head>
            <style>
                p {
                    color : #084975;
                }
                div{ 
                    color: #F99D25; 
                }
            </style>
        </head>
        <body>
            <p>iText</p>
            <div>Your developer journey with iText begins here</div>
        </body>

输出将使用以下代码直接写入 PDF 文件:

 

    public static void main() throws IOException {
 
        // IO
        File htmlSource = new File("input.html");
        File pdfDest = new File("output.pdf");
 
        // pdfHTML specific code
        ConverterProperties converterProperties = new ConverterProperties();
        HtmlConverter.convertToPdf(new FileInputStream(htmlSource), new FileOutputStream(pdfDest), converterProperties);
    }

 

Converting HTML to PDF with pdfHTML

标签:tput   mod   tps   div   class   body   padding   attribute   itext   

原文地址:http://www.cnblogs.com/imust2008/p/8035594.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!