Options

From PDF XChange PDF SDK
Jump to: navigation, search
 
Line 19: Line 19:
 
| Specifies the new content of the attachment. Note that it can be <code>IStream</code>, [[PXV:IAFS_Name|IAFS_Name]] or [[PXV:IAFS_File|IAFS_File]] type.
 
| Specifies the new content of the attachment. Note that it can be <code>IStream</code>, [[PXV:IAFS_Name|IAFS_Name]] or [[PXV:IAFS_File|IAFS_File]] type.
 
|}
 
|}
 +
 +
== Sample ==
 +
<pre class="brush:c#">//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 pTree = Doc.CoreDoc.GetNameTree("EmbeddedFiles");
 +
PDFXEdit.IAFS_FileSys pFSys = fsInst.DefaultFileSys;
 +
string sName;
 +
uint nAttachmentsCount = pTree.Count;
 +
if (nAttachmentsCount == 0)
 +
return;
 +
PDFXEdit.IPXS_PDFVariant pValue;
 +
//Getting first attachment
 +
pTree.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();
 +
}
 +
</pre>

Latest revision as of 04:54, 18 April 2016


Options Table

Name Type Value
Attachment IUnknown Specifies the IPXC_FileSpec which contents would be edited.
Contents IUnknown Specifies the new content of the attachment. Note that it can be IStream, IAFS_Name or IAFS_File type.

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 pTree = Doc.CoreDoc.GetNameTree("EmbeddedFiles");
	PDFXEdit.IAFS_FileSys pFSys = fsInst.DefaultFileSys;
	string sName;
	uint nAttachmentsCount = pTree.Count;
	if (nAttachmentsCount == 0)
		return;
	PDFXEdit.IPXS_PDFVariant pValue;
	//Getting first attachment
	pTree.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();
}