Document

The document section allows to change all the parameters pertaining to the document (title, url, file type, etc.).

fileType

Defines the type of the file for the source viewed or edited document. Must be lowercase. The following file types are available: .csv, .djvu, .doc, .docm, .docx, .docxf, .dot, .dotm, .dotx, .epub, .fb2, .fodp, .fods, .fodt, .htm, .html, .mht, .odp, .ods, .odt, .oform, .otp, .ots, .ott, .oxps, .pdf, .pot, .potm, .potx, .pps, .ppsm, .ppsx, .ppt, .pptm, .pptx, .rtf, .txt, .xls, .xlsb, .xlsm, .xlsx, .xlt, .xltm, .xltx, .xml, .xps.

This parameter is required.

Type: string

Example: "docx"

key

Defines the unique document identifier used by the service to recognize the document. In case the known key is sent, the document will be taken from the cache. Every time the document is edited and saved, the key must be generated anew. The document url can be used as the key but without the special characters and the length is limited to 128 symbols.

Please note that the key must be unique for all independent services connected to the same document server. Otherwise, the service may open someone else's file from the editor cache. If multiple third-party integrators are connected to the same document server, they must also provide a unique key.

The key characters can be used: 0-9, a-z, A-Z, -._=. The maximal key length is 128 characters.

This parameter is required.

Type: string

Example: "Khirz6zTPdfd7"

referenceData

Defines an object that is generated by the integrator to uniquely identify a file in its system.

Type: object

Example:

{
  "fileKey": "BCFA2CED",
  "instanceId": "https://example.com",
  "key": "Khirz6zTPdfd7"
}

referenceData.fileKey

The unique document identifier used by the service to get a link to the file. It must not be changed when the document is edited and saved (i.e. it is not equal to the document.key parameter).

Type: string

Example: "BCFA2CED"

referenceData.instanceId

The unique system identifier. If the data was copied from a file on one system, and inserted into a file on another, then pasting by link will not be available and there will be no corresponding button in the context menu.

Type: string

Example: https://example.com

referenceData.key

Defines the unique document identifier used by the service to take the data from the co-editing session. In case the known key is sent, the document will be taken from the cache. Every time the document is edited and saved, the key must be generated anew. The document url can be used as the key but without the special characters and the length is limited to 128 symbols.

Type: string

Example: "Khirz6zTPdfd7"

title

Defines the desired file name for the viewed or edited document which will also be used as file name when the document is downloaded. The length is limited to 128 symbols.

This parameter is required.

Type: string

Example: "Example Document Title.docx"

url

Defines the absolute URL where the source viewed or edited document is stored. Be sure to add a token when using local links. Otherwise, an error will occur.

This parameter is required.

Type: string

Example: https://example.com/url-to-example-document.docx

Example

const docEditor = new DocsAPI.DocEditor("placeholder", {
  document: {
    fileType: "xlsx",
    key: "Khirz6zTPdfd7",
    referenceData: {
      fileKey: "BCFA2CED",
      instanceId: "https://example.com",
      key: "Khirz6zTPdfd7",
    },
    title: "Example Title",
    url: "https://example.com/url-to-example-document.xlsx",
  },
})

The example.com is the name of the server where document manager and document storage service are installed. See the How it works section to find out more on ONLYOFFICE Docs service client-server interactions.

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).