Printing with Rebol on Windows network
[1/9] from: al::bri::xtra::co::nz at: 21-Aug-2002 9:19
Printing with Rebol on Windows network
I've been exploring how to print over a Windows 2000 network, and have just managed to
get it work. Here's an example of printing to a local printer (printer attached directly
to computer running Rebol):
write/binary %//prn read/binary %Test.txt
Note the two "//" for the local printer, and the "magic" value of "prn" ("lpt1" and others
are magical). And here's an example of printing to a network printer:
write/binary %/Media/Corridor read/binary %Test.txt
For the second example, your file name will obviously differ. The best way I've found
so far for determining the file name of the network printer is to use the Windows Explorer
program, browse into "My Network Places", "Entire Network", "Microsoft Windows Network",
then work group, and then computer. There should be one or more printer icons showing.
Click on one, and in the description vertical bar is the file name. For our network,
that comes up with:
\\Media\Corridor
For Rebol, that changes to the file! value:
%/Media/Corridor
CAUTION: It's best to use a test file that consists of two or more pages of text. I discovered
that my local printer (Canon BJC-255) would ignore anything less than a page of text
and do nothing!
Note that Windows printers require CR and LF to be sent for the end of line; newline.
If you must print directly from Rebol, you'll need to replace/all of the newline values
in your text with these values.
Andrew Martin
Posting from School/Work.
[2/9] from: louisaturk:coxinet at: 21-Aug-2002 8:33
Andrew,
At 09:19 AM 8/21/2002 +1200, you wrote:
>Printing with Rebol on Windows network
>I've been exploring how to print over a Windows 2000 network, and have
<<quoted lines omitted: 3>>
>Note the two "//" for the local printer, and the "magic" value of "prn"
>("lpt1" and others are magical).
Thanks! Simple enough. I've just tested this on my win2k machine, and it
works for me too (with a few problems).
>And here's an example of printing to a network printer:
> write/binary %/Media/Corridor read/binary %Test.txt
<<quoted lines omitted: 11>>
>of text. I discovered that my local printer (Canon BJC-255) would ignore
>anything less than a page of text and do nothing!
Same experience here.
>Note that Windows printers require CR and LF to be sent for the end of
>line; newline. If you must print directly from Rebol, you'll need to
>replace/all of the newline values in your text with these values.
How are you doing this?
>Andrew Martin
>Posting from School/Work.
Please post anything else you learn about this.
Louis
[3/9] from: sisbro:pipo at: 21-Aug-2002 18:48
Content-Type: Text/Plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi=0D
=0D
Just for information, you can use RPV with rebol to generate more complex
document=0D
http://www.rpvreport.com/=0D
=0D
See ya=0D
=0D
Jerome
-- Binary/unsupported file stripped by Listar --
-- Err : No filename to use for decode, file stripped.
-- Type: image/gif
[4/9] from: brian:hawley at: 21-Aug-2002 18:27
At 08:33 AM 8/21/02 -0500, Louis Turk wrote:
>Andrew,
>At 09:19 AM 8/21/2002 +1200, you wrote:
<<quoted lines omitted: 3>>
>>replace/all of the newline values in your text with these values.
>How are you doing this?
write/with %somefile "somedata" "^M^/"
or you could use "^(0D)^(0A)", it means the same thing.
Brian
[5/9] from: gschwarz:netconnect:au at: 22-Aug-2002 17:12
A thought for the list. (I know you can not do this in Rebol.)
To print html pages to a printer eg. invoices, group letters....
Rebol saves a html file to a folder called "printing".
A program (written in java, VB..) running in the background looks in this
folder for html files to print then deletes the file.
This program got look every few seconds to print any html files then goes to
sleep until the next read.
In this folder would also be a settings file (settings.txt) to store the
margins and printer to use.
printer = hp4000
magin-top = 0.5"
magin-bottom = 0.5"
margin-right = 0.5"
margin-left = 0.5"
Below is a link to a java software which can do it, I think. Would there be
a use in for something like this?
http://www.codebase.com/products/javaprint/?src=google_aws&id=PRINT
Regards,
Greg
----- Original Message -----
From: <[al--bri--xtra--co--nz]>
To: <[rebol-list--rebol--com]>
Sent: Wednesday, August 21, 2002 7:19 AM
Subject: [REBOL] Printing with Rebol on Windows network
> Printing with Rebol on Windows network
>
> I've been exploring how to print over a Windows 2000 network, and have
just managed to get it work. Here's an example of printing to a local
printer (printer attached directly to computer running Rebol):
> write/binary %//prn read/binary %Test.txt
>
> Note the two "//" for the local printer, and the "magic" value of "prn"
("lpt1" and others are magical). And here's an example of printing to a
network printer:
> write/binary %/Media/Corridor read/binary %Test.txt
>
> For the second example, your file name will obviously differ. The best way
I've found so far for determining the file name of the network printer is to
use the Windows Explorer program, browse into "My Network Places", "Entire
Network", "Microsoft Windows Network", then work group, and then computer.
There should be one or more printer icons showing. Click on one, and in the
description vertical bar is the file name. For our network, that comes up
with:
> \\Media\Corridor
>
> For Rebol, that changes to the file! value:
> %/Media/Corridor
>
> CAUTION: It's best to use a test file that consists of two or more pages
of text. I discovered that my local printer (Canon BJC-255) would ignore
anything less than a page of text and do nothing!
> Note that Windows printers require CR and LF to be sent for the end of
line; newline. If you must print directly from Rebol, you'll need to
replace/all of the newline values in your text with these values.
[6/9] from: al:bri:xtra at: 22-Aug-2002 19:44
Andrew wrote:
> > Note that Windows printers require CR and LF to be sent for the end of
line; newline. If you must print directly from Rebol, you'll need to
replace/all of the newline values in your text with these values.
Louis wrote:
> How are you doing this?
At the moment, by doing something like this:
Pages: rejoin [
; A whole lot of lines...
"Blah blah blah..." newline
"^(page)" ; Page feed code.
; A whole lot of lines...
"Blah blah blah..." newline
"^(page)" ; Page feed code.
]
; Rebol converts 'newline to CRLF automatically in 'write.
write %Test.txt Pages
; ...and then print to printer:
write/binary %//prn read/binary %Test.txt
I'm using the above method at the moment, because I'm still testing and
writing reports. A better method that doesn't use the temporary file is
something like:
replace/all Pages newline CRLF
write/binary %//prn Pages
Caution: I haven't tested the above script!
Brian wrote:
> write/with %somefile "somedata" "^M^/"
I hadn't thought of that method. That's a good method if one's using a
non-windows PC on the network.
> or you could use "^(0D)^(0A)", it means the same thing.
Rebol has defined CRLF as:
>> crlf
== "^M^/"
I hope that helps!
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
[7/9] from: al:bri:xtra at: 22-Aug-2002 20:24
Greg claimed:
> A thought for the list. (I know you can not do this in Rebol.)
>
> To print html pages to a printer eg. invoices, group letters....
I'll just design a Rebol CGI script, then launch a browser, and print from
that! Here's a script that does just that. It requires my ML and CSS
dialects (and a high school database). This script will print out class
lists of pupils to a browser, and enables the user to choose an appropriate
orientation, and by modifying the URL (or clicking the Back button) change
some parameters appropriately.
Andrew Martin
Rebol *CAN* do that! :)
ICQ: 26227169 http://valley.150m.com/
-><-
#! C:\Rebol\View\rebol.exe -cs
Rebol [
Name: 'ClassList
Title: "Class List"
File: %ClassList.r
Author: "Andrew Martin"
eMail: [Al--Bri--xtra--co--nz]
Web: http://valley.150m.com
Date: 7/August/2002
Version: 1.2.0
Purpose: {Creates class lists for teachers.}
Category: [util net markup 5]
]
Stylesheet: %Wiki.css
Subjects: sort load %/C/Rebol/MUSAC/Subjects.txt
Forms: sort load %/C/Rebol/MUSAC/Forms.txt
Years: sort load %/C/Rebol/MUSAC/Years.txt
Command: all [
"GET" = Rebol/options/cgi/request-method
string? Rebol/options/cgi/query-string
not empty? Rebol/options/cgi/query-string
make object! decode-cgi Rebol/options/cgi/query-string
]
if all [
object? Command
in Command 'Partition
"on" Command/Partition
any [
in Command 'Subject
in Command 'Form
in Command 'Year
]
in Command 'Period
parse Command/Period [digits end]
Command/Period: load Command/Period
in Command 'Points
parse Command/Points [digits end]
Command/Points: load Command/Points
] [
Partition: none
Pupils: load %/C/Rebol/MUSAC/Pupils.txt
Columns: Pupils/1
Rows: Pupils/2
Intersections: Pupils/3
IncludeLeavers: all [
in Command 'Leavers
"on" = Command/Leavers
]
Title: any [
all [
in Command 'Subject
PartitionColumn: index? find Columns to-string Command/Subject/1
Partition: next Command/Subject
]
all [
in Command 'Form
PartitionColumn: index? find Columns "Form"
Partition: Command/Form
]
all [
in Command 'Year
PartitionColumn: index? find Columns "Year"
Partition: load Command/Year
]
"No Assigned Form Class!"
]
TitleValues: [
"Preferred"
"Family Name"
"Form"
]
for TitleValue 1 length? TitleValues 1 [
change at TitleValues TitleValue index? find Columns
TitleValues/:TitleValue
]
Class: make block! 500
any [
Partition
Partition: ""
]
StatusColumn: index? find Columns "Status"
for Row 1 length? Rows 1 [
if all [
Partition = select Intersections make pair! reduce
[PartitionColumn Row]
Status: select Intersections make pair! reduce [StatusColumn
Row]
any [
#"F" = Status
#"P" = Status
all [
IncludeLeavers
#"L" = Status
]
]
] [
foreach TitleValue TitleValues [
append Class select Intersections make pair! reduce
[TitleValue Row]
]
]
]
sort/skip/compare Class 3 2
content-type 'text/html
print newline
print ML compose/deep [
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
html [
title (Title)
style/type/media "text/css" "screen,print" [
"<!--^/"
(
CSS compose/deep [
[h1 p table] [
margin: 0 px
]
td [
font-size: (Command/Points) pt
margin: 0 px
]
td.Grid [width: 1.5 em]
p + h1 [page-break-after: always]
]
)
"//-->"
]
]
body [
h1 (Title)
(
use [Row Rows] [
Rows: make block! 2 * 500
Row: make block! 100
foreach TitleValue TitleValues [
append Row compose [
th (Columns/:TitleValue)
]
]
loop Command/Period [
append Row compose [th/class "Grid" (" ")]
]
append Rows reduce ['tr Row]
while [not empty? Class] [
Row: make block! 100
for TitleValue 1 length? TitleValues 1 [
append Row compose [
td (Class/:TitleValue)
]
]
loop Command/Period [
append Row [td/class "Grid" " "]
]
repend Rows ['tr Row]
Class: skip Class length? TitleValues
]
compose/deep [
table/border/bordercolor/cellspacing 1 "black" 0 [
(Rows)
]
]
]
)
p [
b "Number of Pupils" ": " (/ length? head Class length?
TitleValues) "."
]
]
]
quit
]
Title: Rebol/script/header/Title
Idn: "Partition"
content-type 'text/html
print newline
print ML compose/deep [
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
html [
head [
title (Title)
link/rel/type/href "stylesheet" "text/css" (Stylesheet)
script/language "JavaScript" {
function Able (Object) {
document.forms[0].Subject.disabled=true;
document.forms[0].Form.disabled= true;
document.forms[0].Year.disabled= true;
Object.disabled= false;
document.forms[0].Submit.disabled= false;
}
}
]
body [
div/id "Center_Column" [
h1 (Title)
form/method/action "GET" (Rebol/script/header/file) [
fieldset [
legend "Dimensions"
fieldset/style "display: inline" [
legend "Vertical"
p/class "Initial" "Click radio button to select:
input/type/id/name/onclick
radio" (Idn) (Idn)
Able (Subject)
label [
"Subject: " select/name/disabled "Subject"
disabled
[
(
use [Options] [
Options: make block! length?
Subjects
foreach Subject Subjects [
append Options compose [
option (Subject)
]
]
Options
]
)
]
] br
input/type/id/name/onclick "radio" (Idn) (Idn)
Able (Form)
label [
"Form: " select/name/disabled "Form"
disabled
[
(
use [Options] [
Options: make block! length?
Forms
foreach Form_Class Forms [
append Options compose [
option (Form_Class)
]
]
Options
]
)
]
]
label [
input/type/name "checkbox" "All_Forms" "All"
]
br
input/type/id/name/onclick "radio" (Idn) (Idn)
Able (Year)
label [
"Year: " select/name/disabled "Year"
disabled
[
(
use [Options] [
Options: make block! length?
Years
foreach Year Years [
append Options compose [
option (Year)
]
]
Options
]
)
]
]
label [
input/type/name "checkbox" "All_Years" "All"
]
br
]
fieldset/style "display: inline" [
legend "Horizontal"
label [
"Columns: " select/name "Period" [
option/value 0 "None (0)"
option/value 7 "Week (7)"
option/value 14 "Fortnight (14)"
option/value 33 "Subject Term (33)"
option/value 60 "Term (60)"
option/value 24 "Form folder (24)"
]
]
]
fieldset/style "display: inline" [
legend "Font Size"
label [
"Points: " select/name "Points" [
option 6
option/selected "selected" 8
option 10
option 12
option 14
option 16
option 18
]
]
]
]
label ["Include leavers: " input/type/name "checkbox"
Leavers
]
input/type/id/value/disabled "submit" "Submit" "Show
Class List"
"disabled"
]
]
]
]
]
[8/9] from: zokie:libero:it at: 22-Aug-2002 10:27
Hello [al--bri--xtra--co--nz]
On 20-Ago-02, [al--bri--xtra--co--nz] wrote:
> CAUTION: It's best to use a test file that consists of two or more pages
> of text. I discovered that my local printer (Canon BJC-255) would ignore
> anything less than a page of text and do nothing!
My Epson Stylus Color 640 waits until a buffer-overflow or a buffer-flush
command before to dump on paper, I must force a Form Feed to get anything.
Maybe your printer needs it too, try this:
formfeed: to-char tostring #{0C}
write/binary %//prn join read/binary %Test.txt formfeed
plese note: alone formfeed doesn't throw out paper. My printer just ignore
it, I need to print something before to send Form Feed.
Regards
--
"Where did you get all those facts!?!"
[9/9] from: louisaturk:coxinet at: 22-Aug-2002 11:31
Hi Francesco,
At 10:27 AM 8/22/2002 +0200, you wrote:
>Hello [al--bri--xtra--co--nz]
>On 20-Ago-02, [al--bri--xtra--co--nz] wrote:
<<quoted lines omitted: 8>>
>plese note: alone formfeed doesn't throw out paper. My printer just ignore
>it, I need to print something before to send Form Feed.
Thanks! That works on my hp laserjet III also.
Louis
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted