Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.apps > #765

Re: Printing from a C program in linux

From Jan Panteltje <panteltje@yahoo.com>
Newsgroups comp.os.linux.development.apps
Subject Re: Printing from a C program in linux
Date 2015-01-12 14:33 +0000
Organization Datemas.de http://www.news.datemas.de
Message-ID <m90lv8$2c1$1@news.datemas.de> (permalink)
References <B79FD1EF.4922%jenco@wol.be> <fab8e3f2-b94b-484b-8d42-303c6ef86b23@googlegroups.com>

Show all headers | View raw


On a sunny day (Mon, 12 Jan 2015 05:48:12 -0800 (PST)) it happened
mtkhusro92@gmail.com wrote in
<fab8e3f2-b94b-484b-8d42-303c6ef86b23@googlegroups.com>:

>On Tuesday, 14 August 2001 22:14:45 UTC-7, Jenco  wrote:
>> Hi,
>> 
>> I'm making a program in C for linux but an important thing i can't find in
>> my books is how to print from your C program
>> 
>> 
>> any hint,link or tutorial is welcome
>> 
>> 
>> 
>> thaaaaaaaaaaaaaaaaanx       Marco
>
>
>
>any help?

There is a lot of possibilities.
You could start by typing:
apropos printer


If you have some postscript compatible printer installed,
man
lp
lpr
lpq

I have cups installed, print on DVDs with it etc.
gimp for formatting, graphics.

Some scripts I'v used:

# print postscript to Epson USB printer using ghostscipt and ijs printer server:

# lpr200
/usr/bin/gs \
-sDEVICE=ijs \
-sIjsServer=/usr/bin/epijs \
-sOutputFile=/dev/usb/lp0 \
-r360 \
-dIjsDepth=24 \
-sDeviceManufacturer=Epson \
-sDeviceModel='Stylus Photo 2000P' \
-sIjsParams="PageImageFormat=Raster,ByteSex=little-endian" \
-DNOPAUSE \
-dSAFER \
-- \
$1



Print ASCII text to USB printer , using the above script:

# lpr200a
if [ "$2"  = "" ]
then
 echo "Usage lpr200a file.txt fontsize (use 10 for letter, 12 for addresses on enveloppes)".
 exit
fi
# ASCII to PS
a2ps -o /tmp/a2ps_tmp1.ps -1 --font-size=$2 --portrait --no-header --borders=no $1
# To USB R200 on /dev/usb/usblp0
lpr200 /tmp/a2ps_tmp1.ps
# delete temp file
rm /tmp/a2ps_tmp1.ps



Maybe from C use system("blah blah") as above

Maybe simply look for /dev/usb/lpX (X = 0,1, etc)
open it,
send the postscript to it,
close device

Do not use printer very often anymore. almost everybody has some electronics reading device these days..



Back to comp.os.linux.development.apps | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: Printing from a C program in linux mtkhusro92@gmail.com - 2015-01-12 05:48 -0800
  Re: Printing from a C program in linux Jan Panteltje <panteltje@yahoo.com> - 2015-01-12 14:33 +0000
  Re: Printing from a C program in linux floyd@apaflo.com (Floyd L. Davidson) - 2015-01-12 05:34 -0900
  Re: Printing from a C program in linux Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-01-12 10:56 -0500
  Re: Printing from a C program in linux Jasen Betts <jasen@xnet.co.nz> - 2015-01-13 06:38 +0000
    Re: Printing from a C program in linux Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2015-01-13 17:28 +0200

csiph-web