有谁知道是否可以使用 itextsharp 将垂直文本框添加到 PDF 文档。
我试过先旋转页面
PdfDictionary pDict = reader.GetPageN(1);
pDict.Put(PdfName.ROTATE, new PdfNumber(90));
AddTextBox(stamper, ...........)
// Rotate back
但这只是水平添加文本框,我需要在旋转后获取另一个 stamper 实例吗?
最佳答案
当您创建 TextField
时,设置其 Rotation
属性:
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);
}
}
关于c# - iTextSharp - 添加垂直文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8414019/