Javascript: EmbeddedFileCollection.addBinaryFile Method
Description
Adds an embedded binary file to the collection.
Syntax
<void> EmbeddedFileCollection.addBinaryFile(<string> fileName, <string> data, [<string> metaData], [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| fileName | Specifies the file's name. |
| data | Specifies the file's binary data as a base64 string. |
| metaData | Optional. 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. |
| callback | Optional. Is called when the operation completed. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates EmbeddedFileCollection.addBinaryFile in a practical document-editing workflow. It adds an embedded binary file to the collection.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
TXTextControl.textParts.getMainText(function(mainText) {
const embeddedFiles = mainText.embeddedFiles;
embeddedFiles.addBinaryFile(
"quarterly-report.docx",
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAFgAH/qbPzWQAAAABJRU5ErkJggg==",
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAFgAH/qbPzWQAAAABJRU5ErkJggg==",
function() {
console.log("add binary file completed.");
},
onTxError
);
}, onTxError);