How to fill an editable PDF with stored data in Kotlin?

Viewed 564

I'm coding an application on Android Studio using Kotlin. For now, I have one fragment where the user has to fill some fields (like "Client", "Date", etc) and I'd like to put these information in an editable PDF that already exists when the user clicks on a "Validate" button. I searched for hours, but the only solution I found is called "Pdftron", but I couldn't make it work without the (4000$/year) license. Is there any way I can fill the PDF using Kotlin? Does anyone know how to use properly the demo version of Pdftron?

Thank you in advance.

Here is a screenshot of the existing editable PDF as an example:

IMAGE

EDIT: Someone sent me this: https://pdfbox.apache.org/, that could help me. I'll dig that tomorrow, but I'm still open to any suggestion :)

2 Answers

You can try the demo version of PDFTron by integrating via Gradle: https://www.pdftron.com/documentation/android/get-started/integration/gradle/ (the demo version does not require any trial license key, simply add it to your app to try out).

For your app, it looks like your editable PDF contains text fields and you are trying to populate these text fields. In this case, you can use PDFTron's FieldIterator API to traverse the text fields and insert your information.

For reference, you can check out this Kotlin sample (specifically "Example 2: Fill-in forms / Modify values of existing fields"): https://www.pdftron.com/documentation/samples/kt/InteractiveFormsTest?platforms=android

Related