# FileFetcher

The `FileFetcher` class is a utility class that partitions a multi-page image file into multiple independent `ImageData` objects. It inherits from the `ImageSourceAdapter` class.

## Definition

*Package:* com.dynamsoft.utility

*Inheritance:* [ImageSourceAdapter](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/core/basic-classes/image-source-adapter.md) -> FileFetcher

```java
public class FileFetcher extends ImageSourceAdapter
```

## Methods

| Method | Description |
|--------|-------------|
| [`FileFetcher`](#filefetcher) | Initializes a new instance of the `FileFetcher` class. |
| [`setFile`](#setfile) | Sets the file using a file path, file bytes or an `ImageData` object. |
| [`setPDFReadingParameter`](#setpdfreadeingparameter) | Sets the parameters for reading PDF files. |
| [`setPages`](#setpages) | Sets the 0-based page indexes of a file (.tiff or .pdf) for barcode searching. |
| [`hasNextImageToFetch`](#hasnextimagetofetch) | Determines whether there are more images left to fetch. |

### FileFetcher

Initializes a new instance of the `FileFetcher` class.

```java
FileFetcher()
FileFetcher(PDFReadingParameter pdfReadingParameter)
```

**Parameters**

`pdfReadingParameter` A `PDFReadingParameter` object with PDF files reading parameters.

**See Also**

[PDFReadingParameter](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/core/basic-classes/pdf-reading-parameter.md)

### setFile

Sets the file using a file path, file bytes or an `ImageData` object.

```java
void setFile(String path) throws UtilityException
void setFile(byte[] bytes) throws UtilityException
void setFile(ImageData imageData) throws UtilityException
```

**Parameters**

`path` Specifies the path of the file to process.

`bytes` Specifies the image file bytes in memory to process.

`imageData` Specifies the image data to process.

**Exception**

[UtilityException](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/utility/utility-exception.md)

**See Also**

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

### setPDFReadingParameter

Sets the parameters for reading PDF files.

```java
void setPDFReadingParameter(PDFReadingParameter para) throws UtilityException
```

**Parameters**

`para` A `PDFReadingParameter` object with PDF files reading parameters.

**Exception**

[UtilityException](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/utility/utility-exception.md)

**See Also**

[PDFReadingParameter](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/core/basic-classes/pdf-reading-parameter.md)

### setPages

Sets the 0-based page indexes of a file (.tiff or .pdf). By default, there is no restriction on the number of pages that can be processed in a single file.

```java
void setPages(int[] pages) throws UtilityException
```

**Parameters**

`pages` An integer array containing the page information to be set.

**Exception**

[UtilityException](https://www.dynamsoft.com/capture-vision/docs/server/programming/java/api-reference/utility/utility-exception.md)

### hasNextImageToFetch

Determines whether there are more images left to fetch.

```java
boolean hasNextImageToFetch()
```

**Return Value**

Returns true if there are more images left to fetch, false otherwise.
