[英]How to fill form in pdf with image for iText7?
I have pdf with form inside it.我有里面有表格的pdf。 I already can set form with value from text.
我已经可以用文本中的值设置表单了。 But how if I want to fill the field with image instead with text?
但是如果我想用图像而不是文本填充字段怎么办?
Replace it with a button, so add a button and insert an image into the button then replace the original formField with a button of the same Key and placement.将其替换为按钮,因此添加一个按钮并在按钮中插入图像,然后将原始 formField 替换为具有相同 Key 和位置的按钮。
formFields.TryGetValue(key, out var toSet);
PdfArray sizingArray = toSet.GetWidgets()[0].GetRectangle();
var width = (float)(sizingArray.GetAsNumber(2).GetValue() - sizingArray.GetAsNumber(0).GetValue());
var height = (float)(sizingArray.GetAsNumber(3).GetValue() - sizingArray.GetAsNumber(1).GetValue());
var imagbase64 = imaged.Draw(image);
var button = PdfFormField.CreatePushButton(
pdfDoc, new Rectangle(sizingArray.GetAsNumber(0).FloatValue(),
sizingArray.GetAsNumber(1).FloatValue(),
width,
height), key, "");
button.SetValue(imagbase64);
form.ReplaceField(key, button);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.