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 Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reusable Content Caching: 2 eps files in 1 ps file

Status
Not open for further replies.

themurph

Programmer
Dec 2, 2004
2
US
The following works just fine when IDForm1 is called
further in the program. (thanks Mr. Greer for that
great article on your site).

------------------------------------------------------
/ImageData
currentfile
<< /Filter /SubFileDecode
/DecodeParms << /EODCount 0 /EODString (*EOD*) >>
>> /ReusableStreamDecode filter
[[[[ eps1 here ]]]]
*EOD*
def
/IDForm1
<< /FormType 1
/BBox [0 0 1224 792]
/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
------------------------------------------------------

But what if I want to include 2 EPS files? How and
where would I define the block for IDForm2?

I tried just copying the block above and renaming
to IDForm2, but my pdf creator bombs when it hits the
second call IDForm2 call..

Any pointer would be great... any code would be even better.

I checked a good bit of post history here and saw this
issue discussed, but I'm having a devil of a time getting any code to actually run...

Thanks,
Chris M.
 
You not only have to define a second form, you also have to create a second Resuable Stream.

Copy that code block you have above.

Rename "ImageData" to "ImageData2"

Rename "IDForm1" to "IDForm2".

In the form's PaintProc, change "ImageData" to "ImageData1"

Code:
% First EPS:
/ImageData
currentfile
<< /Filter /SubFileDecode
   /DecodeParms << /EODCount 0 /EODString (*EOD*) >>
>> /ReusableStreamDecode filter
[[[[ eps1 here ]]]]
*EOD*
def
/IDForm1
<< /FormType 1
   /BBox [0 0 1224 792]
   /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

% Second EPS:
/ImageData2
currentfile
<< /Filter /SubFileDecode
   /DecodeParms << /EODCount 0 /EODString (*EOD*) >>
>> /ReusableStreamDecode filter
[[[[ eps1 here ]]]]
*EOD*
def
/IDForm2
<< /FormType 1
   /BBox [0 0 1224 792]
   /Matrix [ 1 0 0 1 0 0]
   /PaintProc
   { pop
       /ostate save def
         /showpage {} def
         /setpagedevice /pop load def
         ImageData2 0 setfileposition ImageData cvx exec
       ostate restore
   } bind
>> def

That should do the trick.

You can thank me for that article by clicking some of the ads on my site!



Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
Works like a charm! Heading to click after this post :)

Here's a related follow-up question:

I am using the ps2pdf.bat file included with ghostscript for windows (ver 8.14) to distill the ps files I am producing. I would have thought that using a reusable content cache in the ps file, that the resulting PDF produced would not be much larger than the ps file.. but the resulting PDF is actually over 4 times larger than the PS file... which leads me to think it is writing out the forms every occurrence instead of caching them.

It was my understanding that PDF would cache the form data in a similar way that the PS file does and prevent such large filesize escalation.

On a whim, I just checked.. and strangely enough, when I distill using Adobe's Distiller.. the resulting PDF is much much smaller (and is produced much mush faster too).

Not sure what I may be missing here.. mabye I need to feed some sort of flags to ghostscript to achieve the same optimization as Distiller?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top