On-Disk Document Files

<< Click to Display Table of Contents >>

Navigation:  Programming Techniques > VPE Document Files >

On-Disk Document Files

Previous pageReturn to chapter overviewNext page

Another option to open / create a VPE document file is to use a special on-disk mode.

NOTE:On-Disk files are always written compressed.

For the VPE Control this is done by setting the property SwapFileName before calling OpenDoc(), for the VPE DLL this is done by calling the function VpeOpenDocFile() instead of VpeOpenDoc().

In the on-disk mode only the current page is held in memory, all other pages are swapped to a VPE document file. This implies minimum memory usage at very high performance and allows to create huge documents. VPE's on-disk mode is VERY fast.

Even for file-based documents you can add new pages to the end of a document at any point in time.

Editions below the Professional Edition: after a page has been swapped to file, you can not modify the page, i.e. add new objects to it.

The Professional Edition and higher allow to add new objects to pages which have already been written to file and to clear, insert and delete pages at any position in a document file.

A page is swapped to file after:

Adding a new blank page by calling PageBreak()

Moving to a different page by modifying the property CurrentPage
DLL: by calling VpeGotoPage()

On-disk document files can become fragmented, if you are adding a lot of new objects to a page which has already been written to disk. Especially if you are adding objects in multiple steps, i.e. you add some objects, seek to another page, seek back and add again objects and so on, or open and close the document file repeatedly while adding each time new objects. This will result in decreased performance when reading pages of document files.

Defragmenting document files:
Open the document file with SwapFileName (DLL: use VpeOpenDocFile())
Call WriteDoc(<new file name>)
The file <new file name> is defragmented, whilst requiring nearly no memory for the operation.

With SwapFileName / VpeOpenDocFile() you can also open an existing file, VPE first checks if the given file already exists. If so, the first page is loaded into memory. If you want to add pages to the end of an existing document file, open it and call PageBreak() first, so that a new empty page is added to the end of the document . If the document doesn't contain any pages, then the first page is an empty page.