Printing with DFPRINT

Version 4.616 brought major enhancements to the printing functionality in DP4. There is full support for printing text in multiple fonts and colours and for printing bitmaps, icons etc. The appearance of printed maps will closely match the appearance on screen. To make use of the enhanced print capabilities all that is needed is to change the output device (POD) to one that uses the new DFPRINT print device. No other program changes are necessary, though it would be advisable to read through the remainder of this topic to gain a full understanding of the considerable implications resulting from this change.

Operation of DP4 when printing to DFPRINT devices

When a program selects to print to DFPRINT then a page set up dialog is displayed. In the 16 bit version this will only allow the user to select orientation and printer to be used. In the 32 bit version it also allows margins to be set. You can disable this dialog by setting pagesetup=0 in the [progname] or [trmw] sections of the DP4 configuration file. The print orientation will default to Landscape if only print to screen is selected, and Portrait otherwise. The margins selected in the 32 bit version are taken from margin_left, margin_top, margin_right, margin_bottom entries in the DP4 configuration file. The users selections are written back to the same place. Margins default to half the default value specified by Windows (usually give a value of 12.5 millimetres or half an inch), though this default will be increased if the printer's minimum margins are more than this. The margin_xxxx entries are stored in the units used by Windows, which may be thousandths of an inch or hundredths of a millimetre.

If print to file is selected then the append/delete/cancel dialog may be displayed as normal. However the append option is disabled - it is not currently possible to append to print files intended for DFPRINT. (This may prevent DFPRINT from being used in certain situations). This restriction will be removed in a future release if possible. Print files created using the DFPRINT device can only be accessed with the DFPRINT program (using a command line of the form DFPRINT filename). The files are in a private format which is different between the 16 bit and 32 bit versions of DP4 and which is subject to change in future releases. The file is analogous to a Windows meta file, though the format is much more compact. To create files readable by other applications you should set up a print device that uses the IBM file output or DP4 output devices, or from 4.621, you can use the Save option in DFPRINT to convert the file to various formats usable by other programs. You can also configure PODs that will automatically cause the file to be converted to one of these formats. For more information on these possibilities refer to Configuring DFPRINT PODs in the OSDI Developer's Guide.

As with the old WINPRIN program, which is retained for compatibility only, no printing is done until the application releases the print device. In order to ensure that programs printing to DFPRINT do not appear to hang a comfort message is displayed while the print output is being created. However this is not created until several pages have been created (as creating the file is normally very rapid).

When the program closes the DFPRINT device the output it has created is sent to the new DFPRINT program (unless only print to file was selected, and conversion to another format is not required).

Operation of DFPRINT

The behaviour of DFPRINT will vary according to whether print to screen was selected or not. If it was selected then DFPRINT will normally run interactively and display a print preview of the first page. The user can toggle between viewing the whole page, the page minus the margins or actual size output. It is possible to navigate around the document simply. If DFPRINT is running interactively no printing will take place unless the user presses the Print button, regardless of whether print to printer was selected or not initially. The standard windows print dialog is displayed when the user presses the print button.

If print to screen was not originally selected then DFPRINT runs in batch mode, and prints a single copy of the document on the printer selected in the pagesetup dialog, or the Windows default printer if this dialog was disabled. DFPRINT also runs in batch mode if the flags SCREEN+NOCTL+NO_SELECT are passed to dvc_choose().

In the 32 bit version of DFPRINT there is also a Copy button. This copies an image of the currently displayed page as a scaleable picture (metafile) to the clipboard. This allows individual pages of the document to be imported as graphics into other applications such as MS Word or Paint. It is not currently possible to import the document as text, though this is a likely future enhancement.

From 4.619, again only in the 32 bit version of DFPRINT, there is a Save button that can be used to save the output to a file or files: in versions 4.619 and 4.620 only HTML format is supported, from 4.621 you can also use RTF files which contain each page of the report embedded as a metafile. The HTML format files use CSS2 positioning and may not display correctly in older Web Browsers. Also some HTML editors will have problems with the generated pages. In the RTF files the output is essentially a picture and cannot be edited by the user.

DFPRINT can be used to view a file created on another computer, subject to the following limitations:

To create a file that can be viewed on any Windows computer see Creating Output for Other Applications in the OSDI Developer's Guide.

Appearance of Printed Output

The DFPRINT program is intended to be completely WYSIWYG - maps will be printed in the same colours and at the same size using the same fonts as they have on screen. However there are a few points to bear in mind:

Because Windows does not change the reported resolution of the screen in pixels per inch when the resolution is changed the size of a printed map and the display size will not always match exactly. However a map that is one "logical inch" on screen will be printed at one "logical inch" on the printer. Unfortunately MAPEDIT does not currently have a ruler to indicate the size (and in any case does not always display maps in their correct size) but the ratio of sizes will match that used by programs such as Word or WordPad. From 4.620 you can control the sizes used for printing with the settings listed here.

If maps have colour information then they will be printed grey scale on non colour printers. Depending on the colour scheme you use this may sometimes cause printing to be hard to read.

DFPRINT uses exactly the same information to create the font and convert map co-ordinates from internal units to real word units as the terminal manager (except that from release 4.621 you can use the [DFPRINT] section of dp4.ini to override settings from the [TRMW] section). Therefore at full scale in print preview the map will always look more or less identical to a map displayed on screen, unless the default font is realised differently on the printer from on screen, in which case the preview will match the printed version. Under most circumstances a map will look the same printed or displayed, but certain perverse choices of default font can cause this not to be the case.

For example, suppose you are running US Windows 95, and select userdata type F and specify the default font like this:

font="system"
pointsize=15.

Now, on screen the system font is not available in this point size - it is only available 10 point - 8 pixels wide by 16 high using small fonts, or 10*20 using large fonts. Therefore maps will be displayed by converting a 16*32 internal cell to an 8*16 display cell. However on the printer things are quite different. Windows will be able to scale the system font. Therefore the display cell of the print preview will probably be 12*24 units - and the maps will appear 50% bigger than expected. This kind of problem can only arise when a default font is specified that Windows cannot create exactly on the display. If this is encountered then change the definition of the default font to match what it actually is - in this example by changing the pointsize entry to pointsize=10.

In a few cases the font used to display the map on screen will not be the same as the font used to print the map. This will not be a problem where true type fonts are used or a font which exists in many different resolutions. However the system font and the system fixed font need to be substituted in order to print acceptably, as they only exist for the screen and when printed out would look very poor. The choice of font substitute is left up to Windows, but enough information is provided for it to choose a generally similar font. (i.e. proportional and non proportional sans serif fonts respectively)

When the print preview is displayed all fonts and outputs are scaled to fit the display. For non true type fonts, especially when the preview is resized to a very small size the display may not be accurate. At normal size it will usually be quite accurate.