Page 1 of 1 1
Topic Options
#121847 - 2004-06-25 09:39 PM Sending a file to printer
futte Offline
Fresh Scripter

Registered: 2002-07-02
Posts: 49
Loc: Denmark
Hi everybody

I have found thes code in the UDF libaray :
function PrintTo($_file,$_printer)
dim $,$_
$_=split($_file,"\")
if ubound($_) $_file=$_[ubound($_)] endif
$_[ubound($_)]=""
$_=join($_)
$=createobject("shell.application")
$.ShellExecute($_file, $_printer, $_, "printto", 0)
exit @error
endfunction

and tried it, but there are three things, if i'm sending a PDF file to a printer it also starts Acrobat reader and show the file there, Why ?

And one more thing if don't delete these 4 lines in the code, it wont work, what does these 4 lines do ?
$_=split($_file,"\")
if ubound($_) $_file=$_[ubound($_)] endif
$_[ubound($_)]=""
$_=join($_)

And the last thing, what does these two lines in the code means :

$=createobject("shell.application")
$.ShellExecute($_file, $_printer, $_, "printto", 0)

Hope anybody can help me

Top
#121848 - 2004-06-25 09:45 PM Re: Sending a file to printer
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
You can do the following pretty simply -

TYPE FILE.TXT > LPT1

Or

PRINT FILE.PDF > LPT1

What version of KiXtart are you running:
Quote:


$_=split($_file,"\")
if ubound($_) $_file=$_[ubound($_)] endif
$_[ubound($_)]=""
$_=join($_)





Create an object for use..
Quote:


$=createobject("shell.application")




Execute the file to be printed..
Quote:


$.ShellExecute($_file, $_printer, $_, "printto", 0)





Thanks,

Kent

_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#121849 - 2004-06-25 09:55 PM Re: Sending a file to printer
futte Offline
Fresh Scripter

Registered: 2002-07-02
Posts: 49
Loc: Denmark
Thanks for quick respons but.....

First I'm running version 4.22 og Kix

You say I can do it simple this way:

TYPE FILE.TXT > LPT1

Or

PRINT FILE.PDF > LPT1

but I need to print it to a networkprinter, can I do that in a simple way to ??

You said that this execute the file to be printed

$.ShellExecute($_file, $_printer, $_, "printto", 0)

What does these 3 parameters do in the line

$_, "printto", 0


Thanks



Top
#121850 - 2004-06-25 11:53 PM Re: Sending a file to printer
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
Is it a network printer shared off a server? if so try something like...

Shell '%comspec% /c Print /D:\\server\printshare File.txt'

Top
#121851 - 2004-06-26 04:20 PM Re: Sending a file to printer
futte Offline
Fresh Scripter

Registered: 2002-07-02
Posts: 49
Loc: Denmark
Hey

Yes it's working fine with txt-files, but i need to print a PDF file too, is that possible ??


Top
#121852 - 2004-06-27 04:03 AM Re: Sending a file to printer
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
In order to print a PDF file, a PDF reader must be launched. This is normal.
_________________________
There are two types of vessels, submarines and targets.

Top
#121853 - 2004-06-27 08:00 PM Re: Sending a file to printer
futte Offline
Fresh Scripter

Registered: 2002-07-02
Posts: 49
Loc: Denmark
Hi

Now it's all working, thanks a lot for the help :-)

Top
#121854 - 2004-07-16 08:25 AM Re: Sending a file to printer
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
actually, to print a PDF file, all you need is either Print() or PrintTo() UDF
print for pdf seems to automatically print to default printer (instead of asking printer) and printto can be used to direct to printer of your choice.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.128 seconds in which 0.093 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org