3

How can I set the vertical alignment to center in a PDF field when using iTextSharp? I have already set the field to vertical align center within Acrobat, but when I write text from my application to the PDF it aligns top. If I uncheck the multiline box within Acrobat, the text aligns to center, but will not work with multiline. Here is my code:

var reader = new PdfReader(Server.MapPath("PDFs/SuperiorSubShell1.pdf"));
var output = new MemoryStream();
var stamper = new PdfStamper(reader, output);

stamper.AcroFields.SetField("paperTitle", paperTitle.ToUpper());
stamper.FormFlattening = true;

stamper.Close();
reader.Close();

Response.AddHeader("Content-Disposition", "attachment; filename=YourPdf.pdf");
Response.ContentType = "application/pdf";

Response.BinaryWrite(output.ToArray());
Response.End();
azSphinx
  • 109
  • 1
  • 6

0 Answers0