r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Postscript] Emitting Postscript from REBOL

Henrik
24-Jun-2008
[1732x9]
http://rebol.hmkdesign.dk/files/system-print.png
It supports currently print to file, print to LPT, print to Ghostscript, 
print to screen (as in screenshot), print to ethernet printer and 
to a custom network printer server made in REBOL for some simple 
printer sharing.
There is also a print queue system, which you can opt to use, if 
you don't want to print directly.

http://rebol.hmkdesign.dk/files/system-print-queue.png
you feed a postscript layout through a parser, which fills in dynamic 
values and then it's run through postscript.r and then it's fed through 
system-print to the appropriate printing method.
the first part can probably be replaced with your own stuff
the downside with this system is that I'm still not using straight 
native windows printing. the good side is that it offers many alternative 
solutions for printing.
it is largely oriented towards use on Win98/XP.
I can release the code for you, if you're interested.
another advantage is that it's fairly simple to add a new method. 
it took 20 minutes to add Ghostscript printing via the win32pr driver 
and when it was added, I could print anything, which is a nice thing 
about this abstraction.
Graham
24-Jun-2008
[1741]
so does using %//prn work any better than using echo??
Henrik
25-Jun-2008
[1742]
I don't know. I don't have the HP1200 anymore. :-)
Anton
14-Oct-2008
[1743]
Can you put images into postscript ?
Henrik
14-Oct-2008
[1744x2]
yes, jpg, gif, bmp and I believe png is also supported.
but not image! yet
Anton
14-Oct-2008
[1746x3]
Well we can save/bmp
So you could use  save/bmp #{} to-image face
for those faces which have DRAW blocks, as a temporary measure.
Henrik
14-Oct-2008
[1749x2]
so it saves it as a bmp in memory?
I was wrong. There is image! support, although this was not brought 
out in the dialect (strange). Problem is right now that Ghostscript 
refuses to display postscripts with images from to-postscripts.
Anton
14-Oct-2008
[1751x3]
Yes, it saves as a bmp bitmap in the binary specified, so no need 
for intermediate file.
Geomol's dialect allows image! but you have to reference it by a 
word (no direct reference).
(Never mind the save/bmp thing.)
Geomol
14-Oct-2008
[1754]
:-) Good to see some being done in this area. If you have ideas for 
the postscript dialect
http://home.tiscali.dk/john.niclasen/postscript/postscript.r
, let me know.


Documentation: http://home.tiscali.dk/john.niclasen/postscript/postscript.html
Anton
14-Oct-2008
[1755]
Ah docs by the author.. :)
Geomol
14-Oct-2008
[1756]
Yeah, that's rare, isn't it! ;P
Anton
14-Oct-2008
[1757x2]
write/binary %test-image.ps postscript [DeviceRGB [translate 10x10 
scale 72x72 image help.gif]]
I can see the help.gif image, in colour, at the bottom of the page, 
using kghostview.
Geomol
14-Oct-2008
[1759]
I can too using Preview under OS X.
Anton
14-Oct-2008
[1760]
Hmm.. what's the height of the page ?  I want to put the image at 
the top.
Geomol
14-Oct-2008
[1761x2]
Paper sizes in postscript:
A4: 595x842
A5: 420x595
Letter: 612x792
You can also use the command "switchy" to switch y-axis. See last 
command in the docs.
Anton
14-Oct-2008
[1763x2]
Aha, that's useful for what Henrik's doing.
I suppose actually I should ignore the page size.
Geomol
14-Oct-2008
[1765x3]
The whole page will be upside down, it seems, also the graphics. 
That can prob. be fixed with some transformation.
I think, if you write code, that'll produce postscript output, you 
have to know the paper size. At least the last step has to know. 
I see postscript as a language, where you have full control over, 
what you get on the paper.
In contrast to e.g. HTML, where it's up to the browser, how it'll 
look.
Anton
14-Oct-2008
[1768x10]
This talks about page size.
http://alumni.media.mit.edu/~szummer/postscript/
How to generate portable Postscript
Do not explicitly specify paper format. 
 Unfortunately, many programs 
force you to select a paper size. Often, it can be edited out of 
the Postscript file. Instead, let the printer decide whether it can 
print a document with specific dimensions.
It's an old document, from 2000, though...
I'm just wondering what the default page size is, when it's not specified.
pagesize: 595x842  ; Default A4 page size
img: help.gif
offset: 0x0

write/binary %test-image.ps postscript compose/deep [DeviceRGB [translate 
(as-pair offset/x pagesize/y - offset/y - img/size/y) scale 36x36 
image img]]
kghostview test-image.ps  shows the help.gif image just down a little 
bit from the top-left of the page. I suppose it's a margin of some 
sort.
Hmm.. if I have
	offset: pagesize - img/size

then it shows the image just a little left of bottom-right corner 
of page.
Another margin ?
Anyway... just a little dabble in the postscript world..
Henrik
14-Oct-2008
[1778x2]
the only problem with switchy is that everything is upside down, 
inclusing text.
Geomol, I've added direct support for image! in the postscript dialect. 
It seemed appropriate to do.
Geomol
14-Oct-2008
[1780]
Henrik, I can see, there's a bit difference in our versions. Maybe 
we should merge at some point? Image is in both our versions though.
Henrik
14-Oct-2008
[1781]
I was editing 0.4.3 from February 2008. Is yours newer?