The GnuAPDF library provides support for generation of PDF files using standard Android "draw" commands. The library provides a special Canvas subclass, PDFCanvas, that is associated with a PDF document and that renders draw commands into PDF syntax. A sequence of Android Canvas drawing method calls will thus create a structured PDF document that, when viewed with a standard PDF reader, will display the corresponding image. Note that Android version 5.0 has this functionality as part of the standard API; however, earlier versions did not provide PDF generation, and the Android support library didn't include this as of the time of this writing.
This library is derived from the GnuJPDF library, which provides similar functionality for the Java AWT graphics system, and as such is similarly released under the LGPL License.
The class PDFCanvas implements the graphics operations defined by the standard Android Canvas class. To draw something into a PDF document, you use the standard Android Canvas drawing calls (including drawing, transformations, clips, etc.) on an instance of PDFCanvas. The PDFCanvas will encode these as PDF drawing commands.
The GnuAPDF library provides most of the drawing operations available in the standard Canvas class. However, certain methods are unimplemented due to lack of support in PDF; these will throw an UnsupportedOperationException if used. Some additional features currently have no or limited support, as indicated below.
Some example files generated with GnuAPDF are at the links below. The source code for these is available in the Example Code section.
A test project is available that illustrates how to use the library and can also be used to test its functionality.
The downloads are supplied as gzipped tar archives; the library archive contains the compiled gnuapdf.jar file for inclusion in a project, while the source archive contains the Java source files that can be used to rebuild the .jar file or included as source files in a referencing project.