我正在尝试使用 iText 填充文本字段的颜色。我尝试过 setfieldproperty,但它不适用于 bgcolor 或填充颜色属性。我正在寻找的是要设置的文本字段的属性,因为它将覆盖现有的文本或图像
最后我尝试了这两个案例..
' Create a new PDF reader based on the PDF template document
Dim pdfReaderBG As PdfReader = New PdfReader(pdfTemplate) ' Page of Fields
Dim pdfReaderFG As PdfReader = New PdfReader(pdfExisting) ' Image from CD Image
'Create the stream for the new PDF Document with the BackGround PDf
Dim writer As PdfStamper = New PdfStamper(pdfReaderBG, New FileStream("c:\temp\CDs\newMerge.pdf", FileMode.Create))
'Get all the content of the page
Dim content_Byte As PdfContentByte = writer.GetUnderContent(1)
'Then get the Other PDF to overlay the other
Dim mark_page As PdfImportedPage = writer.GetImportedPage(pdfReaderFG, 1)
If (mark_page.Width > mark_page.Height) Then 'Check to see if it is in Landscape
content_Byte.AddTemplate(mark_page, 0, -1, 1, 0, 0, mark_page.Width)
Else
'Then add the content to the new page over the Image
content_Byte.AddTemplate(mark_page, 0, 0)
End If
Dim formFields As AcroFields = writer.AcroFields
formFields.SetFieldProperty("cd28", "borderColor", BaseColor.GREEN, Nothing)
'content_Byte.te(BaseColor.PINK)
**formFields.SetFieldProperty("cd28", "backgroundcolor", BaseColor.YELLOW, Nothing)
'formFields.setfieldproperty("cd28") ' SetFieldProperty("cd28", "bgColor", BaseColor.WHITE, Nothing)**
我只想更改一个文本字段背景的颜色
当您手动编辑文档中的文本字段时。属性的外观选项卡。它具有填充颜色和边框颜色的属性我可以做边框颜色..我似乎无法在代码中做填充颜色属性..