How to print an ASCII file

The example program printfile.p demonstrates how to print an ascii-file using GDI functions.
The program prints a header and a footer on every page using a proportional font. The page header contains the filename (right aligned). The page footer contains the date (left aligned), time (centered) and page number (right aligned).
The contents of the ascii-file is printed in a non-proportional font (Courier New).
The procedure printfile.p has currently only one input parameter: the filename of the ascii-file to print.
The definition section contains some variables who could also have been used as input parameters:

/* ================================================================= 
   file    : printfile.p
   purpose : print a text file
   usage   : RUN printfile.p ("printfile.p").
   tested  : only on Windows 98 with local printer (HP Laserjet 4)
   ================================================================= */
/* these variables could also be useful as input parameters: */
DEFINE VARIABLE p-Landscape   AS LOGICAL NO-UNDO INITIAL NO.   /* Orientation is Landscape or Portrait */
DEFINE VARIABLE p-Silent      AS LOGICAL NO-UNDO INITIAL YES.  /* show no message boxes (on error)     */
DEFINE VARIABLE p-Devicename  AS CHARACTER    NO-UNDO.         /* if "" then default printer           */
DEFINE VARIABLE p-docname     AS CHARACTER    NO-UNDO.         /* if "" then p-Filename                */
DEFINE VARIABLE p-Leftmargin  AS DECIMAL NO-UNDO INITIAL 1.0.  /* left margin (inches) from paper edge */
DEFINE VARIABLE p-fontsize    AS INTEGER NO-UNDO INITIAL 9.    /* pointsize for bodyfont               */

API-procedures used in CreateDC, DeleteDC, DocumentProperties, GetProfileString, StartDoc, EndDoc, StartPage, EndPage, TextOut, SetTextAlign, GetDeviceCaps, MoveToEx, LineTo, SelectObject, DeleteObject, GetTextMetrics, CreateFont, MulDiv.

Attachments : example