op.contentItems.transform

From PDF XChange PDF SDK
Jump to: navigation, search


Overview

The operation allows to transform the required content items.

Parameters

Name Type Description
Input Array Array of IUnknown-based objects containing the IPXC_Document which content items will be transformed.
Output Array Not yet implemented.
Options Dictionary Dictionary with options of the operation.

Sample

//C#
private void TransformContentItems(PDFXEdit.IPXV_Document Doc, PDFXEdit.IPXV_Inst Inst)
{
	//Creating contentItems.delete operation
	int nID = Inst.Str2ID("op.contentItems.transform", 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;
	//Specifying the transformation matrix
	options["Matrix.a"].v = 0.8;
	options["Matrix.b"].v = 0.6;
	options["Matrix.c"].v = -0.6;
	options["Matrix.d"].v = 0.8;
	options["Matrix.e"].v = 0;
	options["Matrix.f"].v = 0;
	//Transforming content items
	Op.Do();
	//Clearing the selection
	itSel.Clear();
}