Aros/Developer/Docs/Devices/Printer

Introduction
AmigaDOS 3.1 (which AROS is modeled after) didn't have any standard printing dialogs like you are probably used to seeing under other OSes for selecting which pages to print of a document, choosing landscape mode vs portrait, paper sizes, paper types, duplex mode, print preview, etc. Every program has to roll its own to interface with the printer prefs for these things.

Under AmigaDOS 1.x-3.1 each and every application program has to do its own support for high resolution, high quality printing because the graphics display and printing API didn't have any resolution independence built in creating and displaying a drawing command list and then converting that to a structured drawing format or language output including logos or fonts, etc. (unlike MacOS or Windows).

Under AmigaDOS 1.x-3.1 printing consisted of a primitive printer.device which only understands ANSI formatted text and a few types of graphics rastport binary data, and consulted the printer, printergfx, and printerps preferences to decide how to handle printing to either a bitmap oriented printer, an ANSI sequence text printer, or by feeding raw data (generated independently by each individual program that wanted to print raw). Each printer would have a custom device file made for it to switch modes from text to graphics (translating from internal Amiga graphics or text format to something the printer liked) and do things like form feed, set margins, etc. and printer.device would (by the printer prefs) decide which port to send that data to, check for errors while printing, etc.

AROS, at the moment, does support translating any text and pictures into Postscript (.ps) files which can then be saved as a file or printed to a limited range of printers.


 * Use the existing printer.device API


 * PRD_RAWWRITE send unprocessed data to printer
 * PRD_DUMPRPORT (IODRPReq->ioCommand) send rastport to printer
 * PRD_QUERY (IOStdReq->io_Command) in what state is the printer port
 * PRD_PRTCOMMAND (IOPrtCmdReq->ioCommand) send ANSI escape sequence to printer via CMD_WRITE (unsupported)


 * Writes its output to:
 * A filename specified by the user (via prefs or a pop-up)
 * A pipe to another program (via prefs or a pop-up requester)
 * The output is PostScript Level 2 (or lower)
 * Select page size as A4, Letter, or custom (in inches or mm)

Status:


 * printer.device is ~99% code complete
 * L:port-handler is code complete
 * C:Print is code complete (print via Datatypes)
 * DEVS:Printers/PostScript is ~95% code complete

Features:

+ All 10 printer.device units should be available + Each unit runs in its own DOS Process + Each unit has its own instance of a DEVS:Printer/* driver + The instance only exists while the unit is open. + Print to file, serial, parallel, or USB (the last 3 are untested) + PAR: SER: and PRT: DOS handlers for printing (and general IO) - Of note, see DEVS:DosDrivers/SER0 - it can be adapted for to connect to any streaming device. + Landscape/Portrait works + PostScript Level 2, with %%Page: and EPS compatible comments - makes enscript happier

Known issues: - Only PCC_BGR printers are supported at this time (I'll get CYMK and B&W working in a bit) - Only (due to licensing [1]) PostScript and Skeleton (demo) printers are available. - Centering, color inversion, and a number of other minor features are missing or broken. - No attempt is made to correct the aspect ratio of the printed pictures.


 * Almost all of the printer drivers with source code that could be found have a big "Copyright (c) 19xx Amiga" at the top. Hopefully people can use the PostScript and Skeleton drivers to write printer drivers with better licenses.

Examples
/**************************************************************
 * Print.h : procedures for printing                    ****
 * Free software under GNU license, started on 2/2/2012 ****
 * © AROS Team                                          ****


 * 1) ifndef PRINT_H
 * 2) define PRINT_H


 * 1) include "Memory.h"

/* Print a file */ BYTE print_file(LINE *svg, unsigned char eol);

/* Get/set current printer.device unit *  If unit < 0, gets current printer unit *  Otherwise, sets unit to the selected unit */ BYTE print_unit(BYTE unit);


 * 1) endif