iTextPdf--the world's preferred PDF library

iText, the world's preferred PDF library

iText is a software developer toolkit that allows users to integrate PDF functionalities within their applications, processes or products. You know that PDF is one of the world's most widely used document formats, but perhaps you didn't know how it can keep being revolutionary? iText, in turn, is one of the best-documented and versatile PDF engines in the world. Don't believe us? See for yourself!


几个关键步骤:

1.快速开发:去github上搜索下载iText最新jar包,集成到项目中,你可能用到的两个链接:

https://github.com/itext/itextpdf/releases/tag/5.5.10

http://blog.csdn.net/zmx729618/article/details/52150070

2.深层定制:去github或者官网搜索下载iText源码,使用AS,SI查看并分析源码,需要用到的链接:

https://github.com/itext/itextpdf/releases/tag/5.5.10

http://itextpdf.com/


简单快速入门:

private void exportPDF() {
        String pdfile = Constants.EXPORTPATH + "xxx.pdf";
        // 1.创建一个document
        Document doc = new Document();
        //doc.setPageCount(mStrings.size());
        //有PageSize.B5,A4...
        int crWidth = Constants.CR_WIDTH;
        int ury = Constants.CR_HEIGHT - 90;
        doc.setPageSize(new Rectangle(crWidth, ury));
        FileOutputStream fos = null;
        try {
            fos = new FileOutputStream(new File(pdfile));
            PdfWriter writer = PdfWriter.getInstance(doc, fos);
            doc.open();
            PdfContentByte canvas = writer.getDirectContent();

            //...署名,版权,密码保护等

            //首页
            //doc.add(new Paragraph("Welcome to Shenzhen !"));

            //内容
            for (int i = 0; i < mStrings.size(); i++) {
                if (i > 0)
                    doc.newPage();
                drawPage(canvas, i);
                fos.flush();
            }

            //尾页
            //doc.newPage();
            //doc.add(new Paragraph("Thank you ! "));

            doc.close();
            ToastUtils.showLongToast(this, "成功导出到" + pdfile);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            FileUtils.close(fos);
        }
    }




























你可能感兴趣的:(Android,流行框架,android系统开发,Android,Framework开发)