[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Including Lout eps output into Lout documents.

From: Richard Cichelli
Subject: Including Lout eps output into Lout documents.
Date: Thu, 24 Aug 2006 12:06:37 -0400
User-agent: Thunderbird (Windows/20060719)

Dear Dr. Kingston and other friends of Lout,

We are new to trying to use Lout, although we first were intrigued by it in 1993. It seems by far the most elegant tool for what we call batch composition and pagination.

In exploring Lout's functionality for automating the creation of advertising we have run into a situation we don't understand.  We think the way to make some ads is to make up several parts and then assemble them into a complete ad.  Imagine an ad consisting of several houses or cars for sale.  Pictures and text for each might be composed into boxes and then the boxes assembled into an ad.  We would like Lout to help us automate this.

Here is an example of how we get stuck:

Attempting to include an EPS image that was output by Lout inside another lout file doesn't seem to work as we would expect.  This is causing the part of the document that comes after the include to not be displayed.

The following steps:
1) compile the two files that are generating the EPS images:
1. lout -EPS -o bug1.eps bug1.lout
2. lout -EPS -o bug2.eps bug2.lout

2) Compile the document that will include these two images
lout -o document.ps document.lout

3) Open document.ps in a viewer (kghostview)

Once the document opens, only the first included image is being displayed. In document.lout's code, bug2.eps is vertically concatenated with the first image, so the content of bug2.eps is intended to display below bug1.eps.

We tried other PostScript viewers, including GhostScript 8.53, ggv, and evince.  They choked or reported errors. 

We're running lout 3.31, on CentOS Linux 4.3 (a RHEL4 clone).

Are we doing something wrong with LOUT?  Is this a bug?


bug1.lout -
@SysInclude { picture }
@Illustration 6i @Wide 12p @Font { Testing a bug ! The line below this is the second image }


bug2.lout -

@SysInclude { picture }
@Illustration 6i @Wide 12p @Font { This text won't show up because of the bug ! }


document.lout -

@SysInclude { doc }
@Doc @Text @Begin
@LP Text above the error will display.
@LP The next line is the first included image.
@IncludeGraphic { "bug1.eps" }
@IncludeGraphic { "bug2.eps" }
@LP Extra text here just to show you
@End @Text

Thank you for any assistance you might give us.

Richard Cichelli

p.s. Here is the most recent diagnosis by us:

>From William 



When I run the document through gs, I see

$ gs -sDEVICE=nullpage doc.ps
AFPL Ghostscript 8.54 (2006-05-17)
Copyright (C) 2005 artofcode LLC, Benicia, CA.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusRomNo9L-Regu font from /u1/gnu/gs4/fonts/n021003l.pfb... 3008644 1651050 1659712 368087 2 done.
Error: /invalidrestore in --restore--
... stack trace ...
Current file position is 22956
AFPL Ghostscript 8.54: Unrecoverable error, exit code 1

Invalid restore means that the postscript tried to do a restore but the top of stack was not a valid save object.

The byte position that ghostscript reports is between the two lines below in the code immediately after the included copy of bug1 and before the included copy of bug2.

This is not a permanent solution, but I got the files to work by changing the prologs.
In each of the two procsets in the resources, I added a line like
 userdict /LoutGraphic known not {
(where the test uses a variable defined in resource) and then at the end, I added the line
 } if

The resource files are in the lout library directory (defined by LIBDIR in the makefile when you build lout).

The problem was that the LoutStartEPSF before bug1 came from the copy from the prolog of the main document while the LoutEPSFCleanUp after bug1 came from the copy in the prolog of bug1 instead of from the copy in the main document.  The nested LoutEPSFCleanUp fails because it removes itself from the stack.  I confirmed that by editing the document postscript and adding an "x" in the definition like
 /xLoutEPSFCleanUp { % clean up after EPSF inclusion
in the prologs of bug1 and bug2 so the calls at the end of the files use the main copy instead of the nested copy.

I also noticed that the nested bug1 and bug2 eps files both start with
 /pgsave save def
and end with
 pgsave restore
Another problem (that does not show here but could cause problems in more complicated situations) is that the outer postscript also has the same save and restore sequence.  In order to allow arbitrary nesting of eps files, the save object must be stored on the stack instead of inside a variable with a fixed name.  That is what I do in ClassPag to allow ClassPag pages (like square-off blocks) to be embedded inside other pages.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]