// ---------------------------------------------------------------------------
/**
* Shows the stream passed to the server with POST
*/
protected void DoPost(byte[] pdf, Stream stream) {
using (Stream s = WebContext.Request.InputStream) {
// Create a reader that interprets the Request's input stream
FdfReader fdf = new FdfReader(s);
// 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 alter the fields of the existing PDF
AcroFields fields = stamper.AcroFields;
fields.SetFields(fdf);
stamper.FormFlattening = true;
// Gets the image from the FDF file
try {
Image img = Image.GetInstance(fdf.GetAttachedFile("image"));
img.ScaleToFit(100, 100);
img.SetAbsolutePosition(90, 590);
stamper.GetOverContent(1).AddImage(img);
}
catch {
ColumnText.ShowTextAligned(
stamper.GetOverContent(1),
Element.ALIGN_LEFT,
new Phrase("No image posted!"),
90, 660, 0
);
}
}
}
}