×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Running Multiple EPS files in one PS File

Running Multiple EPS files in one PS File

Running Multiple EPS files in one PS File

(OP)
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.

RE: Running Multiple EPS files in one PS File

(OP)
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.

RE: Running Multiple EPS files in one PS File

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
http://www.tgreer.com

Providing PostScript & PDF
Training, Development & Consulting

RE: Running Multiple EPS files in one PS File

(OP)
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.
 

RE: Running Multiple EPS files in one PS File

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
http://www.tgreer.com

Providing PostScript & PDF
Training, Development & Consulting

RE: Running Multiple EPS files in one PS File

(OP)
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     

RE: Running Multiple EPS files in one PS File

(OP)
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
   ..
    

RE: Running Multiple EPS files in one PS File

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
http://www.tgreer.com

Providing PostScript & PDF
Training, Development & Consulting

RE: Running Multiple EPS files in one PS File

(OP)
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

RE: Running Multiple EPS files in one PS File

(OP)
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

RE: Running Multiple EPS files in one PS File

(OP)
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

RE: Running Multiple EPS files in one PS File

(OP)
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

RE: Running Multiple EPS files in one PS File

(OP)
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.

RE: Running Multiple EPS files in one PS File

(OP)
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.  

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close