op.replaceContent

From PDF XChange PDF SDK
Jump to: navigation, search


Overview

The operation allows you to replace a part of an active PDF document with a part of already opened IPXC_Content.

Parameters

Name Type Description
Input IUnknown IUnknown-based object containing the IPXC_Document that will have it's pages changed.
Output IUnknown IUnknown-based object containing the IPXC_Document that had it's pages changed.
Options Dictionary Dictionary with options of the operation.

Sample

//C#
private void pDFToGrayscaleToolStripMenuItem_Click(object sender, EventArgs e)
{
	PDFXEdit.IPXC_Page page = pdfCtl.Doc.CoreDoc.Pages[0];
	//Getting full clone of the content so we can modify it fully
	PDFXEdit.IPXC_Content content = page.GetContent(PDFXEdit.PXC_ContentAccessMode.CAccessMode_FullClone);
	//Getting image or inline image types of the content items
	for (uint i = 0; i < content.Items.Count; i++)
	{
		PDFXEdit.IPXC_ContentItem ci = content.Items[i];
		if ((ci.Type == PDFXEdit.PXC_CIType.CIT_Image) || (ci.Type == PDFXEdit.PXC_CIType.CIT_InlineImage))
		{
			PDFXEdit.IIXC_Page ip = ci.Image_CreateIXCPage(true);
			PDFXEdit.IPXC_Image im = pdfCtl.Doc.CoreDoc.AddImageFromIXCPage(ip);
			ci.Image_Object = im;
		}
	}
	//...
	//Your changes to content
	//...
	//Now launching the replace content operation
	int nID = pdfCtl.Inst.Str2ID("op.replaceContent", false);
	PDFXEdit.IOperation Op = pdfCtl.Inst.CreateOp(nID);
	PDFXEdit.ICabNode input = Op.Params.Root["Input"];
	input.Add().v = pdfCtl.Doc.CoreDoc;
	PDFXEdit.ICabNode options = Op.Params.Root["Options"];
	options["NewContent"].v = content;
	options["TargetPage"].v = 0;
	Op.Do();
}