问题
Does anyone know if it's possible to add a vertical textbox to a PDF document using itextsharp.
I have tried rotating the page first
PdfDictionary pDict = reader.GetPageN(1);
pDict.Put(PdfName.ROTATE, new PdfNumber(90));
AddTextBox(stamper, ...........)
// Rotate back
but this just adds the textbox horizontally, do I need to get another instance of stamper after the rotation?
回答1:
When you create the TextField
set its Rotation
property:
PdfReader reader = new PdfReader(file1);
using (FileStream fs = new FileStream(file2, FileMode.Create, FileAccess.Write, FileShare.None))
{
using (PdfStamper stamper = new PdfStamper(reader, fs))
{
TextField tf = new TextField(stamper.Writer, new iTextSharp.text.Rectangle(0, 0, 100, 300), "Vertical");
//Change the orientation of the text
tf.Rotation = 90;
stamper.AddAnnotation(tf.GetTextField(), 1);
}
}
来源:https://stackoverflow.com/questions/8414019/itextsharp-adding-a-vertical-textbox