Пример #1
0
        protected void ManipulatePdf(String dest)
        {
            PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
            PdfAcroForm form   = PdfAcroForm.GetAcroForm(pdfDoc, true);

            PdfTextFormField field = PdfFormField.CreateText(pdfDoc,
                                                             new Rectangle(36, 788, 523, 18), "myfile", "");

            // If true is passed, then the text entered in the field will represent the pathname of a file
            // whose contents are to be submitted as the value of the field.
            field.SetFileSelect(true);

            // When the mouse is released inside the annotation's area (that's what PdfName.U stands for),
            // then the focus will be set on the "mytitle" field.
            field.SetAdditionalAction(PdfName.U, PdfAction.CreateJavaScript(
                                          "this.getField('myfile').browseForFileToSubmit();"
                                          + "this.getField('mytitle').setFocus();"));
            form.AddField(field);

            PdfTextFormField title = PdfFormField.CreateText(pdfDoc,
                                                             new Rectangle(36, 752, 523, 18), "mytitle", "");

            form.AddField(title);

            pdfDoc.Close();
        }