Getting Started
Implementation
Last updated
Implementation
Last updated
PDF creator uses views which can be rendered on screen, So we need to extend an Activity
in order to create pdf.
Create a Empty Activity
without any layout and extend it with PDFCreatorActivity
. Do not set use setContentView(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
onNextClicked()
This is a handler method to get callback when user taps on Next.
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.
This library also provides PDFUtil.pdfToBitmap(File pdfFile)
method to get image preview of all pages of specified PDF file.