# Single-File Processing Methods - CaptureVisionRouter Class

| Method                | Description                                               |
| --------------------- | --------------------------------------------------------- |
| [`capture`](#capture) | Process an image or file to derive important information. |
| [`captureMultiPages`](#capturemultipages) | Processes an image or file containing multiple pages to derive important information. |

## capture

Process an image or file to derive important information. It can optionally use a specified template for the capture.

```java
public CapturedResult capture(String filePath)
public CapturedResult capture(String filePath, String templateName)
public CapturedResult capture(byte[] fileBytes)
public CapturedResult capture(byte[] fileBytes, String templateName)
public CapturedResult capture(ImageData pImageData)
public CapturedResult capture(ImageData pImageData, String templateName)
```

**Parameters**

`filePath` <*String*>: Specifies the path of the file to process.

`fileBytes` <*byte[]*>: Specifies the image file bytes in memory to process.

`pImageData` <*ImageData*>: Specifies the image data to process.

`templateName` <*String*, optional>: Specifies a `CaptureVisionTemplate` to use for capturing.

**Remarks**

- There are two types of `CaptureVisionTemplate`: the [preset ones](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/enum-preset-template.md) which come with the SDK and the custom ones that get initialized when the user calls [initSettings](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/settings.md#initsettings) / [initSettingsFromFile](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/settings.md#initsettingsfromfile).
- When using a custom template, the parameter `templateName` should be the name of the [`CaptureVisionTemplate` object](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/capture-vision-template/index.md) in the JSON template file.
- Please be aware that the preset `CaptureVisionTemplates` will be overwritten should the user call `initSettings` / `initSettingsFromFile` and pass his own settings.
- If parameter `templateName` is not specified, the preset one named 'Default' will be used. However, if the preset ones have been overwritten as described above, the first `CaptureVisionTemplate` from the user's own settings will be used instead.

**Return Value**

Returns a `CapturedResult` object containing the captured items.

**See Also**

[ImageData](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/core/basic-classes/image-data.md)

[CapturedResult](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/auxiliary-classes/captured-result.md)

## captureMultiPages

Processes an image or file containing multiple pages to derive important information. It can optionally use a specified template for the capture.

```java
public CapturedResult[] captureMultiPages(String filePath)
public CapturedResult[] captureMultiPages(String filePath, String templateName)
public CapturedResult[] captureMultiPages(byte[] fileBytes)
public CapturedResult[] captureMultiPages(byte[] fileBytes, String templateName)
public CapturedResult[] captureMultiPages(FileFetcher fileFetcher)
public CapturedResult[] captureMultiPages(FileFetcher fileFetcher, String templateName)
```

**Parameters**

`filePath` <*String*>: Specifies the path of the file containing multiple pages to process.

`fileBytes` <*byte[]*>: Specifies the image file bytes in memory containing multiple pages to process.

`fileFetcher` <*FileFetcher*>: Specifies a `FileFetcher` instance that provides the files to process.

`templateName` <*String*, optional>: Specifies a `CaptureVisionTemplate` to use for capturing.

**Remarks**

- There are two types of `CaptureVisionTemplate`: the [preset ones](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/enum-preset-template.md) which come with the SDK and the custom ones that get initialized when the user calls [initSettings](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/settings.md#initsettings) / [initSettingsFromFile](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/capture-vision-router/settings.md#initsettingsfromfile).
- When using a custom template, the parameter `templateName` should be the name of the [`CaptureVisionTemplate` object](https://www.dynamsoft.com/capture-vision/docs/core/parameters/reference/capture-vision-template/index.md) in the JSON template file.
- Please be aware that the preset `CaptureVisionTemplates` will be overwritten should the user call `initSettings` / `initSettingsFromFile` and pass his own settings.
- If parameter `templateName` is not specified, the preset one named 'Default' will be used. However, if the preset ones have been overwritten as described above, the first `CaptureVisionTemplate` from the user's own settings will be used instead.

**Return Value**

Returns an array of `CapturedResult` objects containing a collection of captured results, where each entry corresponds to a processed page.
