Skip to main content
Participant
July 21, 2008
Question

Understanding Post Script

  • July 21, 2008
  • 5 replies
  • 1764 views
Hi,
We have so many programs written in Post script by previous developers,10 years ago.right now we are trying to understand what is been written in those programs and trying to reengineer them with latest programming language. in that process our big hurdle is understanding the existing code.because we have no post script knowledge at all . i would like to hear from anybody who can help me in guiding what my best bets would be, either to learn post script language or are there any tools which can convert them to a popular language or any debugger to understand the code.
This topic has been closed for replies.

5 replies

Participant
December 5, 2008
Hi, I'm trying to create an environment on my laptop where I can preview direct postscript onscreen. I have tried installing ghostscript using macports 1.6 in x11 and get a type 1 error when i input the sudo install ghostscript command. Anyone have a clue what to do?

Maybe the problem is its 10.4.11 and not intel?
Participant
July 24, 2008
Aandi,
Thank you so much for showing me the right direction.you are right our post scripts are processed by different program. so now at lease we know where to unplug to get rid of these post scripts . Thank you once again for your help.
Participant
July 22, 2008
Hi Aandi,

Thanks for your reply . But we have tried removing this Post script and the result was not as expected. so understood that they are not comments. we used post scripts in our report generation to get certain outputs .we are trying to get rid of this post scripts and also at the same time maintain for the current production use.so in our maintaining activity we have follwoing problem .

we have a form with post script embedded to it,which i gave below.what our understanding is ,this post script creates a box.then we send the text from input file,which will be displayed inside the box.we think that the box is taking relative position to the top left corner of the page.right now we are trying to place a static text at top corner of the page.but by doing that.if my input file not passing the text for the box.my new static text is disappearing .

So, we are trying to understand this post script, so that we can locate what is the starting position that is tied up with this box display. We might need to change the position so that our new static text at the top of the form should be stick to one place.


The post script is -

%PS mark 0.5 setlinewidth currentpoint

%PS 22 1 50 {dup 0 0 t! (B) eq {20 99 t! show crlf}{exit}ifelse }for

%PS dup 22 ne{3 1 roll gsave

%PS currentpoint -6 8 translate 4 -2 roll moveto currentpoint exch pop 546 exch lineto

%PS dup 546 exch lineto lineto closepath stroke grestore

%PS 22 sub 12 mul}{pop pop pop 0}ifelse

%PS currentpoint

%PS 26 1 49 {dup 0 0 t! (D) eq {20 99 t! show crlf}{exit}ifelse }for

%PS dup 26 ne{3 1 roll gsave

%PS currentpoint -6 8 translate 4 -2 roll moveto currentpoint exch pop 546 exch lineto

%PS dup 546 exch lineto lineto closepath stroke grestore

%PS 26 sub 12 mul}{pop pop pop 0}ifelse

%PS add neg 0 exch translate

%PS cleartomark

if you can help us explain what this post script does and explain where we can modify to achieve our requirement,that would be great.
Participating Frequently
July 22, 2008
>Thanks for your reply . But we have tried removing this Post script and the result was not as expected. so understood that they are not comments.

Please believe me when I say that % is a comment in PostScript. I
don't often say this, but I DO know what I am talking about.

However, your "PostScript" files are processed by a program. It is
likely that it uses %PS as some kind of escape, and removes it. I
recommend reading the program (not the PostScript) to find out how
these are handled.

Until you know exactly what is done to process these lines into a
print or other file, it is probably not a good idea to touch them.

>So, we are trying to understand this post script, so that we can locate what is the starting position that is tied up with this box display.

PostScript has a transformation matrix which is used to map all
coordinates. Without looking at the entire context of the print
stream, rather than these few lines, it is not possible to know what
the co-ordinates mean.

Aandi Inston
Participating Frequently
July 22, 2008
>.right now we are trying to understand what is been written in those programs and trying to reengineer them with latest programming language.

PostScript has not changed, the PostScript doesn't need updating
unless it is badly written (which you probably aren't yet in a
position to judge) or doesn't do it's job any longer.

> or are there any tools which can convert them to a popular language or any debugger to understand the code.

There is a debugger for PostScript. My company sells it, in fact. It
is limited to level 2 PostScript, but the chances are 10 year old code
will be level 2.

Some useful background on PostScript
* PostScript is a programming language understood by some printers
* 99.99% of PostScript files are not written by programmers, but
automatically written by software such as print drivers.

I am interested in your idea of "converting to a popular language".
PostScript is a programming language, certainly, but one with a
special purpose. It is the language understood by PostScript printers.

So, in a typical scenario, this PostScript is understood by your
printer(s). Your printer probably doesn't understand anything else, so
conversion isn't an option.

Conversion to PDF is a possibility, if that is more helpful for you.
PDF is designed for both viewing on screen and printing but note the
following:
* PDF is NOT a language, but a graphical file format
* You do not edit PDF files, So you would still absolutely want to
keep the PostScript, and learn PostScript, for any future changes.
Think of them as the raw and compiled program, source code and exe, if
that helps.
* PDF files are generated from PostScript automatically using Acrobat
Distiller.

If this doesn't point you in the right direction for your project, it
would probably be best to discuss the purpose of the files: what is
done with these PostScript files in your workflow, in your
organisation?


Aandi Inston
Participant
July 21, 2008
i even installed "GhostView" to see the result. but no luck in it. since my programs looks like below,output was empty page.

%PS mark 0.5 setlinewidth currentpoint
%PS 22 1 50 {dup 0 0 t! (B) eq {20 99 t! show crlf}{exit}ifelse }for
%PS dup 22 ne{3 1 roll gsave
%PS currentpoint -6 8 translate 4 -2 roll moveto currentpoint exch pop 546 exch lineto
%PS dup 546 exch lineto lineto closepath stroke grestore
%PS 22 sub 12 mul}{pop pop pop 0}ifelse
%PS currentpoint
%PS 26 1 49 {dup 0 0 t! (D) eq {20 99 t! show crlf}{exit}ifelse }for
%PS dup 26 ne{3 1 roll gsave
%PS currentpoint -6 8 translate 4 -2 roll moveto currentpoint exch pop 546 exch lineto
%PS dup 546 exch lineto lineto closepath stroke grestore
%PS 26 sub 12 mul}{pop pop pop 0}ifelse
%PS add neg 0 exch translate
%PS cleartomark
Participating Frequently
July 22, 2008
>%PS mark 0.5 setlinewidth currentpoint

In PostScript, % is the start of a comment. The comment runs to the
end of the line. So your program contains nothing but comments - and
hence, is blank!

It is common to put

%!

on the first line of a PostScript file, alone, which tells some
utilities that this is PostScript.

Aandi Inston