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.
Relativity performs the conversion and then stores the content in the converted cache table for a specific workspace. After a document is converted to a specified type, you can then display it in the viewer available through the Relativity UI. For more information, see
The Document Viewer Services API also provides functionality for persistent highlight sets and allows you to view information about the persistent highlight sets and terms in a specific document and workspace. Persistent highlight sets allow you to configure and apply term highlighting to assist with document review in the Viewer. To learn more, visit
The Document Viewer Services API also provides functionality for persistent highlight sets and allows you to view information about the persistent highlight sets and terms in a specific document and workspace. The API also allows you to select the default highlight sets or terms as well as make any terms or sets inactive. Persistent highlight sets allow you to configure and apply term highlighting to assist with document review in the Viewer. To learn more, visit
The following sample use cases illustrate how you can use these cache entries to create custom viewers or workflows for displaying documents:
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.Services namespace contains the interface, classes, and enumerations required to make conversion requests. The IDocumentViewerServiceManager interface includes the GetViewerContentKeyAsync() method, which sends a request to convert documents. It supports requests for native, image, production, and transcript conversion types. This method takes a GetViewerContentKeyRequest object that includes information about how to convert a document, such as its conversion type, priority, and other options. For on-the-fly requests, it returns a request key for documents that are currently undergoing conversion, and a cache entry ID for converted documents.
The Relativity.DocumentViewer.Services namespace contains the interface, classes, and enumerations required to make conversion requests and to retrieve persistent highlight sets. It includes the following methods that you can use to access the services for the document viewer:
Use the following guidelines when calling the GetViewerContentKeyAsync() method:
The Relativity.DocumentViewer.Services namespace also contains the following classes and enumerations:
For reference information about these classes and enumerations, see Document Viewer Services API
Complete the following prerequisites to begin development with the Document Viewer Services API:
Download the SDKs required for converting documents from the Relativity Community. For more information, see Download the SDKs.
After you download the following SDKs, install or extract their contents to folders on your local machine:
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:
To convert documents to their native format on the fly, the ConversionType property on the GetViewerContentKeyRequest instance is set to Native, and the Priority property is set to OnTheFly. The request is then passed to the GetViewerContentKeyAsync() method.
public async Task<ViewerContentKey> GetViewerContentKeyAsync(int workspaceId, int[] documentIds) { ViewerContentKey viewerContentKey = null; using (IDocumentViewerServiceManager proxy = helper.GetServicesManager().CreateProxy<IDocumentViewerServiceManager>(ExecutionIdentity.User)) { GetViewerContentKeyOptions options = new GetViewerContentKeyOptions(); options.ForceConversion = false; GetViewerContentKeyRequest request = new GetViewerContentKeyRequest(); request.WorkspaceId = workspaceId; request.DocumentIds = documentIds; request.ConversionType = ConversionType.Native; request.Priority = PriorityLevel.OnTheFly; request.Options = options; try { viewerContentKey = await proxy.GetViewerContentKeyAsync(request); } catch (ServiceException exception) { ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<IDocumentViewerServiceManager>(); _logger.LogError(exception, "Document Viewer Service GetViewerContentKeyAsync call failed for Workspace ID {0}", workspaceId); } } return viewerContentKey; }
To convert documents in a production set, the ProductionId property on the GetViewerContentKeyOptions instance is set to the Artifact ID of a production set, and the ConversionType property on the GetViewerContentKeyRequest instance is set to Production. The request is then passed to the GetViewerContentKeyAsync() method.
public async Task GetViewerContentKeyAsync(int workspaceId, int[] documentIds, int productionId) { using (IDocumentViewerServiceManager proxy = helper.GetServicesManager().CreateProxy<IDocumentViewerServiceManager>(ExecutionIdentity.User)) { GetViewerContentKeyOptions options = new GetViewerContentKeyOptions(); options.ForceConversion = false; options.ProductionId = productionId; GetViewerContentKeyRequest request = new GetViewerContentKeyRequest(); request.WorkspaceId = workspaceId; request.DocumentIds = documentIds; request.ConversionType = ConversionType.Production; request.Priority = PriorityLevel.ConvertAhead; request.Options = options; try { await proxy.GetViewerContentKeyAsync(request); } catch (ServiceException exception) { ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<IDocumentViewerServiceManager>(); _logger.LogError(exception, "Document Viewer Service GetViewerContentKeyAsync call failed for Workspace ID {0}", workspaceId); } } }
To pre-convert images, the DocumentSetId property on the GetViewerContentKeyOptions instance is set to the name of an SQL table, and the ConversionType property on the GetViewerContentKeyRequest instance is set to Image. Additionally, the Priority property is set to MassConvert. The request is then passed to the GetViewerContentKeyAsync() method.
public async Task GetViewerContentKeyAsync(int workspaceId, string massOpTableDocumentSetId) { using (IDocumentViewerServiceManager proxy = helper.GetServicesManager().CreateProxy<IDocumentViewerServiceManager>(ExecutionIdentity.User)) { GetViewerContentKeyOptions options = new GetViewerContentKeyOptions(); options.ForceConversion = true; options.DocumentSetId = massOpTableDocumentSetId; GetViewerContentKeyRequest request = new GetViewerContentKeyRequest(); request.WorkspaceId = workspaceId; request.ConversionType = ConversionType.Image; request.Priority = PriorityLevel.MassConvert; request.Options = options; try { await proxy.GetViewerContentKeyAsync(request); } catch (ServiceException exception) { ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<IDocumentViewerServiceManager>(); _logger.LogError(exception, "Document Viewer Service GetViewerContentKeyAsync call failed for Workspace ID {0}", workspaceId); } } }
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.
Similar to document conversion, pass a GetViewerContentKeyRequest instance to the GetViewerContentKeyAsync() method. Follow these guidelines for setting properties on the GetViewerContentKeyRequest instance for converting File fields:
Note: On the GetViewerContentKeyRequest instance, the DocumentIds property contains only the FieldArtifactID when it is 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.
The following code sample illustrates how to convert a file contained in a File field. For information about general tasks performed in this code, see Convert documents.
public async Task<ViewerContentKey> GetViewerContentKeyAsync(int workspaceId, int[] documentIds, int? fileId = null) { ViewerContentKey viewerContentKey = null; using (IDocumentViewerServiceManager proxy = helper.GetServicesManager().CreateProxy<IDocumentViewerServiceManager>(ExecutionIdentity.User)) { GetViewerContentKeyOptions options = new GetViewerContentKeyOptions(); options.ForceConversion = false; options.FileId = fileId; GetViewerContentKeyRequest request = new GetViewerContentKeyRequest(); request.WorkspaceId = workspaceId; request.DocumentIds = documentIds.FirstOrDefault(); request.ConversionType = ConversionType.Native; request.Priority = PriorityLevel.OnTheFly; request.Options = options; try { viewerContentKey = await proxy.GetViewerContentKeyAsync(request); } catch (ServiceException exception) { ISampleLogger _logger = Client.SamplesLibrary.Logging.Log.Logger.ForContext<IDocumentViewerServiceManager>(); _logger.LogError(exception, "Document Viewer Service GetViewerContentKeyAsync call failed for Workspace ID {0}", workspaceId); } } return viewerContentKey; }
This method retrieves each the persistent highlight sets and terms in a specific document and workspace.
public void GetPersistentHighlightSets() { var persistentHighlightSetRepository = _servicesManager.CreateProxy<IPersistentHighlightServiceManager>(); IEnumerable<PersistentHighlightSet> sets = persistentHighlightSetRepository.GetPersistentHighlightSets(workspaceId, documentId); }
This method allows you to change the default persistent highlight set or terms. Additionally, you can make terms or sets inactive as desired.
public void SavePersistentHighlightState() { int workspaceId = 1; int persistentHighlightSetId = 2; IEnumerable<int> termIds = new List<int>(); PersistentHighlightStateAction action = PersistentHighlightStateAction.Collapsed; var persistentHighlightSetRepository = _servicesManager.CreateProxy<IPersistentHighlightServiceManager>(); persistentHighlightSetRepository.SavePersistentHighlightSetState(workspaceId, persistentHighlightSetId, termIds, action); }
Community Updates |
|||
Aero Developer FAQ | Evolving the Platform | Most recent release notes | |
Learn more | Learn more | Learn more |
Additional Resources |
|||
![]() |
![]() |
||
Access Third-Party Tools with GitHub | Create .NET Apps Faster with NuGet | ||
Visit github | visit nuget |