> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DocumentExportResult

> DocumentExportResult and ResultFiles provide access to exported document files (JSON, PDF, images) from a Custom or Output activity script.

`DocumentExportResult` is a JavaScript object that provides access to document export results.

Before a Custom activity runs, or before an Output (External system) script runs, Vantage exports each document to the formats configured on the activity (for example, JSON or PDF). Access these exported files via [`Document.Exports`](/vantage/documentation/skill-designer/process/custom-activity/document) to send them to third-party systems.

## Properties

| Name                          | Type                                                                                        | Access    | Description                             |
| :---------------------------- | :------------------------------------------------------------------------------------------ | :-------- | :-------------------------------------- |
| **FileName**                  | string                                                                                      | Read-only | The name of the file.                   |
| **ExportFormat**              | [ExportFormat](/vantage/documentation/skill-designer/process/custom-activity/export-format) | Read-only | The export format.                      |
| **`Properties["PageIndex"]`** | string                                                                                      | Read-only | Page sequence number (JPG export only). |

## Methods

### ToJson

```javascript theme={null}
string ToJson();
```

Returns the export results as a JSON-formatted string. Only works for JSON formats (JSON, FieldsJson, OcrJson).

## ResultFiles

A read-only collection of `DocumentExportResult` objects. Filter results by export format.

### Methods

#### GetByFormat

```javascript theme={null}
DocumentExportResult GetByFormat(ExportFormat format);
```

Returns the `DocumentExportResult` for the specified export format.

## Examples

The following script gets the JSON and PDF export results for a document and sends them to an external system:

```javascript theme={null}
// Access the export results for the first document in the transaction.
// Vantage exports each document to the formats configured on the activity.
var exports = Context.Transaction.Documents[0].Exports;

// Get a specific export result by format.
var jsonResult = exports.GetByFormat(ExportFormat.Json);
var pdfResult = exports.GetByFormat(ExportFormat.Pdf);

// Read the extracted data from the JSON export result as a string.
var jsonString = jsonResult.ToJson();

// Send the extracted data and the PDF to an external system.
var request = Context.CreateMultipartFormDataRequest();
request.Url = "https://my_service.com/api/v1.0/documents";
request.Method = "POST";
request.AppendStringContent(jsonString, "jsonData");
request.AppendFileContent(pdfResult, "binaryData");
request.Send();
```

The following script lists each exported JPG page image with its file name and page number:

```javascript theme={null}
// PageIndex is available for JPG exports only.
var exports = Context.Transaction.Documents[0].Exports;
exports
  .filter(result => result.ExportFormat === ExportFormat.Jpeg)
  .forEach(result => {
    Context.LogMessage(result.FileName + " (page " + result.Properties["PageIndex"] + ")");
  });
```

## Related topics

* [Document](/vantage/documentation/skill-designer/process/custom-activity/document)
* [ExportFormat](/vantage/documentation/skill-designer/process/custom-activity/export-format)
* [Custom activity](/vantage/documentation/skill-designer/process/custom-activity/custom-activity)
* [Sample scripts](/vantage/documentation/skill-designer/process/custom-activity/sample-scripts)
* [Export results to an external system](/vantage/documentation/skill-designer/process/output-activity/export-external-system)
* [Object model](/vantage/documentation/skill-designer/process/custom-activity/object-model)
