TX Text Control .NET Server

EmbeddedFile Constructor

Constructor|Introduced in 29.0
Namespace
TXTextControl
Package
TXTextControl.TextControl.Core.SDK as TXTextControl.Core.dll from the private NuGet feed or Text Control Offline Packages
Also in
TXTextControl.TextControl.ASP.SDK as TXTextControl.dll

Description

Initializes a new instance of the EmbeddedFile class.

Syntax

EmbeddedFile(string, SafeFileHandle, string)

Initializes a new instance of an embedded file with the specified name. The file's data is given through the specified file handle. When the document is saved, the data is read from the file and embedded in the document.

public EmbeddedFile(string fileName, SafeFileHandle handle, string metaData);
ParameterDescription
fileName

Specifies the file's name. The name can include a relative or absolute path.

handle

Identifies a file from which the data to embed is read.

metaData

Specifies additional metadata with properties of the document which is embedded. The data is added to the metadata of the containing document. The string must consist of one or more rdf:Description elements as specified by the XMP Specification (XMP: Extensible Metadata Platform, Adobe Systems Incorporated) or the RDF Model and Syntax Specification (http://www.w3.org/TR/rdf-syntax-grammar/). rdf is the XML namespace prefix for the "http://www.w3.org/1999/02/22-rdf-syntax-ns#" namespace. It can be null or an empty string, if there is no additional meta data to embed.

EmbeddedFile(string, string, string)

Initializes a new instance of an embedded file with the specified name and string data.

public EmbeddedFile(string fileName, string data, string metaData);
ParameterDescription
fileName

Specifies the file's name. The name can include a relative or absolute path.

data

Specifies the file's data. The data can be a string or binary data.

metaData

Specifies additional metadata with properties of the document which is embedded. The data is added to the metadata of the containing document. The string must consist of one or more rdf:Description elements as specified by the XMP Specification (XMP: Extensible Metadata Platform, Adobe Systems Incorporated) or the RDF Model and Syntax Specification (http://www.w3.org/TR/rdf-syntax-grammar/). rdf is the XML namespace prefix for the "http://www.w3.org/1999/02/22-rdf-syntax-ns#" namespace. It can be null or an empty string, if there is no additional meta data to embed.

EmbeddedFile(string, byte[], string)

Initializes a new instance of an embedded file with the specified name and binary data.

public EmbeddedFile(string fileName, byte[] data, string metaData);
ParameterDescription
fileName

Specifies the file's name. The name can include a relative or absolute path.

data

Specifies the file's data. The data can be a string or binary data.

metaData

Specifies additional metadata with properties of the document which is embedded. The data is added to the metadata of the containing document. The string must consist of one or more rdf:Description elements as specified by the XMP Specification (XMP: Extensible Metadata Platform, Adobe Systems Incorporated) or the RDF Model and Syntax Specification (http://www.w3.org/TR/rdf-syntax-grammar/). rdf is the XML namespace prefix for the "http://www.w3.org/1999/02/22-rdf-syntax-ns#" namespace. It can be null or an empty string, if there is no additional meta data to embed.

Examples

The following example embeds a PDF attachment and preserves its media type during WordprocessingML export.

EmbeddedFile embeddedFile = new("terms.pdf", @"Attachments\terms.pdf", "application/pdf");
SaveSettings saveSettings = new() { EmbeddedFiles = new[] { embeddedFile } };
textControl.Save("contract-with-attachment.docx", StreamType.WordprocessingML, saveSettings);