1

I have PDF forms and I used adobe acrobat pro version 9 to add some hidden fields, buttons and some validation in javascript to it.

Also I am using dynamicPDF api (first time) in java to read that PDF and pre-populate few fields with some values (eg date with current date and some url fields) and drawing it into byte array and sending back to render.

But while rendering dynamic PDF is messing up my forms. Its not showing buttons perfectly that I added using adobe. Buttons are displayed with NO LABEL on it and if I click it shows * on it. Don't know why.

I am using Dynamic PDF as a replacement to FDF Merge. So I want same functionality from dynamicPDF and I am total beginner to both APIs.

Any suggestion?

Jared Farrish
  • 48,585
  • 17
  • 95
  • 104
misha2302
  • 11
  • 1

1 Answers1

0

This is my helper class to write and PDF---

public class PDFMerge {

    private MergeDocument document = null;



    public PDFMerge(File template) throws Exception {

        if (templatePdfFile == null)  {
            throw new Exception( );
                document = new MergeDocument(template.getAbsolutePath(), new MergeOptions(true));
        }


           }

    public MergeDocument mergePDF(String pdfformid, String url,
            ) {

        Calendar cal = Calendar.getInstance();

        if (document != null) {

                               //hidden fields on PDF form 


                if (document.getForm().getFields().getFormField("url_to_submit") != null) {
                    document.getForm().getFields().getFormField("url_to_submit")
                            .setValue(url);

                }


                //Date fields to prepopulate before rendered on browser

                if (document.getForm().getFields().getFormField("date.mm") != null) {
                    document
                            .getForm()
                            .getFields()
                            .getFormField("date.mm")
                            .setValue(
                                    String.valueOf(cal.get(Calendar.MONTH) + 1));

                }

                if (document.getForm().getFields().getFormField("date.dd") != null) {
                    .....

                }

                if (document.getForm().getFields().getFormField("date.yyyy") != null) {
                    ....
                }




            }
        }
                //document is drawn into byte array in servlet to send to output stream.

        return document;

    }


}

On servlet/caller (struts action) side ----

PDFMerge pdfmerge = new PDFMerge(form.getTemplateFile());
MergeDocument mergedPDF = printTool.mergePDF(String
.valueOf(form.getFormId()), URL);


byte[] pdfArray = mergedPDF.draw();

This byte array is forwarded onto JSP to be rendered. It doesnt display buttons correctly.

Saurabh Gokhale
  • 53,625
  • 36
  • 139
  • 164