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);        }    }




























更多相关文章

  1. android 源码下载及问题
  2. Android(安卓)learning Starting!
  3. android手电源码
  4. android 贪吃蛇源码分析
  5. android 用到的技巧集
  6. Android(安卓)获取设备序列号(SN号)含源码Demo
  7. Android(安卓)NavigationBar 代码分析记录(一)
  8. Android(安卓)源码下载、编译填坑
  9. android在eclipse上搭建环境---android launcher移植之(一)

随机推荐

  1. Android(安卓)-- 内容观察者
  2. Android系统介绍
  3. Android中Intent传递对象的两种方法(Seri
  4. 【Android】小白进阶之接口和抽象类的使
  5. 获取Android开机启动项列表
  6. Retrofit使用总结
  7. Android中文API(99)—— RelativeLayout
  8. Android中IntentService的使用及其源码解
  9. Android采用Junit进行应用单元测试
  10. Android Debug keystore系统位置