SDK“图象域”本质是一个button类型的表单域。所以得按照e_TypePushButton类型获取,再通过widget.setMKNormalIconImage替换它的图标即可。
JAVA示例代码如下:
public static void GetField() throws PDFException {
PDFDoc doc=new PDFDoc("D:\\表单\\test_ImageField.pdf");
doc.load(null);
Form form = new Form(doc);
for (int pageIndex=0;pageIndex<doc.getPageCount();pageIndex++)
{
PDFPage page= doc.getPage(pageIndex);
page.startParse(0,null,true);
int controlCount= form.getControlCount(page);
for(int ctrIndex=0;ctrIndex<controlCount;ctrIndex++)
{
Control control= form.getControl(page,ctrIndex);
Field field=control.getField();
int fieldType= field.getType();
if(fieldType==Field.e_TypePushButton)
{
Widget widget= control.getWidget();
String strName= field.getName();
if(strName.contains("图像域"))
{
Image image = new Image("D:\\test\\foxitLogo.png");
widget.setMKNormalIconImage(image, 0);
widget.resetAppearanceStream();
}
}
}
}
doc.saveAs("D:\\表单\\result.pdf",0);
}