It is necessary having a document template, fill in the fields in it, and save after. All this is done programmatically, from within the Android application. There are two options:
- There is a .pdf file. Fill in the fields in it and save it
- There is a .doc file. Fill in the fields in it, convert it to .pdf and save.
The problem is that you cannot use commercial libraries, and libraries with licenses that require opening source code. Most of the answers that I found were quite ancient, I think during this time new libraries came out. Or the libraries that they consulted do not have documentation.