op.contentItems.setProps

From PDF XChange PDF SDK
Jump to: navigation, search
(Sample)
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
  
 
== Overview ==
 
== Overview ==
The operation allows to set properties of the required text items.
+
The operation allows to set properties of the required content items.
  
 
== Parameters ==
 
== Parameters ==
Line 15: Line 15:
 
| class="op_param_name" | Input
 
| class="op_param_name" | Input
 
| style="text-align:center" | Array
 
| style="text-align:center" | Array
| Array of <code>IUnknown</code>-based objects.
+
| Array of <code>IUnknown</code>-based objects containing the [[PXV:IPXC_Document|IPXC_Document]] which content items will be modified.
 
|-
 
|-
 
| class="op_param_name" | Output
 
| class="op_param_name" | Output
 
| style="text-align:center;" | Array
 
| style="text-align:center;" | Array
| Array of <code>IUnknown</code>-based objects.
+
| Array of <code>IUnknown</code>-based objects containing the [[PXV:IPXC_Document|IPXC_Document]] that had it's content items modified.
 
|-
 
|-
 
| class="op_param_name" | [[PXV:op_contentItems_setProps_Options|Options]]
 
| class="op_param_name" | [[PXV:op_contentItems_setProps_Options|Options]]
Line 34: Line 34:
 
//Creating contentItems.setProps operation
 
//Creating contentItems.setProps operation
 
int nID = Inst.Str2ID("op.contentItems.setProps", false);
 
int nID = Inst.Str2ID("op.contentItems.setProps", false);
PDFXEdit.IOperation pOp = Inst.CreateOp(nID);
+
PDFXEdit.IOperation Op = Inst.CreateOp(nID);
var input = pOp.Params.Root["Input"];
+
var input = Op.Params.Root["Input"];
 
input.Add().v = Doc.CoreDoc;
 
input.Add().v = Doc.CoreDoc;
PDFXEdit.ICabNode options = pOp.Params.Root["Options"];
+
PDFXEdit.ICabNode options = Op.Params.Root["Options"];
 
int nSelID = Inst.Str2ID("selection.contentItems", false);
 
int nSelID = Inst.Str2ID("selection.contentItems", false);
 
uint nPage = 0; //Page number that will have it's content items modified
 
uint nPage = 0; //Page number that will have it's content items modified
Line 58: Line 58:
 
//Setting mask that will tell the operation that the FColor will be modified
 
//Setting mask that will tell the operation that the FColor will be modified
 
options["Mask"].v = 2;
 
options["Mask"].v = 2;
pOp.Do();
+
Op.Do();
 
//Clearing the selection
 
//Clearing the selection
 
itSel.Clear();
 
itSel.Clear();
 
}
 
}
 
</pre>
 
</pre>

Latest revision as of 23:38, 18 April 2016


Overview

The operation allows to set properties of the required content items.

Parameters

Name Type Description
Input Array Array of IUnknown-based objects containing the IPXC_Document which content items will be modified.
Output Array Array of IUnknown-based objects containing the IPXC_Document that had it's content items modified.
Options Dictionary Dictionary with options of the operation.

Sample

//C#
private void SetContentColor(PDFXEdit.IPXV_Document Doc, PDFXEdit.PXV_Inst Inst)
{
	if (Doc == null)
		return;
	//Creating contentItems.setProps operation
	int nID = Inst.Str2ID("op.contentItems.setProps", false);
	PDFXEdit.IOperation Op = Inst.CreateOp(nID);
	var input = Op.Params.Root["Input"];
	input.Add().v = Doc.CoreDoc;
	PDFXEdit.ICabNode options = Op.Params.Root["Options"];
	int nSelID = Inst.Str2ID("selection.contentItems", false);
	uint nPage = 0; //Page number that will have it's content items modified
	//First we need to create content items selection
	PDFXEdit.IPXV_ContentItemsSelection itSel = (PDFXEdit.IPXV_ContentItemsSelection)Doc.CreateStdSel((uint)nSelID);
	//Then we need to get root item entry for the desired page (we'll create it if needed)
	PDFXEdit.IPXV_ContentItemEntry itEntry = itSel.GetSel(nPage, true);
	//Inserting needed content items from the page
	var content = Doc.CoreDoc.Pages[nPage].GetContent(PDFXEdit.PXC_ContentAccessMode.CAccessMode_WeakClone);
	for (uint i = 0; i < content.Items.Count; i++)
	{
		//For example we will take all of the text items
		if (content.Items[i].Type == PDFXEdit.PXC_CIType.CIT_Text)
			itEntry.Insert(i);
	}
	//Adding selected page's root entry with added content items to the operation
	options["Entries"].Add(PDFXEdit.CabDataTypeID.dt_IUnknown).v = itEntry;
	//Setting the color (note that rgb notation is rgb(r,g,b) where r g b are float values from 0.0 to 1.0)
	options["FColor"].v = "#AC3312";
	//Setting mask that will tell the operation that the FColor will be modified
	options["Mask"].v = 2;
	Op.Do();
	//Clearing the selection
	itSel.Clear();
}