Dec 102017
Simple ASCII text file printer. Prints text files fully formatted.
File CPRINT44.ZIP from The Programmer’s Corner in
Category Printer Utilities
Simple ASCII text file printer. Prints text files fully formatted.
File Name File Size Zip Size Zip Type
CPRINT.DOC 10112 3613 deflated
CPRINT.EXE 32566 16069 deflated
CPRINTS.EXE 18120 8676 deflated

Download File CPRINT44.ZIP Here

Contents of the CPRINT.DOC file


CPRINT can take input from the command line or via a built in full
screen editor. Enter "CPRINT /P" for full screen input mode.

CPRINT can INTELLIGENTLY handle a print request for MULTIPLE files such
that the files are CORRECTLY printed on BOTH sides of the paper. This
is great for printing hardcopy of large documents (eg. PROCOMM.DOC) or
many small files (eg. source code for your 200 function C lib). The
resulting output is arranged just like a book - page 1 & 2 of the first
file are on opposite sides of the same piece of paper.

CPRINT will page break when the default line count is reached (/L
switch) or when it encounters an ASCII form feed in the file. You can
add a top margin (great for EPSON printers). You can print or not
print the files date & time info as a page header. You can add a left
margin to all lines of the file (allows 3 hole punch without punching
through text).

File List

The distribution files are:

CPRINT.DOC - this documentation file.

CPRINT.EXE - the full program including the built in full
screen editor.

CPRINTS.EXE - a small version of cprint without the full screen
editor - for use on pc's which are not close IBM

Program Usage

cprint filespec switches

OPTIONAL COMMAND LINE SWITCHES: ( where "xx" equals a number)

/P display prompts using the built in full screen editor
so you can enter options by "filling in the blanks".

/Mxx defines left margin to add to every print line (default=0).

/Wxx defines total maximum line width (default=80).

/Cxx defines number of copies to print (default=1).

/H do NOT print files' date/time info as page header.
useful for printing pre-formatted documents.

/Txx defines top margin to add (default=0).

/Lxx defines maximum print lines per page in addition to
the top margin (default=54 (66 if /H used)).

/1 print pages which go on front side of paper (see NOTES).

/2 print pages which go on back side of paper (see NOTES).

/S split such that each file is on a unique set of pages.
(do NOT print the first page of a new file on the back
of the last page of the previous file.)


Filespec may contain pathnames & wildcards.

To print on both sides of paper:
print with /1, turn the paper over, re-print with /2.

/S only applies to /1 and /2.

/C is disabled by /1 and /2.

Some Examples

Print files with file date & time info as page heading, 54
text lines per page, using front of paper only.


Same as above but add an 8 character left margin and print on both
sides of the paper (put your printer in 12 CPI mode first).


when 1st pass printout is completed flip paper over then


Notice in the second example I told CPRINT to use an 88 character line
width. The default width is 80. If the total print width (left margin
+ text) is greater than the /W parameter CPRINT will break the line,
linefeed, space over by the left margin amount, then print the balance
of the line. Since we put the printer in 12 CPI mode we needed to tell
CPRINT that 88 characters would fit on the print line so that input
lines longer than 72 characters would not be needlessly split. This
effectively centers an 80 character wide line on the 96 character wide
page with 8 character left and right margins.

The /S switch

This switch can be used in conjunction with /1 and /2 to control the
interleaving of multiple files when printing on both sides of the
paper. Suppose we have two files - FILEA containing 3 pages of data and
FILEB containing 2 pages of data. If we wish to print on both sides of
the paper we can print the files with or without interleaving:

Without /S


This will produce the following page layout:

sheet 1 front side - page 1 of FILEA
sheet 1 back side - page 2 of FILEA

sheet 2 front side - page 3 of FILEA
sheet 2 back side - page 1 of FILEB

sheet 3 front side - page 2 of FILEB
sheet 3 back side - blank

Notice that page 3 of FILEA and page 1 of FILEB are printed on
opposite sides of the same peice of paper.

With /S


This will produce the following page layout:

sheet 1 front side - page 1 of FILEA
sheet 1 back side - page 2 of FILEA

sheet 2 front side - page 3 of FILEA
sheet 2 back side - blank

sheet 3 front side - page 1 of FILEB
sheet 3 back side - page 2 of FILEB

Notice that each file is printed on a unique set of sheets.

Line Length

CPRINT will start a new print line whenever a new line is encountered
in the input file OR the line length (as set by the /W switch) is
reached. The program attempts to account for non-printing characters
when making these decisions (embedded printer control codes). This is
critical only when an input lines' length exceeds the /W line length
due to embedded control codes. CPRINT does NOT count any of the
following as printed characters when calculating printed line length:

- Characters less than ASCII space (32)

- ANY single character immediately following an
ASCII escape (27)

For instance, if the physical line length is 84, the /W length is 80,
and the line contains two 2 character long printer control sequences -
the last four characters will NOT be printed on the next line because
CPRINT understands that 4 of the characters were control codes and did
not move the printhead. However, if the 84 character long line does
not contain any control codes then it will be split and the last 4
characters will be printed by themselves on the next line. There is
one situation where this falls flat - some printers have control


This will be considered TWO non-printed characters (ESC + single
character following it - A). Therefore CPRINT will think the printhead
has moved right one character more than it actually has (due to the H).
The /W switch can be used to compensate accordingly. I have found it
virtually impossible to build a program capable of interpreting all of
the various control code sequences used by all of the printer
manufacturers. I do not see this as a significant problem given the
programs intent - to print source code and on-line documentation files.

Programmers Example

Given the following inputs:

CPRINT PTD*.C /M8 /W88 /1
CPRINT PTD*.C /M8 /W88 /2

CPRINT printed 40 some files encompassing 115 pages with page breaks,
left margins for 3 hole punch, descriptive file information as page
headers, and correctly interleaved on both sides of the 58 sheets of
paper. Just like a book. Need I say more?


o MS-DOS Version 2.0 or later is required.

CPRINT is supplied for personal, private use. Feel free to
distribute CPRINT given these restrictions:

o the program shall be supplied in its original, unmodified
form, which includes this documentation and all other
files in the distribution list.

o no fee is charged.

o commmercial use is prohibited.

o the program may NOT be included - or bundled - with other
goods or services.

If you are using CPRINT and find it of value, any contribution
would be greatly appreciated ($10 suggested).

Contributions and problem reports may be sent to:

Larry I. Smith
808 Shenandoah Dr.
Plano, Texas 75023

Revision History

o v3.9 - first public domain release.

o v4.0 - added support for embedded printer codes.

o v4.1 - corrected logic to handle lines containing
an embedded CR. Some formatters use this
method to emulate bold and underlining.

o v4.2 - internal housekeeping.

o v4.3 - corrected a bug associated with lines which
start with a CR and contain more than the CR.

o v4.4 - replaced fopen/fprintf constructs with
open/write constructs. some pc clone
versions of MS-DOS 2.x do not always write
to the printer correctly using fopen/fprintf.

- added CPRINTS.EXE to the archive. this is
CPRINT.EXE with the full screen editor
input feature removed so that users with
non IBM compatible pc's won't crash their
system trying to use the full screen mode.

 December 10, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>