iTextSharp - 添加垂直文本框 [英] iTextSharp - Adding a vertical textbox

查看:723
本文介绍了iTextSharp - 添加垂直文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道是否可以使用itextsharp将垂直文本框添加到PDF文档。

Does anyone know if it's possible to add a vertical textbox to a PDF document using itextsharp.

我尝试先旋转页面

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?

推荐答案

当您创建 TextField 时,设置其轮换属性:

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);
    }
}

这篇关于iTextSharp - 添加垂直文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆