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

World: r3wp

[Postscript] Emitting Postscript from REBOL

Geomol
12-Mar-2009
[1902x2]
About scaling images and physical size. I know, the image datatype 
only have size in pixels, and how much is a pixel on paper? It's 
up to the one producing the output to set that. An old measure is 
72 dpi, which is 72 dots per inch. So setting this pixel-to-dot scale 
for images, and the image will be:
(# of pixels / 72) inches in size on paper


I'm not 100% happy with the way, I've implemented the scaling of 
images, and suggestions are welcome.
The more I read and learn about the PDF format, the less fond I am 
of it. It's a bloated mess with some critical limites, as I see it.
Pekr
12-Mar-2009
[1904]
hmm, your pdf example above display dialog box with message: there 
is an error on this page. Acrobat may not display the content correctly. 
Please contact the person, who created the page to remove the problem 
.... (free translation from czech)
Geomol
12-Mar-2009
[1905x2]
In PDF, the only way to get center- and right-aligned text, is to 
know the size of each character in the font, and then calculate the 
starting left position yourself. It seems, all people on the planet 
producing PDF does it this way:
http://www.adobeforums.com/webx/.3bc3e853
Pekr, do you try to open this?
http://www.fys.ku.dk/~niclasen/postscript/pdftest.pdf
Pekr
12-Mar-2009
[1907]
yes, it launches in FF 3.0.4
Geomol
12-Mar-2009
[1908x2]
Maybe encoding? ok, I'll try change encoding. one moment...
Pekr, try reload it again.
Pekr
12-Mar-2009
[1910]
now it's ok ...
Geomol
12-Mar-2009
[1911x3]
Strange, I just tried on my PC, and I get a blank page. It works 
on my Mac. hmm
I think, there a problem. Adobe Reader give an error "Ilegal operation 
'm' inside a text object." on my PC.
Pekr, what version of Adobe Reader do you have installed?
Pekr
12-Mar-2009
[1914]
version 9.0.0 Czech ...
Geomol
12-Mar-2009
[1915x3]
Thanks, I get the error in a version 6.0. Now I have to figure out, 
if I stick to PDF 1.3 standard.
And I don't ... damn! Changes on the way...
I updated:
http://www.fys.ku.dk/~niclasen/postscript/rebps2pdf.r
and http://www.fys.ku.dk/~niclasen/postscript/pdftest.pdf

How does it look now?
Pekr
12-Mar-2009
[1918]
No problems here ...
Geomol
12-Mar-2009
[1919]
The way to do center- and right-aligned text in PDF is to get the 
Font Metrics like these for the 14 standard fonts (see "PDF CORE 
FONT INFORMATION" near the bottom):
http://www.adobe.com/devnet/font/


and calculate the size of the text and then the position. For other 
fonts, you need similar info.
Gabriele
13-Mar-2009
[1920]
Geomol... code to do that has been available for like 6 years...
Geomol
13-Mar-2009
[1921x2]
:-) Do you do it using font metrics in pdf-maker, or is there another 
trick?
Seems like you use font metrics (metrics.bin).
Gabriele
14-Mar-2009
[1923x4]
right, font metrics. Volker wrote a script to parse the .afm files.
You can use metrics.bin, or you can even use my TeX based typesetter, 
as that is completely independent from the PDF Maker.
it needs work, it's quite slow the way it is now, and I need to redo 
the math as the approach I used doesn't work very well (the results 
are good anyway, it's just that there are too many special cases 
in the code).
still... even if you just study the pdf maker you'll learn all you 
need about what you need to do.
Geomol
14-Mar-2009
[1927]
Thanks, Gabriele. I have the info to make those alignments and will 
probably do it next week.
Geomol
16-Mar-2009
[1928]
I made the center- and right-alignment of text for PDF output. See 
Announce!
Geomol
17-Mar-2009
[1929]
Ver. 0.4.7 of PostScript dialect incl. PDF output uploaded:
http://www.fys.ku.dk/~niclasen/postscript/


- I included font widths in rebps2pdf.r instead of separate binary, 
and
- fixed a bug.
Geomol
20-Mar-2009
[1930]
List of printers supporting Level 2 PostScript directly without software 
driver as of 2/2/1998:
http://www.postscript.org/FAQs/language/node95.html
Geomol
2-Jun-2009
[1931x2]
I'm working on a Print Markup Language for a customer, that will 
output the REBOL postscript dialect, so it can produce PostScript 
and PDF output. When producing text, it's possible to specify centered 
and right-aligned text by using the words CENTER or RIGHT after the 
text followed by the size of the area, wherein the text should be 
aligned. Example:

at 100x100 "Right-aligned text" right 400

has the same effect as:

at 500x100 "Right-aligned text" right 0


Suggestion: The dialect will be more simple, if the size is dropped. 
Then the position (from AT) is the right border of the text on the 
output. Same for CENTER, where the position will be the center of 
the text.


I know, Henrik use this dialect. What do you say? If others use this 
dialect, I would like to hear your opinions! If I change this in 
the dialect, it may mean changes to your code.
Because all content in the dialect starts with a word or a string, 
I could make the size optional. It will just mean a more complicated 
dialect, but it won't break your code.
Henrik
2-Jun-2009
[1933x2]
Geomol, did you try my VID->postscript conversion function? It might 
be able to do some of what you need.
it does not do word wrapping however. that's a problem that I've 
not yet solved.
Maxim
2-Jun-2009
[1935]
there is VID manual word-wrapping code in glayout lib if you need 
it.
Henrik
2-Jun-2009
[1936]
interesting. how does it work?
Geomol
2-Jun-2009
[1937]
hm, I remember something about that. I think, I tried it a while 
ago.

But what about the suggestion for a change to the dialect?
Henrik
2-Jun-2009
[1938x3]
http://rebol.hmkdesign.dk/files/vid-postscript2.png
if you drop the position marker, will it be simpler or harder to 
build formatted tables?
oops, size marker, not position marker
Geomol
2-Jun-2009
[1941x3]
It should make no difference. Dropping the size just mean, you need 
to add the size to the possition yourself. The thing is, in my examples 
here, I often know the final right border (pos + size), so I always 
have size set to zero. And then it struck me, that I don't need the 
size.
at 0x0 "some long text that will be right aligned" right 800

is the same as

at 800x0 "some long text that will be right aligned" right
I like the second way better.
Maxim
2-Jun-2009
[1944]
glayout wordwrap functions uses the internal view commands which 
calculate word-wrap.
Henrik
2-Jun-2009
[1945]
Maxim, so they will be identical to what is seen in View instead 
of DRAW?
Maxim
2-Jun-2009
[1946x3]
I was using it specifically to build HUGE tables (300000cells) and 
its deadly fast.
yes.
you can use it to wordwrap draw text too.
Henrik
2-Jun-2009
[1949x2]
this will be useful when I will get to finish the function, perhaps 
in a month or so.
Geomol, I guess it doesn't harm layout capabilities.
Geomol
2-Jun-2009
[1951]
Do you use the RIGHT and CENTER options in the dialect in your code 
today? Would you have to change alot, if I drop the size in the dialect?