Skip to main content

npm SDK File Loading

Once you have a resource ID, openFile is the one method to remember. Tell it which viewer you are using and it will return the matching data:
Here are the two possible responses:
The two responses are deliberately different. The Apryse response has the file bytes; the OnlyOffice response has the editor inputs. Check result.viewer before reading the viewer-specific fields.

Open the returned file

openFile retrieves and authorizes the resource, but it does not create a viewer component. After an Apryse call, hand the returned Blob to Apryse or create a temporary browser URL:
For a quick browser preview, use an object URL:
To use OnlyOffice, load its editor API script and add an editor container:
Then pass the returned editor inputs to the OnlyOffice editor—not the Blob fields:
The viewer libraries are still part of your application. The SDK supplies the authorized file or editor configuration; Apryse and OnlyOffice render it.

Documents

For a regular document preview or download, use the document ID as the resource ID:

Templates

Templates work the same way, but you first ask Artos for the template resource ID:

Source files

Source files need one extra lookup. Resolve the source reference to a resource ID, then pass that ID to openFile:
For sourcefile-... resources, openFile uses authenticated POST /source-file. Documents, templates, and generated outputs use the document-session flow. In both cases, you pass the resource ID; you do not construct an S3 URL or append a session token.

OnlyOffice

To open a resource in OnlyOffice, use the same method with viewer: 'onlyoffice':
edit requests an editable editor. readonly disables editing and saving. Source files, templates, generated outputs, and duplicate outputs may be forced read-only by the backend regardless of the requested mode. For editable documents, OnlyOffice sends saves through the callback in the generated config. Keep config and token from the same response, leave the config unchanged, and request a new result when reopening an expired editor session.