Getting Started
Implementation
Implementation
PDF creator uses views which can be rendered on screen, So we need to extend an
Activityin order to create pdf.Create a Empty
Activitywithout any layout and extend it withPDFCreatorActivity. Do not set usesetContentView(int resourceId)inside your created activity.There are 3 abstract methods you have to override.
getHeaderView()This will be header for PDF and will be added to each page. (Accepts
PDFHeaderView)
getBodyViews()This will return a PDFBody which consist of list of views which can be broken between pages.
getFooterView()This will be footer for PDF and will be added to each page. (Accepts
PDFFooterView)
getWatermarkView()[OPTIONAL] This add a watermark image to each page. (Accepts
PDFImageView), see issue #14
onNextClicked()This is a handler method to get callback when user taps on Next.
In
onCreateof you activity, you have to callcreatePDF(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.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