// ---------------------------------------------------------------------------
/**
* Show keys and values passed to the query string with GET
*/
protected void DoGet(byte[] pdf, Stream stream) {
// We get a resource from our web app
PdfReader reader = new PdfReader(pdf);
// Now we create the PDF
using (PdfStamper stamper = new PdfStamper(reader, stream)) {
// We add a submit button to the existing form
PushbuttonField button = new PushbuttonField(
stamper.Writer, new Rectangle(90, 660, 140, 690), "submit"
);
button.Text = "POST";
button.BackgroundColor = new GrayColor(0.7f);
button.Visibility = PushbuttonField.VISIBLE_BUT_DOES_NOT_PRINT;
PdfFormField submit = button.Field;
submit.Action = PdfAction.CreateSubmitForm(
WebContext.Request.RawUrl, null, 0
);
stamper.AddAnnotation(submit, 1);
// We add an extra field that can be used to upload a file
TextField file = new TextField(
stamper.Writer, new Rectangle(160, 660, 470, 690), "image"
);
file.Options = TextField.FILE_SELECTION;
file.BackgroundColor = new GrayColor(0.9f);
PdfFormField upload = file.GetTextField();
upload.SetAdditionalActions(PdfName.U,
PdfAction.JavaScript(
"this.getField('image').browseForFileToSubmit();"
+ "this.getField('submit').setFocus();",
stamper.Writer
)
);
stamper.AddAnnotation(upload, 1);
}
}