Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running Multiple EPS files in one PS File

Status
Not open for further replies.

shussai2

Programmer
Aug 28, 2003
42
CA
Hi,

I am trying to run multiple eps files in a single ps file. These eps files were created by Tkinter (Python) automatically and contain a rendition of a canvas. So, each eps has a graph, calendar rendered in it. I can actually view these in GSView by simply double clicking on them.
Now I want to show two images by scaling and translating them in a ps file. So far, this is my code in my ps file:

%!
%%Title: Sample document
%%Pages: 1
%%EndComments
save
/showpage {} def
10 280 translate
0.8 0.8 scale
(histogram.ps) run
10 -400 translate
(calendar.ps) run
showpage
restore

Although the ps file runs and displays the desired output in GSView, I am still encountering number of problems.

1) When press Print, the printer does not print this ps file, and does not display any errors or warnings either. However, I can print when I convert this single page ps file into an eps format.
2) I want to display more eps files on the other page, but I can't seem to setup a second page.
 
Hi,

I have seen that if I take out the line:

/showpage {} def

from my ps file, printer is able to print the two images in eps files. However, they are printed on two seperate pages which I don't want. Please help.
 
You need to protect the EPS files from EACH OTHER. Modify your code to:

Code:
save
  /showpage {} def
  10 280 translate
  0.8 0.8 scale
  (histogram.ps) run
restore
save
  /showpage {} def
  10 -400 translate
  (calendar.ps) run
restore
showpage

There are a couple of articles on my site that discuss how to use/edit EPS files. If you find this post or my site helpful, you can thank me by clicking some of the ads on my site. Same goes for Tek-Tips, of course.

Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
Hi Mr. Greer,

Thank you for your response. My code actually works thanks to your suggestion. It not only prints but I know now how to setup a second page.

My third question is that do you have an example which can show me how to eliminate run command and literally run the eps file from my ps file. I don't want to copy and paste the code of eps into ps. Is there any way of doing it automatically?

I will definitely click on the ads on your website.
 
If you visit my site, there is an article entited "Reusable Content Caching", which explains how to embed the EPS into your PostScript program, and thus eliminate the "run" operator.

Now you ask, can you get the EPS into your program without copying and pasting it? Well, that's the easiest way. There isn't an "importEPS" operator. You can read the file in, using standard PostScript file i/o, but if you can do THAT, why wouldn't you use "run"? Much easier.

The other approach is to write a program in another language. That program would generate your final PostScript.

In short, copy & paste is easy, but not automatic. And making it automatic, isn't easy.

Let me know if I can be of further assistance.


Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
Hi,

I read your article on "Reusable Content Caching" and used your example as a template. I manually copied and pasted eps code. It worked!!.

I am trying to create a print/preview utility for my program written in Python. As I mentioned earlier, I can generate renditions of my canvases in seperate EPS files. Thanks to you, when I use GSView and use run command, I can display and print from GSView.

However, I want to use my own piece of code written in Python to send a ps file to a printer. The code works when I send a ps which is self-contained meaning it is not calling a run command to load another file. But when I provide it with a ps file with run command, it does not print anything. (I think this due to the unavailablity of interperter). Therefore I used information from your "Reusable Content Caching" article to generated a self-contained ps with eps file copied and pasted in it. It worked.

I think I can write a utility in Python to copy and paste. Though I would like to know how to use postscript I/O to do so. Can you please give me an example.

Regards,

Sajjad
 
Hi Mr. Greer,

I have written my program in python to append eps file to ps file. Now the problem I am facing is that in FormType 1 in my ps file, how do I exclude the /BBox [0 0 612 792] command, so I can just use the %%BoundingBox: 72 150 144 170 comment in the eps file as defined. When I simply erase this line out in FormType1, I get an error.

<< /FormType 1
/BBox [0 0 612 792] --------------> take this line
/Matrix [ 1 0 0 1 0 0]
/PaintProc
..

 
The BBox entry is a required entry in the Form dictionary.

Just make it match the %%BoundingBox DSC comment in the EPS.

Forms are cached for reuse. The interpreter interprets the PostScript, turning it into what's known as a "display list". These are really just primitive shapes, like polygons. The interpreter wants to know how much of the page it needs to account for, thus the BBox entry.

If you want to say "the whole page", then make the BBox entry the same as the EPS Bounding Box.

Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
Hi Mr. Greer,

I am trying to display two images (contained in two seperate EPS files) on one page using your "Reusable Content Caching" template. When I attempt at translating and scaling image 1 in EPS1, the other image in EPS2 is affected too. Which I don't know Why?. I have tried including scale and translate command outside of the form procedure and before the save command. I see the same result. The first image is translated and scaled but the second image is translated and scaled twice (once due to the translate and scale command in preceeding IDform). BBoxes in IDForms are exactly the same values as defined in EPS files %%BoundingBox comments.

EPS1
/IDForm
<< /FormType 1
/BBox [61 263 552 530]
/Matrix [ 1 0 0 1 0 0]
0.55 0.55 scale
450 600 translate
/PaintProc
{ pop
.
.
save
IDForm execform
restore
.
.
/ImageData
currentfile
<< /Filter /SubFileDecode
/DecodeParms << /EODString (*EOD*) >>
>> /ReusableStreamDecode filter
EPS2
.
.
/IDForm
<< /FormType 1
/BBox [72 366 540 720]
/Matrix [ 1 0 0 1 0 0]
0.55 0.55 scale
450 750 translate
/PaintProc
{ pop
.
.
save
IDForm execform
restore

showpage

 
Hi,

Actually this very basic question which I am having trouble with. How do I print a color text string. So for example, I want to print "Hell World" string in colour Blue. I am trying to use setcolor but I keep getting stack error when I open it in GSView.

Regards,

Sajjad
 
Hi Mr. Greer,

I am located in Ottawa, Canada. I am a Systems Engineer in a biomed company here. As you have probably figured out, I am very new to Postscript. I am trying to quickly convert my Python GUI objects into one postscript file and print them.
Actually I have another question, I have a table of text which can continue on to next page or few pages, how do I tell my ps file to divide it into appropriate pages and fit the table correctly.

Regards,

Sajjad
 
That's a much more complex issue. There isn't a really simple answer. You have to measure your position on the page as you draw text, and determine if and when you need to make a new page.

I conduct PostScript training. Email me if you're interested.

Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
Hi Mr. Greer,

I will definitely ask my manager if the company is willing to cover the cost of the training. If so, then I would be happy to participate in your training course.

Regards,

Sajjad
 
Hi,

I am trying to setup a landscape option in my ps file with multiple eps in it. Right now this is what I have:

%!PS
<< /PageSize [792 612] >> setpagedevice
/ImageData
currentfile
<< /Filter /SubFileDecode
/DecodeParms << /EODString (*EOD*) >>
>> /ReusableStreamDecode filter
.
.
.
/IDForm
<< /FormType 1
/BBox [61 263 552 530]
/Matrix [ 1 0 0 1 0 0]
/PaintProc
{ pop
/ostate save def
/showpage {} def
/setpagedevice /pop load def
ImageData 0 setfileposition ImageData cvx exec
ostate restore
} bind
>> def
.

I set << /PageSize [792 612] >> setpagedevice once as the second line of my postscript file. My problem is that in GSView it always shows it as a portrait page setup, and when I print it, it prints as a Portrait. Please help.
 
When I convert the ps file (with landscape option defined) into pdf, the page is displayed as landscape in Acrobat. From Acrobat it prints it as landscape too. Also, I have included a piece of code in my program which directly sends a PS file to the default printer (which can handle PS format). Anyways, it does print in landscape format when directly sent to the PS printer. However, it seems that I would have to place the objects (from each eps file) differently than I do on Portrait. Is there an option in PS to automatically shrink and resize objects to fit landscape.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top