Using a printer in Windows
[1/32] from: philippe:oehler:id-net:ch at: 8-Jan-2002 19:24
Hello,
I want to know if it's possible to user a printer from a rebol program ?
I read an article on the codeconscious.com's site but the code is not
working. I don't have rebol/command, maybe it's an explanation.
Philippe Oehler
[2/32] from: greggirwin:mindspring at: 8-Jan-2002 13:05
Hi Philippe,
<< I want to know if it's possible to user a printer from a rebol program ?
>>
The two main options are to print via a browser, or use PDF-maker to write a
PDF file and print that. I read somewhere that you could also send a PRN
file directly to the printer, but I haven't tried that.
--Gregg
[3/32] from: al:bri:xtra at: 9-Jan-2002 9:19
Philippe wrote:
> I want to know if it's possible to user a printer from a rebol program ?
Try something like this:
REBOL [
Name: 'Printer
Title: "Printer"
File: %"Printer.r"
Author: "Andrew Martin"
eMail: [Al--Bri--xtra--co--nz]
Date: 27/Sep/2001
Example: [
Printer "This goes to the printer!"
Printer/Page "This prints this line and feeds a page!"
]
]
Printer: func [
"Sends text to printer on //prn."
[catch]
Text [string!] "The text to be printed."
/Page "Append Carriage Return (CR) and Page Feed."
][
throw-on-error [
secure [
%//prn [allow write]
]
write %//prn Text
if Page [write/binary %//prn "^(0D)^(page)"]
Text
]
]
]
It works OK on Windows PCs. For other computers, you might have to change
the %//PRN to something else.
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[4/32] from: jason:cunliffe:verizon at: 8-Jan-2002 15:39
> << I want to know if it's possible to user a printer from a rebol program
?
> >>
>
> The two main options are to print via a browser, or use PDF-maker to write
a
> PDF file and print that. I read somewhere that you could also send a PRN
> file directly to the printer, but I haven't tried that.
hmmm..
you might thini this wierd, but another way might be to write a tool in
Flash5 for printing REBOL. It could run within a browser, [perhaps less
interesting], or as a nice standalone executable on Windows and Mac.
Unlke PDF with its ubiquitous splash graphic, and and big load, Flash offers
you some handy features:
- any customized interface you want [clean fullscreen, minimal, animated,
mutilinguaa etc..]
- loop back to launch rebol [FScommand]
- controllable printing [select what area, screen, frame etc]
This might be be another good candidate for REBOL-XML though certainly not
essential.
With Oldes great make-swf toolkit coming along so well, the closure grow
more tantalizing. Perhaps it will soon even make swf.exe
Flash which calls REBOL which makes swf ... etc.
Once you have a 'stub' Flash projector [standalone exctuable or running
within activeX player via browser or some other], you can of course load
other SWFs.
3rd party Flash projector tools add a\many moer cool features to enhande
this scenario.
These all open interesting options addressing the ENCAP / security / REBOL
distribution thread now going on.
So can one embed a stub Flash projector within REBOL like any other binary?
fyi: a minimal stub is 369Kb
./Jason
[5/32] from: info:id-net:ch at: 11-Jan-2002 10:40
The code below doesn't work in Windows 98. Maybe it's because i dont use
rebol/command.
I think i have to produce html text to browse and then print.
Or produce a PDF document.
> Philippe wrote:
> > I want to know if it's possible to user a printer from a rebol program ?
>
> Try something like this:
Rebol []
[6/32] from: sunandadh:aol at: 11-Jan-2002 6:13
Hi Philippe
> The code below doesn't work in Windows 98. Maybe it's because i dont use
> rebol/command.
It doesn't work for me on 98 either. (I don't have /Command). I'm wondering
though if it is because my printer is on USB not LPT. I get nothing printed
with then DOS commands:
echo "hello" > prn
echo ^l > prn
(that's control plus lowercase L to get a page throw)
> I think i have to produce html text to browse and then print.
> Or produce a PDF document.
Both have advantages, in that you can offer a "preview mode"
before printer.
HTML has the edge for me in that it is easier to produce, and you can (as you
say) use the Browse command. The document can then be read by most word
processors and other applications.
And Andrew has written a neat dialect for HTML.
Sunanda.
[7/32] from: info:id-net:ch at: 11-Jan-2002 12:47
The echo command in dos works for me, and i got a lpt connection for my
printer. But a program that is opened with this command, bug.
I will look for this HTML dialect..
Txs
Philippe
[8/32] from: info:id-net:ch at: 11-Jan-2002 12:47
Both have advantages, in that you can offer a "preview mode"
[9/32] from: sunandadh:aol at: 11-Jan-2002 9:23
Hi Philippe,
> Both have advantages, in that you can offer a "preview mode"
> > before printe
Sorry, I loosely phrased what I wrote. It is simpler to fire up a HTML
preview in non-command Rebol than a PDF preview. Rebol has the 'Browse
command for this.
Sunanda
[10/32] from: al:bri:xtra at: 12-Jan-2002 10:08
> The code below doesn't work in Windows 98. Maybe it's because i dont use
rebol/command.
Works OK on Windows XP and Windows 98 using Rebol/Core and Rebol/View for me
(I just tried it). Are you sure that your computer is set up correctly?
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[11/32] from: al:bri:xtra at: 12-Jan-2002 10:13
> I will look for this HTML dialect.
http://valley.150m.com/Rebol/Values/HTML.r
http://valley.150m.com/Rebol/Values/ML.r
http://valley.150m.com/Rebol/Values/eText.r
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[12/32] from: al:bri:xtra at: 12-Jan-2002 10:11
> It doesn't work for me on 98 either. (I don't have /Command). I'm
wondering though if it is because my printer is on USB not LPT. I get
nothing printed with then DOS commands:
Hmmmm, my printer is attached to LPT1: and works OK with this software. So
this could be a problem. Sorry, you're on your own here.
> And Andrew has written a neat dialect for HTML.
Yes! And if you don't like using my HTML dialect, try using the eText
dialect. It's far, far easier to type in and use. There's plenty of eText
samples on my site. :-)
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[13/32] from: info:id-net:ch at: 12-Jan-2002 16:43
Andrew,
you found the solution of the problem of printing 1 year ago, using
javascript and html.
Here's your code. I didn't test it but it sounds good.
[
REBOL [
Title: "Auto printing via Browser."
File: %"HTML Print.r"
Author: "Andrew Martin"
eMail: [Al--Bri--xtra--co--nz]
]
File: %PrintMe.html
write File {
<HTML>
<HEAD>
<TITLE>Auto printing HTML file</TITLE>
</HEAD>
<BODY>
<H1>Auto printing HTML file</H1>
With the help of a little JavaScript...
<SCRIPT LANGUAGE="JavaScript">
self.print();
</SCRIPT>
in here.
</BODY>
</HTML>
}
browse File
]
Philippe
[14/32] from: al:bri:xtra at: 13-Jan-2002 9:28
I tried that out when I wrote it. :-) Then promptly forgot all about it! :-(
Thanks for reminding me about it.
I'll put:
<SCRIPT LANGUAGE="JavaScript">
self.print();
</SCRIPT>
as a magic word in my HTML dialect.
Andrew Martin
What was that again? :-)
ICQ: 26227169 http://valley.150m.com/
[15/32] from: al:bri:xtra at: 13-Jan-2002 11:06
Just add the following to my HTML dialect:
Self-Print: does [
JavaScript "self.print();"
]
then to get a HTML document that will print it self out (one only needs
to click the OK button on the print dialog on Windows MSIE6), just write:
File: %PrintMe.html
write File HTML [
header [Title "Auto printing HTML file"]
body [] [
h1 "Auto printing HTML file"
"With the help of a magic word in HTML dialect!"
Self-Print
]
]
browse File
and use Rebol/View to interpret the script. And the HTML will be printed
out.
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[16/32] from: jason:cunliffe:verizon at: 12-Jan-2002 17:30
> Just add the following to my HTML dialect:
> Self-Print: does [
> JavaScript "self.print();"
> ]
> then to get a HTML document that will print it self out (one only
needs
> to click the OK button on the print dialog on Windows MSIE6), just write:
> File: %PrintMe.html
<<quoted lines omitted: 6>>
> ]
> ]
neat... how about adding this tweak:
File: %PrintMe.html
do load-thru http://www.rebol.org/script/colorize.r
write File colorize HTML
;..etc..
./Jason
[17/32] from: rebol:optushome:au at: 15-Jan-2002 6:50
I have a old script on my reb that allows you to select a file and print via
the browser.
Sadly it is an IE only script. It allows you to print any file type that the
browser recognises as printable.
http://www.rebolforces.com/reb/printviabrowser.r
Cheers,
Allen K
[18/32] from: geza67:freestart:hu at: 15-Jan-2002 18:50
Hello Andrew,
>> you found the solution of the problem of printing 1 year ago, using
>> javascript and html.
>> Here's your code. I didn't test it but it sounds good.
>> REBOL [
>> Title: "Auto printing via Browser."
>> File: %"HTML Print.r"
It is really a very elegant way - but what about page breaks? In HTML
(AFAIK) there is no way of inserting page control codes even the most
straightforward page break ?
If you would like to control such things (and don't want to leave the
browser's pagination alone) only the good old PRN-redirection remains.
Or do I miss something?
--
Best regards,
Geza mailto:[geza67--freestart--hu]
[19/32] from: al:bri:xtra at: 16-Jan-2002 8:58
Geza pointed out:
> ...but what about page breaks? In HTML (AFAIK) there is no way of
inserting page control codes even the most straightforward page break ?
One needs to use Style Sheets to suggest to the browser where to put page
breaks. :) Unfortunately, browsers don't yet seem to support this. :-(
> If you would like to control such things (and don't want to leave the
browser's pagination alone) only the good old PRN-redirection remains. Or do
I miss something?
There's the eText to PDF solution which I haven't yet written.
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[20/32] from: louisaturk:eudoramail at: 16-Apr-2002 18:08
Hi rebols,
There doesn't seem to be much in the archives about printing to a real
printer (in my case a HP LaserJet III). I found the following code from
Andrew, but I can't seem to get it to work. Perhaps my problem is that my
printer is on port lpr2:
I thought that I had this figured out once, but I can't seem to find the
script that used it.
I'm using Windows 2000, but also would like to do it running under Linux.
For my particular need right now I want to print plain text directly to the
printer. I would rather not have to make html or pdf files first.
Louis
At 09:19 AM 1/9/2002 +1300, you wrote:
[21/32] from: izkata:aol at: 16-Apr-2002 19:58
Why don't you just use:
printer: func [
text [file! string!]
][
if file? text [text: read text]
write %printing.html rejoin [{<HTML>
<BODY onLoad=window.print>
} text {
</BODY>
</HTML>
]
Or something like that. I'm not sure if the onLoad function
is window.print, or if I need something else to make it work -
something similar is what I used to use.
Daniel S.
[22/32] from: izkata:aol at: 16-Apr-2002 20:02
Why don't you just use:
printer: func [
text [file! string!]
][
if file? text [text: read text]
write %printing.html rejoin [{<HTML>
<BODY onLoad=window.print>
} text {
</BODY>
</HTML>
browse %printing.html
]
Or something like that. I'm not sure if the onLoad function
is window.print, or if I need something else to make it work -
something similar is what I used to use.
Daniel S.
[23/32] from: al:bri:xtra at: 17-Apr-2002 20:43
That code doesn't work well over a network operating system.
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[24/32] from: louisaturk:eudoramail at: 17-Apr-2002 13:25
Andrew,
Thanks for responding. Does this mean that there is no way to print
directly to a printer? I have been unable to find even one reference to
printing hardcopy in any of the 3 rebol books I have or on the rebol website.
Here is my dilemma: we have a database that holds data of donations to our
non-profit organization. I have made a program to create a receipt for
each donation, and email it to the donor. Problem: some donors don't have
email addresses. To them I must print out a receipt on paper. Also, I
need to be able to print out mailing labels.
Is there really actually no easy way to do this?
The printer I use is not shared, but local to my computer (if that helps).
Louis
At 08:43 PM 4/17/2002 +1200, you wrote:
[25/32] from: louisaturk:eudoramail at: 17-Apr-2002 13:33
Daniel,
Is this suitable for my purpose as explained to Andrew? I have been
playing around with your function, but so far can't get anything to print.
Louis
At 08:02 PM 4/16/2002 -0400, you wrote:
[26/32] from: riusa:email:it at: 18-Apr-2002 9:59
Hi,
I have a non-profit organization, I solved the printing problem making a
rebol program which...
1) format my DB data in HTML format
2) save the file to disk
3) open the HTML file using function "BROWSE"
I think this is a very good solution.
bye!
--Alessandro--
> Andrew,
>
> Thanks for responding. Does this mean that there is no way to print
> directly to a printer? I have been unable to find even one reference to
> printing hardcopy in any of the 3 rebol books I have or on the rebol
website.
> Here is my dilemma: we have a database that holds data of donations to
our
> non-profit organization. I have made a program to create a receipt for
> each donation, and email it to the donor. Problem: some donors don't
have
> email addresses. To them I must print out a receipt on paper. Also, I
> need to be able to print out mailing labels.
<<quoted lines omitted: 19>>
> > > There doesn't seem to be much in the archives about printing to a real
> > > printer (in my case a HP LaserJet III). I found the following
code from
> > > Andrew, but I can't seem to get it to work. Perhaps my problem is
that my
> > > printer is on port lpr2:
> > >
> > > I thought that I had this figured out once, but I can't seem to
find the
> > > script that used it.
> > >
> > > I'm using Windows 2000, but also would like to do it running under
Linux.
> > >
> > > For my particular need right now I want to print plain text
directly to
> >the
> > > printer. I would rather not have to make html or pdf files first.
<<quoted lines omitted: 4>>
> > > >Philippe wrote:
> > > > > I want to know if it's possible to user a printer from a rebol
program
> >?
> > > >
<<quoted lines omitted: 32>>
> > > >
> > > >It works OK on Windows PCs. For other computers, you might have
to change
> > > >the %//PRN to something else.
> > > >
<<quoted lines omitted: 24>>
> [rebol-request--rebol--com] with "unsubscribe" in the
> subject, without the quotes.
++++++++++++++++++++++++++++++++++++++++++++
Alessandro Manotti
Presidente dell'Associazione "RIUSA"
Sito web: http://riusa.apritisesamo.net
email: [riusa--email--it]
mailing-list: [riusa-ml--yahoogroups--com]
Telefono: 347.63.43.231
--
Prendi GRATIS l'email universale che... risparmia: http://www.email.it/f
Sponsor:
Cambia le casse del tuo Pc! Scegli i potentissimi speaker Hercules XPS510
Qualit=E0 elevata e costo contenuto!
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=360&d=18-4
[27/32] from: ronald:free at: 18-Apr-2002 12:36
This script was sent a time ago, but it works well on my W98 SE system
REBOL [
Title: "Auto printing via Browser."
File: %"HTML Print.r"
Author: "Andrew Martin"
eMail: [Al--Bri--xtra--co--nz]
]
File: %PrintMe.html
text: "Ceci est une tentativ d'impression..."
write File rejoin [{
<HTML>
<HEAD>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
self.print();
</SCRIPT>}
text
{</BODY>
</HTML>
}]
browse File
HIH
--
Amitiés,
Ronald
[28/32] from: ammon:rcslv at: 18-Apr-2002 14:18
you can even go as far as placing "window.close()" (without the quotes) after
the "self.print()" to have the document close itself when it is printed. ;-))
Enjoy!!
Ammon
A short time ago, Ronald Gruss, sent an email stating:
[29/32] from: ronald:free at: 19-Apr-2002 0:43
Bonjour Ammon,
Thursday, April 18, 2002, 11:18:40 PM, vous avez écrit:
AJ> you can even go as far as placing "window.close()" (without the quotes) after
AJ> the "self.print()" to have the document close itself when it is printed. ;-))
AJ> Enjoy!!
AJ> Ammon
AJ> A short time ago, Ronald Gruss, sent an email stating:
>> This script was sent a time ago, but it works well on my W98 SE system
>>
<<quoted lines omitted: 25>>
>>
>> HIH
I'm not the author of this script that I retrieved in my mail client
archive ; thanks to Andrew Martin !!
I tried your tip, but it does'nt work : the browser asks if I want the
window to be closed, but no printing in that case !!
--
Regards,
Ronald
[30/32] from: izkata:aol at: 18-Apr-2002 20:45
Sorry, the HTML tags aren't showing.
This is it with * instead of > and < :
(I don't know the symbols to make the appear)
printer: func [
text [file! string!]
][
if file? text [text: read text]
write %printing.html rejoin [{*HTML*
*BODY onLoad=window.print*
} text {
*/BODY*
*/HTML*
]
[31/32] from: ammon:rcslv at: 19-Apr-2002 11:51
I haven't done java for a while but here is a shot in the dark at what might
need to happen, insert between "self.print()" and "window.close()" ,
wait(5)
note that you may vary the number in parentheses to vary the length
of the wait.
HTH
Ammon
A short time ago, Ronald Gruss, sent an email stating:
[32/32] from: ronald:free at: 20-Apr-2002 4:04
Hi Ammon,
Friday, April 19, 2002, 8:51:06 PM, vous avez écrit:
AJ> I haven't done java for a while but here is a shot in the dark at what might
AJ> need to happen, insert between "self.print()" and "window.close()" ,
AJ> "wait(5)" note that you may vary the number in parentheses to vary the length
AJ> of the wait.
AJ> HTH
AJ> Ammon
Thanks Amon, works fine now !
--
Best regards,
Ronald
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted