【问题标题】:IText 7, Text alignment inside a PdfFormField?IText 7,PdfFormField 内的文本对齐?
【发布时间】:2017-10-02 16:09:02
【问题描述】:

我已经尝试并搜索过这个问题,但没有运气。

这是我尝试过的。

using (PdfDocument doc = new PdfDocument(new PdfReader(template), new 
PdfWriter(newPath)))
{
    PdfAcroForm form = PdfAcroForm.GetAcroForm(doc, true);

    // Replace form fields with correct data
    form.GetField("Greet").SetValue("Hello world!");    


    // I have tried this to with no luck
    form.GetField("Greet").SetJustification(1).SetValue("Hello World");

    form.FlattenFields();
}

【问题讨论】:

    标签: itext7


    【解决方案1】:

    Pdf 不支持 acro-forms 的对齐方式。 所以这不是 iText 问题。规范根本不允许这样做。

    【讨论】:

    • 考虑将我的答案标记为已接受的答案。因为这确实是规范所说的:p
    • 感谢您的快速回复 在下面的链接中:itextsupport.com/apidocs/itext7/7.0.1/com/itextpdf/forms/fields/… 我发现了这个: public PdfFormField setJustification(int justification) 设置一个代码,指定用于显示文本的四边形(对齐)形式: 0 左对齐 1 居中 2 右对齐 参数: justification - 设置对齐属性的值 返回:编辑的字段(“你好世界”);”不居中,
    • 这是因为表单域(逻辑上)继承自提供此方法的组件。而不是因为我们支持这种方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-07-04
    • 2021-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-05
    相关资源
    最近更新 更多