op.fields.modify

From PDF XChange PDF SDK
Jump to: navigation, search


Overview

The operation is used to modify form fields' values.

Parameters

Name Type Description
Input Array Array of IUnknown-based objects containing the form fields that need to be modified.
Output Array Is not used.
Options Dictionary Dictionary with options of the operation.

Sample

//C#
PDFXEdit.IPXC_Document CreateNewDocument(out PDFXEdit.PXC_Rect rc)
{
	PDFXEdit.IPXC_Document coreDoc = pxcInst.NewDocument();
	rc.left = 0;
	rc.right = 500;
	rc.top = 800;
	rc.bottom = 0;
	PDFXEdit.IPXC_UndoRedoData urd;
	coreDoc.Pages.AddEmptyPages(0, 1, ref rc, null, out urd);
	rc.left = 10;
	rc.right = 100;
	rc.top = 700;
	rc.bottom = 670;
	return coreDoc;
}

private void SetComboBoxValue()
{
	PDFXEdit.PXC_Rect rc;
	PDFXEdit.IPXC_Document coreDoc = CreateNewDocument(out rc);
	{
		PDFXEdit.IPXC_FormField ff = coreDoc.AcroForm.CreateField("ComboBox1", PDFXEdit.PXC_FormFieldType.FFT_ComboBox, 0, ref rc);
		ff.InsertOptRecord("Value1", "Label1");
		ff.InsertOptRecord("Value2", "Label2");
		ff.InsertOptRecord("Value3", "Label3");
		ff.InsertOptRecord("Value4", "Label4");
	}
	pdfCtl.OpenDocFrom(coreDoc);
	{
		PDFXEdit.IPXC_FormField ff = coreDoc.AcroForm.GetFieldByName("ComboBox1");
		int nID = pdfCtl.Inst.Str2ID("op.fields.modify", false);
		PDFXEdit.IOperation Op = pdfCtl.Inst.CreateOp(nID);
		PDFXEdit.ICabNode input = Op.Params.Root["Input"];
		input.Add().v = ff;
		PDFXEdit.ICabNode options = Op.Params.Root["Options"];
		PDFXEdit.ICabNode value = options["Value"];
		value["Selection"].Add().v = 2;
		options["Mask"].v = 0x00000100 | 0x00000800; // Value modification
		Op.Do();
	}
}