op.contentItems.delete

From PDF XChange PDF SDK
Jump to: navigation, search


Overview

The operation allows to remove content items from the page's contnet.

Parameters

Name Type Description
Input Array Array of IUnknown-based objects containing the IPXC_Document that will have it's pages' content items removed.
Output Array Not yet implemented.
Options Dictionary Dictionary with options of the operation.

Sample

//C#
private void RemoveContentItems(PDFXEdit.IPXV_Document Doc, PDFXEdit.IPXV_Inst Inst)
{
	//Creating contentItems.delete operation
	int nID = Inst.Str2ID("op.contentItems.delete", 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 deleted
	//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;
	//Removing content items
	Op.Do();
	//Clearing the selection
	itSel.Clear();
}