iTextsharp多行字段文本未与行对齐

时间:2017-07-31 19:30:55

标签: forms pdf itext

我们有一些带有多行字段的pdf表格。当我们使用itextsharp 5填充这些字段中的数据时,文本未正确对齐行。 有什么

Multiline fields line alignment

这是我的代码 - 我发送flatten = true

   public static Stream FillPdf(Stream SourceFile, IDictionary<string, string> Values, bool flatten = false)
    {
        //Set Unethical reading to true to overcome owner password
        PdfReader.unethicalreading = true;
        //create PdfReader object to read the source file
        PdfReader reader = new PdfReader(SourceFile);
        Stream output = new MemoryStream();
        PdfStamper stamper;
        if (flatten)
            stamper = new PdfStamper(reader, output);
        else
            stamper = new PdfStamper(reader, output, '\0', true);
        stamper.Writer.CloseStream = false;
        AcroFields form = stamper.AcroFields;

        Values.ToList().ForEach(v => form.SetField(v.Key, v.Value ?? string.Empty));

        stamper.FormFlattening = flatten;

        stamper.Close();
        reader.Close();

        return output;
    }

0 个答案:

没有答案