Web SDKv1.0.0

AttachmentsApi.add()

Embed a file; it is in every save and export from then on. An index shifts down when an earlier attachment is deleted. Needs the edit-pages feature.
methodEditingsince 1.0.0

Signature

add(name: string, bytes: Uint8Array, options?: SignedDocumentOptions): Promise<number>

Parameters

ParameterTypeDescription
namestringThe file name to store.
bytesUint8ArrayThe file's bytes.
options?SignedDocumentOptions{ invalidateSignatures? }.

Returns

Promise<number> Its index in list() (zero-based: its position in the document's table), for data() / delete().

Throws

  • INVALID_ARGUMENT — an empty name.
  • PAGE_ERROR — the file could not be embedded.
  • FEATURE_NOT_LICENSED — the license lacks edit-pages.
  • DOCUMENT_CLOSED — the document has been closed.
  • INVALID_STATE — a certified document, unless options.invalidateSignatures; or a progressive document still downloading.

Example

TypeScript
const index = await doc.attachments.add('invoice.csv', csvBytes);

More in AttachmentsApi