File Content Extraction 26.1
Viewing SDK Programming Guide

# VAPIMWP_INIT_OPEN_DOCUMENT

Opens a document for one of the following operations:

- viewing

- determining a document format without viewing

- printing/converting/saving without viewing

This is a parameter of the `VAPIM_INIT` message. See Open and View a Document.

## Syntax

    #include <kvvapi.h>
    SendMessage(hWndVAPI, VAPIM_INIT, VAPIMWP_INIT_OPEN_DOCUMENT,
               (LPARAM) (TPVAPIOpenDocumentInfo*) pOpenDocumentInfo );

## Arguments

Argument | Description
--- | ---
`hWndVAPI` | The handle of the VAPI window.
`pOpenDocumentInfo` | A pointer to a TPVAPIOpenDocumentInfo structure that contains information about the document to be opened.

## Returns

- `SendMessage()` returns `VAPI_RETURN_SUCCESS` if the document opening is successfully initiated.
- If there is no viewer for the specified document, `SendMessage()` returns `VAPI_RETURN_NO_VIEWER`.
- If the format of the document could not be determined, `SendMessage()` returns `VAPI_RETURN_UNKNOWN_FORMAT`.
- If the document is password protected, `SendMessage()` returns `VAPI_RETURN_PASSWORD_PROTECTED`.
- If the drawing routines have not been initialized, `SendMessage()` returns `VAPI_RETURN_NOT_INITIALIZED`.
- If the requested page does not exist, or is being displayed before all previous pages have been displayed, `SendMessage()` returns `VAPI_RETURN_NO_PAGE`.
- If the document does not support this feature (for example, ZIP files, video, audio), `SendMessage()` returns `VAPI_RETURN_NOT_AVAILABLE`.
- If the license is invalid, `SendMessage()` returns `VAPI_RETURN_INVALID_LICENSE_KEY`.
- If the license is expired, `SendMessage()` returns `VAPI_RETURN_EXPIRED_LICENSE_KEY`.
- If the input file or stream is invalid or corrupt, `SendMessage()` returns `VAPI_RETURN_BAD_INPUT`.
- Any other error condition causes `VAPI_RETURN_ERROR` to be returned.

## Discussion

- This message initiates the document opening and returns before the document opening is complete unless you set the `bWait` parameter in the `TPVAPIOpenDocumentInfo` structure to `TRUE`.

- This message produces several notification messages:

  - One or more `VAPINMWP_INIT_OPENDOCDONE` notification messages are received to report the status of the document opening.

  - In addition, if the document to be opened contains pages, a `VAPINMWP_INIT_PAGENUMBER` notification message is received to report the current page number.

  - Finally, if the document to be opened contains objects (for example, a spreadsheet document containing pages), a `VAPINMWP_MULTIOBJ_OBJNAME` notification message is received to report the current object name (for example, the name of the current spreadsheet page).

- To open a document to view as text, set the `bViewAsText` parameter in the `TPVAPIOpenDocumentInfo` structure to `TRUE`.

- To open and process a document (print, convert, and so on) without viewing, set the `nFlags` parameter in the `TPVAPIOpenDocumentInfo` structure to `VAPIDF_FLAGS_OPEN_WITHOUT_VIEW`. This flag tells VAPI to create a hidden Viewer window. You must also set the `bWait` parameter in the `TPVAPIOpenDocumentInfo` structure to `TRUE`, except when you use APIs to draw documents without viewing. See Draw a Page for more information.

  For example, to print a document without viewing, open the document with the `bWait` parameter set to `TRUE` and the `nFlags` parameter set to `VAPIDF_FLAGS_OPEN_WITHOUT_VIEW`, and then send the `VAPIMWP_PRINT_PRINT` message.

- To open a document and return format information without viewing, set the `nFlags` parameter in the `TPVAPIOpenDocumentInfo` structure to `VAPIDF_FLAGS_OPEN_VAPI_ONLY`. This flag does not create a Viewer window.

- To make sure that a document is fully processed before an operation (such as printing, converting, or searching) is performed, set the `bWait` parameter in the `TPVAPIOpenDocumentInfo` structure to `TRUE`. This is useful when you want to use an operation immediately after opening the document.

Copyright 2016-2025 Open Text
Version 26.1 | Last updated January 2026

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to MFI-swpdl.idoldocsfeedback@opentext.com.

We appreciate your feedback!

Product: File Content Extraction 26.1

Topic Title: VAPIMWP_INIT_OPEN_DOCUMENT