Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android fill PDF form

I have .pdf file and multiple forms are there. I want to open my .pdf file, fill the forms and save it from Android development.

Is there any API for Android Rendering. I found iText but I just manage to create new pdf and than i can fill form. means which .pdf file i created that will be filled out. I need to fill my form in my own .pdf.

Thanks in Advance...any help will be appreciated...

like image 293
AndroidDev Avatar asked Jul 31 '12 08:07

AndroidDev


People also ask

Why can't I fill in a PDF fillable form?

If you can't type into a form field on a pdf, it may be due to a browser's default viewer for pdfs. Fillable forms require Adobe Acrobat or Acrobat Reader/Acrobat DC to fill them out online or on your computer. Many browsers use a different pdf viewer by default that doesn't support fillable form fields.


1 Answers

DynamicPDF Merger for Java allows you to do just that. You can take an existing PDF document, fill out the form field values and then output that newly filled PDF.

There was a recent blog post on dynamicpdf.com on setting up DynamicPDF for Java in an Android application and creating a simple PDF from it, http://www.dynamicpdf.com/Blog/post/2012/06/15/Generating-PDFs-Dynamically-on-Android.aspx.

You can easily take that example one step further and use it to accomplish your task of form filling. The following (untested) code is an example of what it would take to form fill an existing PDF on an Android device using DynamicPDF Merger for Java:

InputStream inputStream = this.getAssets().open("PDFToFill.pdf");
long avail = inputStream.available();
byte[] samplePDF = new byte[(int) avail];
inputStream.read(samplePDF , 0, (int) avail);
inputStream.close();
PdfDocument objPDF = new PdfDocument(samplePDF);    

MergeDocument document = new MergeDocument(objPDF);
document.getForm().getFields().getFormField("FormField1").setValue("My Text");
document.draw("[PhysicalPath]/FilledPDF.pdf");
like image 95
Robbie Avatar answered Oct 06 '22 00:10

Robbie