Set AcroField Text Size to Auto

泄露秘密 提交于 2019-12-19 04:04:51

问题


Using itextsharp, I'm attempting to set the font size of my form's text fields to auto.

I'm currently doing something like this:

Object d = 0.0;

PdfReader reader = new PdfReader(path);

byte [] pdf;

using (var ms = new MemoryStream())
{
    PdfStamper stamper = new PdfStamper(reader, ms);

    AcroFields fields = stamper.AcroFields;

    foreach (var f in fields.Fields.Keys)
    {
        fields.SetFieldProperty(f, "textsize", d, null);
    }
}

But I'm getting the following error:

System.InvalidCastException: Specified cast is not valid.
at iTextSharp.text.pdf.AcroFields.SetFieldProperty(String field, String name, Object value, Int32[] inst)

How can I fix this?


回答1:


Using 0f instead of d in the call SetFieldProperty let me change the font size to auto.



来源:https://stackoverflow.com/questions/24944090/set-acrofield-text-size-to-auto

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!