# Open and View a Document

Because a document must be opened before it can be viewed, printed, saved, or can have any other operation performed on it, viewing a document in the Viewing API means to open and view a document. It is possible, however, to open a document without viewing it, or in other words, to open a document with view mode disabled. In this mode, you can print or save the document without viewing it.

To open a document

1. Create a TPVAPIOpenDocumentInfo structure.

   To open a document without viewing it (view mode disabled), set the `VAPIDF_FLAGS_OPEN_WITHOUT_VIEW` flag in the `nFlags` member of the `TPVAPIOpenDocumentInfo` structure.

2. Send VAPI a `VAPIM_INIT` message with the `wParam` set to `VAPIMWP_INIT_OPEN_DOCUMENT`, and the `lParam` set to the address of the `TPVAPIOpenDocumentInfo` structure. See VAPIMWP_INIT_OPEN_DOCUMENT.

   For example:

       memset (&OpenDocInfo, 0, sizeof(TPVAPIOpenDocumentInfo));
       OpenDocInfo.lpszFilePath = szFileName;
       lResult = SendMessage (hWndVAPI, VAPIM_INIT, VAPIMWP_INIT_OPEN_DOCUMENT, (LPARAM)OpenDocInfo);

## Notification Messages

- To receive the status of the open document expressed as the percent done, wait for the VAPINMWP_INIT_OPENDOCDONE notification message.

- To receive the current page number of the document, wait for the VAPINMWP_INIT_PAGENUMBER notification message.

- To receive the name of the current object of the document, wait for the VAPINMWP_MULTIOBJ_OBJNAME notification message.

© Copyright 2016-2020 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a mail client, and then send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm