Getting Started

Implementation

Implementation

  1. PDF creator uses views which can be rendered on screen, So we need to extend an Activity in order to create pdf.

  2. Create a Empty Activity without any layout and extend it with PDFCreatorActivity. Do not set use setContentView(int resourceId) inside your created activity.

  3. There are 3 abstract methods you have to override.

    1. getHeaderView()

      • This will be header for PDF and will be added to each page. (Accepts PDFHeaderView)

    2. getBodyViews()

      • This will return a PDFBody which consist of list of views which can be broken between pages.

    3. getFooterView()

      • This will be footer for PDF and will be added to each page. (Accepts PDFFooterView)

    4. getWatermarkView()

      • [OPTIONAL] This add a watermark image to each page. (Accepts PDFImageView), see issue #14

    5. onNextClicked()

      • This is a handler method to get callback when user taps on Next.

  4. In onCreate of you activity, you have to call createPDF(String fileName, PDFUtilListener listener). It will generate PDF and give you a PDF file in callback (if success). After receiving callback you can close activity and do whatever you need to do with PDF.

  5. This library also provides PDFUtil.pdfToBitmap(File pdfFile) method to get image preview of all pages of specified PDF file.

Here is an example to create your own pdf

Last updated