[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: stairstep printing on an HP Deskjet



On Thu, Oct 23, 2003 at 04:28:41PM +1000, Robert William Hutton wrote:
> Corey Hickey wrote:
>
> >Currently, if I try to print a text file by using:
> >$ lpr text.txt
> >I get a stairstep effect
> 
> This is due to the difference between Unix text format and the DOS text 
> format.  Unix uses LF (linefeed) as the line terminator; DOS uses LFCR 
> (linefeed-character return).  With an HP printer, sending just an LF 
> makes the printer advance to the next line.  A CR is required to return 
> the printing to the beginning of the line.
> 

I am working with an old HP_670C (understandig PCL 3)
using following printing command for text files:

"pr -o 16 <text_file> | lpr"
 --------------------------

"pr -o 16 .."   left margin = 16 chars
    adding      file header + formfeed


my '/etc/printcap' has this entry (remove dash lines):
------------------------------------------------------

lp|hp deskjet printer condensed w/ formfeed
:lp=/dev/lp0
:sd=/var/spool/lpd/lp
:af=/var/log/lp-acct
:lf=/var/log/lp-errs
#--------------------------
:if=/usr/local/sbin/lp/hpdj
#--------------------------
:pl#60
:pw#100
:mx#0
:sh
:sf
:rw
:

-----------------------------------------------------
The C-source of my 'hpdj' filter (see printcap line)
using internal printer commands to be more flexible:
-----------------------------------------------------
(compile: "cc -O2 -o hpdj hpdj.c")
(compact 'hpdj': "strip hpdj")

// HP DeskJet Printer Filter:  Add CarriageReturn to LineFeed
// ==========================================================
// \wwf 20.01.03
// bin file = "/usr/local/sbin/lp/hpdj"
// reference in /etc/printcap:
// printcap: add "if=/usr/local/sbin/lp/hpdj" to printer config
// -------------------------------------------------------------
// (left margin: "pr -o 16 <text_file> | lpr)
// (pr gererates formfeed)


#include    <stdio.h>

#define CR  '\r'            // CarriageReturn
#define LF  '\n'            // LineFeed
#define FF  '\f'            // FormFeed

//  Printing Control Commands for HP_670C
//  -------------------------------------
char    RESET[]= {'\x1b','\x45'};

char    LFLF[] = {'\x1b','\x26','\x6b','\x30','\x47'};
char    CRLF[] = {'\x1b','\x26','\x6b','\x32','\x47'};

char    COND[] = {'\x1b','\x26','\x6b','\x32','\x53'};
char    ELITE[]= {'\x1b','\x26','\x6b','\x34','\x53'};

char    PROP[] = {'\x1b','\x28','\x73','\x31','\x50'};

int ch;             // text input chars
int i;              // loop counter


char    writebuf(char *array)   {       // write Ctrl-chars
    for (i=0; i<= sizeof(array); i++)   // don't write '\0'
        putc(*array++, stdout);
}

int main()  {
   writebuf(RESET);             // printer
   writebuf(CRLF);              // control
   writebuf(COND);              // commands
// writebuf(PROP);              // (proportional)

   fflush(stdout);              // force writing
    
   
   while ((ch = getchar()) != EOF)  {   // read text
    putchar(ch);                // write text
   }

// putchar(FF);     // formfeed (uncomment if no paper eject)
   writebuf(RESET);             // reset to standard settings
   return(0);
}

(End of source 'hpdj.c' put to this mail)
==================================================================



If the printing configuration above won't work for Your HP printer, try

----------------------------------------
The C-source of my 'crlf' filter
using external 'carriage_return' feeding
----------------------------------------
(of cource, replace 'hpdj' by 'crlf' in 'printcap' listing above!)

(compile: "cc -O2 -o crlf crlf.c")
(compact 'crlf': "strip crlf")


// HP DeskJet Printer Filter:  Add CarriageReturn to LineFeed
// ==========================================================
//                      \wwf 02.07.99
// bin file = "/usr/local/sbin/lp/crlff"
// /etc/printcap: add "if=/usr/local/sbin/lp/crlff"
// to some generic printer config
// ----------------------------------------------------------

#include    <stdio.h>

#define CR  '\r'                // CarriageReturn
#define LF  '\n'                // LineFeed
#define FF  '\f'                // FormFeed

int ch;                         // text input chars


int main () {
    while ((ch = getchar()) != EOF)  {  // read text
        if (ch == LF)   putchar(CR);    // LineFeed
        putchar(ch);                    // write text
    }

//  putchar(FF);        // FormFeed better via "pr" cmd!

    return(0);
}

(End of source 'crlf.c' put to this mail)
==================================================================


----------------------------------------------------
To print "*.html" files, convert them to text first:
----------------------------------------------------

    Convert (tabular) html files to text
    ====================================
    html2text -nobs -o <file>.txt <file>.html

    -nobs          Do not use backspaces for boldface and underlining



-----------------------------------------------
To print "Umlaute", you may have to use recode:
-----------------------------------------------
(I put them into my '/etc/alias.sh')

alias unix2dos='recode lat1..ibmpc'
alias dos2unix='recode ibmpc..lat1'


Usage:  "recode lat1..ibmpc  < input.file  > output.file"



Reply to: