Create a page
There are two options to create a page. First is using a UI component that can create a new page or a new document. Second is an API guide to programmatically create a page.
Create document pages in Android
The AddPageDialogFragment allows users are able to add new pages to an existing document or create a completely new document. The new pages created can have various types, sizes, and colors.

Add page dialog: dialog for creating new document (left), dialog for adding pages to an existing document (right).
Page properties
The following properties are available for creating or adding pages:
PageTypeThe following types of page are supported in this dialog:Blank: a page with nothing on it.Lined: a page with horizontal lines on it.Grid: a page with a superimposed grid on it.Graph: a page with Cartesian axes on it.Music: a page set up with modern staff notation for notating music.
PageSizeThe following page sizes are supported in this dialog:Custom,Letter,Legal,A4,A3,Ledger.
PageColorThe page background can be set to the following colors:White,Yellow, andBlueprint.
Create a new PDF document
To create a new PDF document, call newInstance() and override the OnCreateNewDocumentListener interface. The implementation of onCreateNewDocument(PDFDoc, String) should create a new file with the given title normalized to a ".pdf" extension.
Add pages to an existing document
To add pages to an existing PDF, create a new instance of the add page dialog fragment using newInstance(double, double) and provide the valid page width and page height arguments. These arguments will be used only if the user selects the Custom option in the Page Size dropdown. You also must implement the OnAddNewPagesListener interface and override onAddNewPages(Page[]), in which the implementation should add the provided pages to the document.
API to programmatically create pages in Android
To create a new 8.5x11 blank page and add it at the end of document's page sequence.
Note that, after the page is created, it does not yet belong to a document's page sequence. The page needs to be placed within the page sequence in order to become "visible". PagePushBack() inserts page x into the position of the document's last page.
About creating a new blank page
To create a new page, use the PDFDoc.PageCreate(media_box) method. PageCreate() takes an optional Rect argument that can be used to specify page size. This Rect is called a media box.
A media box is a rectangle, expressed in default user space units, defining the boundaries of the physical medium on which the page is intended to be displayed or printed. A user space unit is 1/72 of an inch. If media_box is unspecified, the default dimensions of the page are 8.5 x 11 inches (or 8.5*72, 11*72 units).
Last updated
Was this helpful?