op.attachments.modContents

From PDF XChange PDF SDK
Jump to: navigation, search


Overview

The operation allows to modify the content of the given attachment.

Parameters

Name Type Description
Input Array Array of IUnknown-based objects that should contain the IPXC_Document that contains the attachment that would be modified. Note that only the first element from the array will be evaluated.
Output Array Array of IUnknown-based objects containing the IPXC_Document which attachment was modified.
Options Dictionary Dictionary with options of the operation.

Sample

//C#
private void ModifyAttachmentContents(PDFXEdit.IPXV_Document Doc, PDFXEdit.IPXV_Inst Inst)
{
	int nID = Inst.Str2ID("op.attachments.modContents", false);
	PDFXEdit.IOperation Op = Inst.CreateOp(nID);
	PDFXEdit.ICabNode input = Op.Params.Root["Input"];
	input.Add().v = Doc;
	PDFXEdit.ICabNode options = Op.Params.Root["Options"];
	PDFXEdit.IPXC_NameTree Tree = Doc.CoreDoc.GetNameTree("EmbeddedFiles");
	PDFXEdit.IAFS_Inst fsInst = (PDFXEdit.IAFS_Inst)Inst.GetExtension("AFS");
	PDFXEdit.IAFS_FileSys pFSys = fsInst.DefaultFileSys;
	string sName;
	uint nAttachmentsCount = Tree.Count;
	if (nAttachmentsCount == 0)
		return;
	PDFXEdit.IPXS_PDFVariant pValue;
	//Getting first attachment
	Tree.Item(0, out sName, out pValue);
	PDFXEdit.IPXC_FileSpec FS = Doc.CoreDoc.GetFileSpecFromVariant(pValue);
	options["Attachment"].v = FS;
	PDFXEdit.IAFS_Name sourceFile = fsInst.DefaultFileSys.StringToName("D:\\TestImage.png"); //Converting string to name
	options["Contents"].v = sourceFile;
	Op.Do();
}