ImageGear Professional for Windows ActiveX
Updating a Document (Multi-Page File)

Since a multi-page file is a complex thing, there are situations where your application will have to make complex modifications to the file (re-arranging the pages, inserting new pages, removing pages, etc.). If the document contains hundreds or thousands of pages, then SaveDocument Method can be a very expensive and time-consuming operation. For those cases, there is another mechanism for dealing with a multi-page file: OpenDocument Method.

When using OpenDocument Method, your application operates in 3 phases:

  1. An IGDocument Object is created and associated with a multi-page file, and the contents of the file are loaded into the IGDocument Object.
  2. The IGDocument Object is modified (IGPages added, removed, re-ordered, and contained images altered), and the file is updated to synchronize with the IGDocument Object.
  3. The IGDocument Object is unassociated with the file.
 

You cannot mix OpenDocument Method usage with LoadDocument Method or SaveDocument Method.

This example uses a hard-coded filename. A real application would provide some mechanism for choosing the file to load (for example, a File-Chooser dialog - see Dialogs, below).



This example uses all default values for the IGLoadOptions Object.
 
Copy Code
Dim document As IGDocument
Dim file As IGIOFile
Dim options as IGLoadOptions
IGCoreCtl1.License.SetSolutionName "Accusoft"
IGCoreCtl1.Result.NotificationMode = IG_ERR_NO_ACTION
IGCoreCtl1.AssociateComponent IGFormatsCtl1.ComponentInterface
Set file = IGFormatsCtl1.CreateObject(IG_FORMATS_OBJ_IOFILE)
Set options =
IGFormatsCtl1.CreateObject(IG_FORMATS_OBJ_LOADOPTIONS)
file.FileName = "myfile.tif"
` Phase 1: create the IGDocument, associate it with a file, and
load it
Set document = IGCoreCtl1.CreateDocument(0)
IGFormatsCtl1.OpenDocument document, file, 0
IGFormatsCtl1.ReadPagesToDocument document, 0, -1
` Phase 2: update the document and synchronize the file
.
. (document modification logic not shown)
.
IGFormatsCtl1.UpdateDocument document
` Phase 3: unassociated the file - we're done
IGFormatsCtl1.CloseDocument document, False

 

 


©2016. Accusoft Corporation. All Rights Reserved.

Send Feedback