SwapFileName

<< Click to Display Table of Contents >>

Navigation:  Management >

SwapFileName

Previous pageReturn to chapter overviewNext page

If this property is set, VPE will work with a Swap File when OpenDoc() is called.

Instead of storing all document pages in memory, 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 file swapping 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

For details about creating and using VPE document files, please see the "Programmer's Manual", chapter "Programming Techniques", subchapter "VPE Document Files".

property string VPE.SwapFileName

read / write; design & runtime, closed document required

Possible Values:

swap file name (= document file name)

Default:

empty = not set

Remarks:

it is very important, that all VPE document files have the suffix ".vpe". Always use this suffix, because "VPE View" (the document browser) is associated with this suffix.
 

You can check for error conditions - for example, if there is not enough free space left on disk for the SwapFile - by testing the property LastError after calling OpenDoc and each time after calling PageBreak.

 

When creating a new document with a swap file, compression is always activated.

Example:

Doc.SwapFileName = "c:\reports\report.vpe"
Doc.OpenDoc

Instructs VPE to use the file "c:\reports\report.vpe" as Swap File.

 

Doc.SwapFileName = ""

Instructs VPE to use no Swap File (the default).

 

Example:

long count

Doc.SwapFileName = "c:\docs\report1.vpe"

Doc.OpenDoc

count = Doc.PageCount

Doc.PageBreak

Doc.Print(1, 1, "Added a new page.")

Doc.Preview

 

If the VPE document file "c:\docs\report1.vpe" is already existing, the file will be opened and the first page is read into memory. If the document file is not existing, VPE will create it with an initial blank page. The variable "count" is assigned the number of pages the document contains. VPE will add a new page at the end of the document and insert the text "Added a new page." there. Then the preview is shown.

 

 

The property DocFileReadOnly:

long count;

Doc.SwapFileName = "c:\docs\report1.vpe"

Doc.DocFileReadOnly = True

Doc.OpenDoc

if Doc.LastError <> 0 then

 exit function

end if

count = Doc.PageCount

Doc.VisualPage = count

Doc.Preview

 

If the VPE document file "c:\docs\report1.vpe" is not existing, the property LastError will return VERR_FILE_OPEN. Otherwise the file will be opened in read-only mode and the first page is read into memory. If the document file is not existing, VPE will create it with an initial blank page. The variable "count" is assigned the number of pages the document contains. The preview will show the last page contained in the document.

 

When using the SwapFileName property, DevJobName is set automatically to the file name.

 

See Also:

WriteDoc and ReadDoc