Python - 如何使用 pdfrw 在 PDF 表单中正确填充多行文本字段?

问题描述

我正在使用 python 和 pdfrw 填写 PDF 表单。我对表单中的任何单行文本字段都没有问题。但是当我尝试填充多行文本字段时,它无法正确呈现,它会忽略断行。

这是我的代码的一部分:

pdf.Root.AcroForm.update(PdfDict(NeedAppearances=PdfObject('true')))

for x in range(0,len(pdf.Root.AcroForm.Fields)):
    try:
        if pdf.Root.AcroForm.Fields[x].T in ['(Observaciones)']:
            pdf.Root.AcroForm.Fields[x].update(PdfDict(V='This\nis\nmultiline',Ff=1))
            continue

这是输出

enter image description here

这是使用 Adob​​e Acrobat 在表单字段中的设置。

enter image description here

我选择了选项:多行、滚动长文本、允许富文本格式。

我也尝试过使用 \r<br> 标签

我应该如何设置值以正确呈现?

解决方法

我无法阅读西班牙语设置,但如果您确保选中这两个字段,那么您可能会没事。

Setting