op.combineDocs

From PDF XChange PDF SDK
Jump to: navigation, search


Overview

The operation allows to merge several documents into one.

Parameters

Name Type Description
Input Array Array of IUnknown-based objects containing the IOpInputItem elements that have IAFS_Name, IAFS_File or IPXC_Document specified along with the correspondent pages range that will be used when merging. Or it can contain the IAFS_Name, IAFS_File or IPXC_Document elements passed directly - then all of the pages from the source files will be used.
Output IUnknown IUnknown-based object containing the IPXC_Document that was merged from the input documents.
Options Dictionary Dictionary with options of the operation.

Sample

//C#
private void CombineDocuments(PDFXEdit.IPXC_Document Doc1, PDFXEdit.IPXC_Document Doc2, PDFXEdit.PXV_Inst Inst)
{
	int nID = Inst.Str2ID("op.combineDocs", false);
	PDFXEdit.IOperation Op = Inst.CreateOp(nID);
	//This operation has quite a unique input that uses IOpInputItem
	PDFXEdit.ICabNode input = Op.Params.Root["Input"];

	//Filling first input document params
	PDFXEdit.IOpInputItem inpItem1 = Op.CreateInputItem(Doc1);
	//Taking first 3 pages from first document
	inpItem1.Params.Root["PagesRange.Type"].v = "Exact";
	inpItem1.Params.Root["PagesRange.Text"].v = "1-3";
	//Adding first item to the input array
	input.Add().v = inpItem1;

	//Filling second input document params
	PDFXEdit.IOpInputItem inpItem2 = Op.CreateInputItem(Doc2);
	//Taking second page from the second document
	inpItem2.Params.Root["PagesRange.Type"].v = "Exact";
	inpItem2.Params.Root["PagesRange.Text"].v = "2";
	//Adding first item to the input array
	input.Add().v = inpItem2;

	PDFXEdit.ICabNode options = Op.Params.Root["Options"];
	options["AddRootBookmarks"].v = true;

	Op.Do();
	//Getting resulting document
	PDFXEdit.IPXC_Document resDoc = (PDFXEdit.IPXC_Document)Op.Params.Root["Output"].v;
	//pdfCtl.OpenDocFrom(resDoc);
}