Adding Rich Text to AcroField in iTextSharp

I need to add formatted text to a PDF form field using iTextSharp, and I cannot figure out how to understand this. This is how I set the fields right now, but some parts of the inserted text should be bold or have a different formatting.

stamper.AcroFields.SetField("fieldName", "fieldValue")
stamper.FormFlattening = True

I saw elsewhere so that I can embed some xml that includes formatting information, but I have no idea what that xml should look like.

Here is a section from this page that makes me believe what I want:

It still marks the actual XML code on the field, and Reader will not make it like rich text in a PDF stamp.

And a working answer to this:

To do this, you will need to call AcroFields.setGenerateAppearances (false). Please note that older versions of Reader did not generate appearances.

What should this xml look like or is there another way to do this?

+3
source share
1 answer

A back, I added the iText feature to set rich text value for a field. I did not add any rendering code to support this.

, - PDF, (Reader/Acrobat). , , acroFields.setGenerateAppearances(false). iText , PDF .

iText [Sharp], - :

  • PDF . . ( ).
  • PushbuttonField, LAYOUT_ICON_ONLY. , . null ().
  • PdfImportedPage PushbuttonField ().
  • Flatten.

, .

# 1 HTMLWorker /HTML .

, , , HTMLWorker, ColumnText, HTML , , . PdfTemplate DirectContent .

.

0

Source: https://habr.com/ru/post/1718192/


All Articles