This article was brought to you by the guys from VDF-GUIdance.
For more DataFlex targeted articles see http://www.vdf-guidance.com


Winprint to VPE classes

by Carl Henry Schaer

Summary

This package includes the code to convert your reports originally developed for use with the Winprint report engine to be used with VPE. The VPE printengine is very fast and has much more features as winprint. We will name just a few of them here. RTF support, clickable objects, use images of the popular image formats, export of pages to all common image file formats, print forms and labels.
Size: 81 KB Download
Date Created: 12/11/2000
Date Updated: 10/11/2002
Author: Carl Henry Schaer
Company: HCSS


Description


This package includes the code to convert your reports originally developed for use with the Winprint report engine to be used with VPE. The VPE printengine is very fast and has much more features as winprint. We will name just a few of them here. RTF support, clickable objects, use images of the popular image formats, export of pages to all common image file formats, print forms and labels.

Installation notes


The files Round.Pkg, Vpe3.Pkg, Vpe3Prnt.Pkg, and VWinPrnt.Pkg are used to convert Winprint reports to VPE 3.0. To implement them, put
Use Vpe3Prnt

after the Use DFAllent in your Src file, and
Use VWinRpt

after the Use DFAllRpt in your report view files.

The WinReport objects should also be changed to VPE_WinReport objects.
The files VpeRpts.Src and VRpt*.* show how to do this with the Winprint sample reports.

There are three versions of VPE 3.0. The file Vpe3.Pkg containing the VPE functions and constants begins with
Define VPEDLL For Vpes32.Dll

If you have the enhanced or professional version of VPE, replace "Vpes32.Dll" with the Dll for your version.

A demo version of VPE 3.0 can be downloaded from
"http://www.idealsoftware.com"

Not all of Winprint has been included yet. Particularly, graphics and the header types DFPageTotal and DFPageFooter have not been implemented.

One major bug that has not been resolved is that Procedure_Sections and HeaderTypes must correspond. For example, DFPageBottom does not work if it is put in Procedure_Section Subtotal1.

Many thanks are due to Peter Bosch, Matthew Davidian, and Peter Brooks who helped with debugging and suggestions.


Readme2.Txt for Vpe3prnt.Pkg Version 2.0

Many thanks are due to Peter Bosch, who implemented tables and lists and
#subpagecount# and #zerosubpagecount# and bug fixes, to Matt Davidian, who
implemented fixed bugs 1 - 3 and the enhancements SetPrinterSetupFile,
DFWriteRectRel, and the DFPrintSetup enhancement, and to Arnold Franken, who
fixed a bug in DFWriteBmp.

Support was added for:
  • #subpagecount#
  • #zerosubpagecount#
  • DFPrinterBinFirstPage
  • DFSetNumberofCopies
  • DFSetSpecPrintFlag
  • Paper Bin Flags
  • Paper Size Flags
  • DFSelectPrinter (Only the device name parameter is used.)
  • DFHeaderWrap, HDR_WRAP, HDR_NOWRAP
  • DFReportFooter
  • DFPageHeader2


Public Interface



Class VPE_WinReport

pShowStatusPanel True | False The default is False.

When this property is False, the preview goes immediately to VPE, allowing
the user to browse the report as it is being processed. The strings that
were sent to the status panel of Winprint now show at the bottom of the VPE
preview.


WinprintID object


pProcessString The default is "Processing"
This is the string that shows in the VPE Preview status when the preview
first starts.

pFinishString The default is "Finished"
This is the string that shows in the VPE Preview status when the report has
finished.

pSetupFile The default is "C:\Vpe.Prs"
This is the filename for the printer setup file that is used internally.
It should have a "Prs" extension.

pAdjustFontSize True | False The default is true.
If true, the font size for numbers is diminished if the number does not
fit in the allocated space. This only effects individual numbers.
If this is not needed, set this to False since this feature increases
the processing time up to 30%.

pAsciiChannel The default is 7.
A new value, PRINT_TO_ASCII_FILE, has been defined for Output_Device_Mode
of Vpe_WinReport. pAsciiChannel is the channel for this Ascii output.


New Command


DFVOffset Number VertOffset

VertOffset - The vertical offset in the current Winprint scale.

If fonts are changed on one line, Winprint justifies the baseline of the
characters. There does not seem to be an easy way to do this in VPE, since
VPE printing is based on a rectangle starting with the upper left hand corner.
As a partial solution to this problem, I've added DFVOffset to set a vertical
offset. This applies for the rest of the line, but is zeroed at the end of
the line. The vertical offset needed can be computed using the scale on the VPE
preview. Hint: Go to a high magnification to see if the text is justified
correctly. At a 1:1 different fonts may not look aligned in the preview even
though they will print correctly.


New value

PRINT_TO_ASCII_FILE

The property Output_Device_Mode of VPE_WinReport can have the value
PRINT_TO_ASCII_FILE. This sends the output to an Ascii file and shows the
output in Notepad or the application stored under "WordPath" in
APPLICATION_LINKS of the registry.


New Properties

pVLicense1, pVLicense2
The VPE license.

pCaption Defaults to "Print Preview".
The preview caption.

pVpeDocFlags Defaults to VPE_FIXED_MESSAGES.
Flags used for opening the VPE document.


New Features


FONT_WRAP and FONT_NOWRAP
Normally, the property pNoteLength, which defaults to 100, determines whether or not text is wrapped. This can be controlled for individual items by using FONT_WRAP and FONT_NOWRAP.

SetPrinterSetupFile
Supports multiple printer setup files (e.g. separate printers for checks, invoices, forms, etc.)

Sample usage:
Send SetPrinterSetupFile "C:\INVOICE.PRS"

DFPrintSetup
An optional parameter was added to do alternate printer setup files
(e.g. for picking the printer for an alternate print setup file)

Sample usage:
Object oInvPrinter is a Button
  Set Label to "Click to Select Invoice Printer"
  Set Size to 14 90

  Procedure OnClick
    Send DFPrintSetup to WinPrintID "C:\INVOICE.PRS"
  End_Procedure
End_Object

DFWriteRectRel
Writes a rectangle relative to the current line.

This command was developed for a report that required a checkbox in the right-most column of the report. Using DfWriteRect with DFGR_CURRLINE would have resulted in either a box that was not vertically centered within the current line and thus not aligned with the text on the line, or a box that was too big.

After testing the report, a "gray-bar" effect was also added (similar to the old 14" wide "green-bar" paper) to make the report easier to read. This consists of every other line being printed with a grey background.

The following is code from that report shows how to use DFWriteRectRel (coordinates are in inches):
get DFGetDFColor of WinPrintID 224 224 224 to iGrey
DFWriteRectRel 0.04 0 0.20 7.75 iGREY 0.01 ;
                                  DFGR_NOWRAP iGREY DFGR_NOPOS

(DFWritePos's for report)

DFWriteRectRel 0.01 7.5 0.125 0.125 RGB_BLACK 0.01 ;
                                 DFGR_NOWRAP RGB_WHITE DFGR_NOPOS
DFWriteLn ''

The first DFWriteRectRel occurs before anything is output on the current line.
The first parameter is the vertical offset from the current position. (This can be positive or negative. A positive offset indicates a position farther down the page and a negative offset indicates a position further up the page.)
An important point here is that when the first DFWriteRectRel is done, the vertical position is still set to a value based on the _prior_ line that was output. Once the DFWritePos's are executed after the DFWriteRectRel,
the current vertical position is moved down a bit because we are on a new line.

Thus, if you look at the offsets of the two commands, you might conclude that the second one prints higher up on the page because it has a smaller offset.
However, it actually prints further down on the page because the current vertical position changes (about .07" I believe) between the two commands.


New feature 

Tables and Lists
DFStartTable [Height|VFREE] [Fill Color] [Frame Color] [Frame Thickness]
  DFWrite ....
  DFWriteLn ...
DFStopTable [Right Border]

DFStartList [Height|VFREE] [Fill Color] [Frame Color] [Frame Thickness]
  DFWrite ....
  DFWriteLn ...
DFStopList [Right Border]

DFStartBox [Height|VFREE] [Fill Color] [Frame Color] [Frame Thickness]
  DFWrite ....
  DFWriteLn ...
DFStopBox [Right Border]

DFStartTable
DFStopTable draws a table with horizontal and vertical lines.

DFStartList
DFStopList draws frames with vertical lines (like tables but without horizontal divisions)

DFStartBox
DFStopBox is like DFStartTable, except that the cursor position is not changed after the box is drawn, so that one can first draw the box, and then freely position the text inside the box.

Height
Specifies the height of the cells. When it is not given or has the value VFREE, the height will be determined by the character size.

Fill Color
The background color of tables in WinPrint color constants (i.e. RGB_RED)

Frame Color
The color of table frames in WinPrint color constants.

Frame Thickness
The thickness of the frame lines (Default: 2)

Right Border
Normally the table extends to the right margin of the report, but it can be made shorter by specifying the right border in cm.

A table row should always end with a Writeln.

Examples:
DFStartTable // Table with single lines.
  DFWritePos "AAAA" 1
  DFWritePos "BBBB" 2
  DFWriteLnPos "CCCC" 3
DFStopTable

DFStartList VFREE RGB_GREY
  For I from 1 to 10 // Table with 10 lines.
    DFWritePos I 1
    DFWritePos "BBBB" 2
    DFWriteLnPos "CCCCC" 3
  Loop
DFStopList

Tables can be in body sections and in header sections without DFBeginHeader ... DFEndHeader. Tables are ignored in DFBeginHeader sections.

Irregular tables can also be drawn by putting DFStartTable ... DFStopTable around individual cells.
DFStartTable
  DFwritePos "AAAA" 1
DFStopTable

DFStartTable VFREE RGB_GREY
  DFWriteLnPos "BBBB" 2
DFStopTable 10.0

Here the first cell is drawn normally, while the second one is shaded gray and has a right border of 10 cm.

Note: If a FONT_LEFT or FONT_CENTER is followed by a FONT_RIGHT (explicit or implicit by printing a number): then the FONT_LEFT or FONT_CENTER must have a specified length.

Bug Fixes



  1. Margins set in Starting_Main_Report or Initialize_Report did not work.
  2. Corrected a bug with printing the frame for PageBottom on the first page.
  3. DFGR_CURRLINE could not be used for the Y coordinate of DFWriteRect.
  4. Items on the right were wrapping at the end of the page in the body section. They now wrap at the margin. Items in the header wrap at the end of the page as in Winprint.
  5. Bitmaps in headers did not work.
  6. Corrected a bug which caused incorrect colors to be printed in Windows NT.
  7. DFVOffset did not work in headers.
  8. In some circumstances an item showing on the preview would not print with some printer drivers.
  9. Subheaders were printing beyond the bottom of the page.
  10. A line could print beyond the bottom margin if the first item of the line was blank.
  11. The last item before a header used the header font.
  12. Numbers were printing at the right margin if the print command was not in order by the print location.
  13. pAdjustFontSize, which reduces the font size of large numbers so that they do not overlap adjacent items, did not work when the number was preceded by text.
  14. DFWriteLine was printing from the top of the page rather than the top of the current header.

Download



Winp2vpe.zip Version 2.1 ~ 80kB
Winp2vpe.zip original

Subversion



http://svn.vdf-guidance.com/Winp2Vpe/trunk/