> ## 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.

# AddImageFileWithPassword Method of the FRDocument Object

This method opens a password-protected image file and adds the pages corresponding to the opened file to a document.

This method may report events to the listeners attached to the IConnectionPointContainer interface of the [FRDocument](/fine-reader/engine/api-reference/document-related-objects/frdocument) object.

## Syntax

### C++

```cpp theme={null}
HRESULT AddImageFileWithPassword(
  BSTR               ImageFileName, 
  BSTR               Password,  
  IPrepareImageMode* PrepareMode,
  IIntsCollection*   PageIndices 
);
```

### C\#

```csharp theme={null}
void AddImageFileWithPassword(
  string           ImageFileName, 
  string           Password,  
  IPrepareImageMode PrepareMode,
  IIntsCollection   PageIndices 
);
```

### Visual Basic .NET

```vb theme={null}
Sub AddImageFileWithPassword( _
  ImageFileName As String, _
  Password As String, _
  [PrepareMode As IPrepareImageMode = Nothing], _
  [PageIndices As IIntsCollection = Nothing] _
)
```

## Parameters

ImageFileName

\[in] This variable contains the full path to the image file to be opened.

Password

\[in] This variable contains a password for accessing images in PDF format.

PrepareMode

\[in] This parameter refers to the [PrepareImageMode](/fine-reader/engine/api-reference/image-related-objects/prepareimagemode) object which specifies how an image will be preprocessed during opening.

PageIndices

\[in] This parameter refers to the [IntsCollection](/fine-reader/engine/api-reference/supplementary-objects-and-methods/intscollection) object which specifies the indices of the pages which have to be added to a document. Note that repeated indices are not allowed. To add the same page several times, please call this method several times.<br />This parameter is optional and may be 0, in which case all the pages of the opened file will be added to the document.

## Return values

This method has no specific return values. It returns the [standard return values of ABBYY FineReader Engine functions](/fine-reader/engine/api-reference/return-codes).

## Remarks

* When opening a PDF Portfolio file using this method, its cover is always included in the output file.
* For Linux and Windows:
  * If your license includes the [Office Formats Opening](/fine-reader/engine/licensing/modules#officeformatsopening) module, you may also use this method to open digital documents of [supported formats](/fine-reader/engine/specifications/supported-digital-document-input-formats).
  * Depending on the value of the [IEngine::MultiProcessingParams](/fine-reader/engine/api-reference/engine-object-iengine-interface/properties#multiprocessingparams) property, ABBYY FineReader Engine can distribute opening of multi-page documents to CPU cores.

## See also

[FRDocument](/fine-reader/engine/api-reference/document-related-objects/frdocument)

[AddImageFileWithPasswordCallback](/fine-reader/engine/api-reference/document-related-objects/frdocument/addimagefilewithpasswordcallback-method)

[AddImageFile](/fine-reader/engine/api-reference/document-related-objects/frdocument/addimagefile-method)

[Working with Images](/fine-reader/engine/guided-tour/advanced-techniques/working-with-images)
