Tips

<< Click to Display Table of Contents >>

Navigation:  Important Notes, Tips & Troubleshooting >

Tips

Previous pageReturn to chapter overviewNext page

Frames drawn around objects (Barcodes, Pictures, etc.) can be eliminated by setting the PenSize to zero

For users of programming languages, which don’t provide some data types:

VpeHandle is a 32-bit integer on 32-bit platforms and a 64-bit integer on 64-bit platforms

VpeCoord is of type double

TRUE is the value 1 and FALSE is the value 0.

COLORREF is a 32-bit integer.

1 inch is 2.54cm, so 5 inch = 5 * 2.54 cm = 12.7cm

If you are using different font-sizes in a row, and you want to draw a box or grid around them, do as followed: use VpeWrite() with y2=VFREE, or VpePrint(). After each Write / Print determine the highest computed y2 coordinate for the whole row. So you can draw boxes (or a grid) later around the row and between columns, and you can position the next row closely beyond.

If you want to create tables or lists with groupings and controlled page breaks, you need to control page breaks by code:
To break detail lines to new pages, first compute the space you will need at least
for one new detail line including the Group or Sub-footer (if any).
Before inserting a detail line, check the available space on the current page with:

available_space = VPE.nBottomMargin - VPE.nBottom

if available_space < space_needed then

PrintMyGroupFooter()

 VPE.PageBreak()

 PrintMyGroupHeader()

end if

<output the next detail line here>

The "Speed + Tables" demo source code demonstrates the above code in detail.

Computing page breaks for images
Call RenderPicture() with the same parameters as if you were calling Picture().
Determine the size if the image with nRenderWidth and nRenderHeight. Add both values to the position (x, y) where you want to place the picture. If the resulting bottom coordinate exceeds the bottom margin (see nBottomMargin, SetOutRect and SetDefOutRect) you need to create a page break and insert the picture on the new page.

Generating a Table of Contents (TOC)
VPE does not allow to insert pages into a document, it is only possible to append pages to the end. The solution is, to create the main document and the TOC using two different VPE documents at the same time: in the first document (docMain) you create the main document and in the second document (docTOC) the TOC at the same time.
After the creation of the main document is finished, you write it to file using docMain.WriteDoc("tmpfile.vpe"). Afterwards close the main document.
Then call docTOC.ReadDoc("tmpfile.vpe") to append the main document to the TOC document.
The above explanation assumes that the page numbering for the main document starts with "page 1". It is also possible to start the first page of the TOC with "page 1", however, this makes things a bit more complicated:
Do not build docTOC while generating docMain. Instead while creating docMain build internally a list which holds the titles and their corresponding page numbers. Do not number the pages of docMain. Having docMain created, save it to file, close it and create docTOC in two passes:
In the first pass you build docTOC with the titles and page numbers from your list. Having done so, you will know how many pages docTOC needs. Afterwards destroy docTOC by closing the document.
In the second pass open docTOC newly. You know now how many pages your TOC has (and therefore how many pages the complete document has). Update the list of titles with page numbers by adding the number of pages required by the TOC to each page number. Then create the TOC and append the main document with docTOC.ReadDoc("tmpfile.vpe"). Afterwards you can start numbering the pages of the main document and that's it.
Not really difficult at all.

 

 

Did you experience a new technique on how to program VPE?
Did you write re-usable code or a class which does something very useful?
Or do you create brilliant or complex (or just weird) documents by using VPE?
Send us your tips, sources and VPE document files.
Show us what one can do with VPE!
We will be happy to make your impressing work available on our website or
to incorporate it into VPE.