Document Viewer Services (.NET)

The Document Viewer Services API provides functionality for requesting the conversion of documents to viewer types supported by Relativity, such as native, image, production, and transcript types. You can also convert files contained in File fields on a Relativity Dynamic Objects (RDOs). These files are converted to their native format on the fly, and then displayed in the standalone viewer.

The following sample use cases illustrate how you can use these cache entries to create custom viewers or workflows for displaying documents:

  • Convert documents and save their locations in the cache. Next, create a custom application that retrieves native documents and displays them in a user-friendly format through a browser.
  • Create a custom page or workflow that requests a document on-the-fly for immediate display in the viewer. Send a notification when the document is converted and available for viewing.

In addition, you can use the Document Viewer API through the REST API. For more information, see Document Viewer Services (REST).

This page contains the following information:

The Relativity.DocumentViewer.SDK contains this API. For compatibility and package installation instructions, see Download the SDKs and NuGet packages.

Fundamentals for the Document Viewer Services API

Review the following information to learn about the methods, classes, and enumerations used by the Document Viewer Services API.

Best practices for the conversion requests

Use the following guidelines when calling the GetViewerContentKeyAsync() method:

  • Import the Relativity.DocumentViewer.Services.V2 namespace by adding a using directive at the top of your class.
  • Verify that you are passing valid parameters to it. If you pass an invalid workspace ID or other parameter, the service throws a ValidationException.
  • For production conversions, set the ProductionId property on the Options property of the request object. See GetViewerContentKeyOptions class in Classes and enumerations.
  • For mass conversions, you can create a mass operations resource table to store multiple document IDs. Include the name of the resource table on DocumentSetID property on the Options property of the request object. See GetViewerContentKeyOptions class in Classes and enumerations.

Convert documents

Use the GetViewerContentKeyAsync() method to convert documents to native, image, production, or transcript type. You can obtain the request key for documents currently undergoing conversion from the ViewerContentKey object returned by this method. It also returns the cache entry ID for converted documents. For jobs with lower priorities, Relativity uses batching to pre-convert documents in a specific workspace.

The following code samples illustrates how to perform these general tasks:

  • Use helper classes to create the proxy and select an appropriate authentication type. See Relativity API Helpers.
  • Create the Services API proxy within a using block in your code.
  • Create a GetViewerContentKeyRequest object.
  • Call the GetViewerContentKeyAsync() method within a try-catch block.
  • Use await/async design pattern. See Basic Services API concepts.
  • Use the logging framework for troubleshooting and debugging purposes. See Log from a Relativity application .

Convert files contained in File fields on RDOs

You can convert files contained in File fields on a Relativity Dynamic Objects (RDOs) for display in the standalone viewer. These files are converted to their native format on the fly.

Like document conversion, pass a GetViewerContentKeyRequest instance to the GetViewerContentKeyAsync() method. Follow these guidelines for setting properties on the GetViewerContentKeyRequest instance for converting File fields:

  • Set the ConversionType property to Native.
  • Set the Priority property set to OnTheFly.
  • Optionally, set the FileId property on the GetViewerContentKeyOptions instance to the identifier for the RDO with the associated File field.

Note: On the GetViewerContentKeyRequest instance, the DocumentIds property contains only the FieldArtifactID when it's used for converting a file contained in a File field.

You can obtain the request key for File fields currently undergoing conversion from the ViewerContentKey object returned by this method. It also returns the cache entry ID for converted files. For jobs with lower priorities, Relativity uses batching to pre-convert file fields in a specific workspace.