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

World: r3wp

[Postscript] Emitting Postscript from REBOL

Henrik
7-Apr-2006
[241x2]
I need to output tables and text at specific locations as well as 
bar codes
straight lines, boxes
Graham
7-Apr-2006
[243]
that should be very easy to do with a postscript dialect.
Henrik
7-Apr-2006
[244]
managing line thickness is going to be important, but that may not 
be so hard
Graham
7-Apr-2006
[245x2]
thickness?
of lines, or text, or what?
Henrik
7-Apr-2006
[247x2]
of lines
I've seen a problem with a barcode reader that could not read codes 
printed from one expensive printer and it would read them fine if 
printed from another cheap printer
Graham
7-Apr-2006
[249]
line thickness can be specified in both ps and view.
Henrik
7-Apr-2006
[250]
turned out the expensive printer was able to separate two parallel 
lines just by a hair's width, where they should appear as a single 
line at double width of one line. that made the barcodes unreadable.
Graham
7-Apr-2006
[251x2]
that was bad programming.
it relied a printer deficiency to work.
Henrik
7-Apr-2006
[253x2]
I didn't discover the error until I tried it on the expensive printer. 
besides the size and position of the line was supposed to be correct. 
the barcode was created with PDF Maker
and it looks correct when viewed in a PDF Viewer
Graham
7-Apr-2006
[255]
even when you drill down on the bars to high resolution?  Remember 
screen res is only 72 dpi .. lower than your cheap printer.
Geomol
7-Apr-2006
[256]
PS has setlinewidth, and setting it to 0 will make is as thin, as 
the device can do.
Graham
7-Apr-2006
[257x4]
John, before we go further in developing this, I would like to know 
what license is going to be applied.  I note that yu have copyright 
nicomsoft in the header.
I think it would be good if someone could produce some draw scripts 
of varying difficulty, and then we can see how far we can get in 
rendering these to ps.
easiest might be some text and lines .. then boxes, circles, fills 
.. then gradient fills etc.
like a test suite for any dialect that is written.
Geomol
7-Apr-2006
[261x4]
Funny, I was just thinking about that. I think, I'll just make the 
first dialect being a small subset of PS, and then license can be 
the one, Carl talked about in a blog. Was it BSD?
Free for all use.
We could then put it in the Library, and others can develop it further. 
(Maybe that should be coordinated somehow?)
Is that ok?
Henrik
7-Apr-2006
[265x3]
graham, even if I take a good PDF viewer and zoom all the way in
so it's probably a problem with the printer, but still one that should 
be solvable by setting the width of the line jsut a few hair's width 
thicker
geomol, BSD license is yummy. please proceed. :-)
Graham
7-Apr-2006
[268x2]
BSD is good.
I've only done bar code printing using bar code fonts .. not directly 
in pdf-maker.
Henrik
7-Apr-2006
[270x3]
http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=ean13.r
<--- did this one a year ago. it uses PDF maker to generate barcodes
it can also generate bitmapped barcodes. works only with EAN13 format 
though
hmm... seems I forgot to upload the version that actually can use 
PDF Maker :-)
Geomol
7-Apr-2006
[273x2]
New version! Try:
do http://home.tiscali.dk/john.niclasen/postscript/postscript.r
print postscript [page [path [linewidth 10 at 72x72 box 72 72]]]
I only test it on the screen under MacOS, where there is an automatic 
converter. Can someone test it on a PS printer?
Henrik
7-Apr-2006
[275x2]
how do you convert it? I can't make preview.app read it
ah, problem fixed
Geomol
7-Apr-2006
[277x3]
I do:

write %test.ps postscript [page [path [linewidth 10 at 72x72 box 
72 72]]]
and then open test.ps with Finder.
ok :)
Maybe box shouldn't be inside a path block, but be an instance of 
itself?
Henrik
7-Apr-2006
[280]
I have no idea...
Geomol
7-Apr-2006
[281]
What is best?
page [path [at 72 72 box 100 100]]
or 
page [box 72 72 100 100]
Henrik
7-Apr-2006
[282]
the first one is most readable
Geomol
7-Apr-2006
[283]
Try:
do http://home.tiscali.dk/john.niclasen/postscript/postscript.r

write %test.ps postscript [page [linewidth 5 path [setgray 0.5 at 
72.5 72 boxfill 72 72]]]
Henrik
7-Apr-2006
[284]
wonderful!
Geomol
7-Apr-2006
[285]
I guess, linewidth mean nothing in that example and can be left out. 
Sorry about that!
Henrik
7-Apr-2006
[286]
I wonder if it's possible to flip the coordinate system to match 
that of DRAW
Geomol
7-Apr-2006
[287]
I read something about that...
Graham
7-Apr-2006
[288x3]
draw starts 0x0 at bottom left ?
you can write postscript functions that translate from one coordinate 
to another.
PostScript normally uses units of "points" for placing graphics on 
the page. I find it more convenient to work with centimeters. I got 
the following snippet of PostScript code from a public domain program 
called "GLE" which I believe is available at any large ftp site; 
I recommend this graphics program. By examining the PostScript output 
of that program I collected the following piece of PostScript code:


matrix currentmatrix /originmat exch def /umatrix {originmat matrix 
concatmatrix setmatrix} def [28.3465 0 0 28.3465 10.5 100.0] umatrix


What this basically does is rescale the page so that now all following 
commands will work as if the centimeter is the basic unit of length. 
This places (0,0) near the bottom left of the page and (21,24) near 
the top right of the page.


If you don't do this, then (0,0) is the bottom left corner of the 
page and (612,792) is the top right corner of the page (if you are 
using an 8 1/2 inch by 11 inch sheet of paper). These are the default 
PostScript units; 72 of these to an inch. 28.3465 to a centimeter, 
thus the numbers above in the last line of PostScript code.