[comp.lang.postscript] Modifying Adobe Illustrator code

edwards@bgsuvax.UUCP (Ken Jenkins) (05/19/91)

I am currently working on a program which will read Adobe Illustrator
files then step, repeat and distort them according to a number of
parameters stored in a database. I work for a company which produces
pressure sensitive labels for the retail packaging trade.  The image
of a single label is created in Illustrator and saved.  These label
images are not just simple text but involve many different fonts,
line art and scanned images.  They are small however, always are
drawn at the bottom/left of document page 1 and are saved to a special
folder on disk.  The program basically goes to the folder, takes each
file, parses the file name to identify the necessary key for database
lookup of step count / spacing / distortion and repeat / count / spacing
and distortion and then processes the file producing a second file which
when sent to the imagesetter results in a negative file image from which
we make a flexographic plate for printing.

 _____________Step distortion %______________
|  STEP-->                                   |

_____________   _____________   _____________  ___                      ^
|           |   |           |   |           |     |                     |
| image 4   |   | image 5   |   | image 6   | -   |                   REPEAT
|           |   |           |   |           |  |  |                     |
-------------   -------------   -------------  |   -Repeat distortion % |
     |--Step spacing--|                  Repeat spacing                 |
_____________   _____________   _____________  |  |
|           |   |           |   |           |  |  |
| image 4   |   | image 5   |   | image 6   | -   |
|           |   |           |   |           |     |
-------------   -------------   ------------- 

Now I know that all this can be done from within Illustrator using various
tools and functions.  But in a production environment, with the number of
die configurations we have (each one with a different set of parameters)
it is much more desirable for the artist to concentrate on getting one
image correct and letting a program batch process a whole folder of single
image files into the final ready-to-create-a-plate version.

I have a program that works and does a fair job.  However...occasionally
I run into problems with some (not all) documents with scanned images placed
in them.  I'm almost certain the problem is in the way I am abusing the
Illustrator document to get what I want.  This is the nature of my question
and plea for help.  Below I have included a "processed" file and although
I have truncated it to save space, enough is there to get the idea from.
Basically I am locating certain reference points in the Illustrator file
and then (quite rudely) inserting things like:

%%BeginDocument:
%%_________________________________________[ DISTORT   ]
 .942575   1  scale
%%______________________________________________________
%%EndDocument

and

%%____________________________________________[ STEP   ]
 162.5784  0 translate       % image :  1 / 1 
%%______________________________________________________
%%EndDocument

Following this (in order to get the additional images) I simple repeat
the Illustrator code which produced the original image over and over.
It works, but there are a few problems. All the images in the processed
document are piled up on top of one another if you load the file back
into Illustrator, even though when the file is printed, they are indeed
where they are supposed to be.  This is because I have not waded into
Illustrator psuedo-code enough to make thing pretty.  And I have trouble
with certain scanned images producing PS error (the offensive .. offending
command most notably).  Of course, like most nasty bugs this one is sporadic
and difficult to reproduce when you want to.

If any of this makes sense to anyone out there and you could suggest
another way of approaching what I'm doing or suggest a commercial product
with the same functionality please follow up or email me edwards@andy.bgsu.edu
and I would be very grateful.  The code which follows is from my existing
program.

%!PS-Adobe-3.0 
%%Creator: Adobe Illustrator(TM) 3.0.1
%%For: (Dr. Digital) (Intergalactic Peace Keeping Force)
%%Title: (\245Sample/597876/A-1)
%%CreationDate: (5/18/91) (5:51 PM)
%%BoundingBox: 39 59 251 218
%%DocumentProcessColors: Cyan Magenta Yellow Black
%%DocumentFonts: Helvetica
%%DocumentFiles:KJ:BASIC:STEP & REPEAT program:Sample scan
%%+KJ:BASIC:STEP & REPEAT program:Sample scan
%%+KJ:BASIC:STEP & REPEAT program:Sample scan
%%+KJ:BASIC:STEP & REPEAT program:Sample scan
%%+KJ:BASIC:STEP & REPEAT program:Sample scan
%%+KJ:BASIC:STEP & REPEAT program:Sample scan
%%DocumentNeededResources: procset Adobe_packedarray 2.0 0
%%+ procset Adobe_cmykcolor 1.1 0
%%+ procset Adobe_cshow 1.1 0
%%+ procset Adobe_customcolor 1.0 0
%%+ procset Adobe_typography_AI3 1.0 1
%%+ procset Adobe_IllustratorA_AI3 1.0 1
%AI3_ColorUsage: Color
%AI3_TemplateBox: 306 396 306 396
%AI3_TileBox: 30 31 582 761
%AI3_DocumentPreview: None
%%EndComments
%%BeginProlog
%%IncludeResource: procset Adobe_packedarray 2.0 0
Adobe_packedarray /initialize get exec
%%IncludeResource: procset Adobe_cmykcolor 1.1 0
%%IncludeResource: procset Adobe_cshow 1.1 0
%%IncludeResource: procset Adobe_customcolor 1.0 0
%%IncludeResource: procset Adobe_typography_AI3 1.0 1
%%IncludeResource: procset Adobe_IllustratorA_AI3 1.0 1
%%EndProlog
%%BeginSetup
%%IncludeFont: Helvetica
Adobe_cmykcolor /initialize get exec
Adobe_cshow /initialize get exec
Adobe_customcolor /initialize get exec
Adobe_typography_AI3 /initialize get exec
Adobe_IllustratorA_AI3 /initialize get exec
.
. stuff omitted for the sake of brevity
.
%AI3_BeginEncoding: _Helvetica Helvetica
[/_Helvetica/Helvetica 0 0 1 TZ
%AI3_EndEncoding
%%EndSetup
0 A
%%BeginDocument:
%%_________________________________________[ DISTORT   ]
 .942575   1  scale
%%______________________________________________________
%%EndDocument
0 To
1 0 0 1 119 68 0 Tp
TP
0 Tr
0 O
0 g
0 i 0 J 0 j 1 w 4 M []0 d
%AI3_Note:
0 D
/_Helvetica 12 Tf
0 Ts
100 Tz
0 Tt
0 TA
0 0 5 TC
100 100 200 TW
0 0 0 Ti
0 Ta
0 Tq
0 0 Tl
0 Tc
0 Tw
(This is a sample label) Tx 
(\r) TX 
TO
[1 0 0 1 90.5 -576] 18 657 150 786
(KJ:BASIC:STEP & REPEAT program:Sample scan)`
%%IncludeFile:KJ:BASIC:STEP & REPEAT program:Sample scan
~
u
250 60 m
250 217 L
40 217 L
40 60 L
250 60 L
f
145 138.5 m
F
U
u
82 104.3665 m
93.7156 104.3665 103.2132 123.6784 103.2132 147.5 c
103.2132 171.3216 93.7156 190.6335 82 190.6335 c
70.2844 190.6335 60.7868 171.3216 60.7868 147.5 c
60.7868 123.6784 70.2844 104.3665 82 104.3665 c
f
82 147.5 m
F
U
47 208 m
47 69 l
F
%%PageTrailer
gsave annotatepage grestore showpage
%%BeginDocument:
%%____________________________________________[ STEP   ]
 162.5784  0 translate       % image :  1 / 1 
%%______________________________________________________
%%EndDocument
0 To
1 0 0 1 119 68 0 Tp
TP
0 Tr
0 O
0 g
0 i 0 J 0 j 1 w 4 M []0 d
%AI3_Note:
0 D
/_Helvetica 12 Tf
0 Ts
100 Tz
0 Tt
0 TA
0 0 5 TC
100 100 200 TW
0 0 0 Ti
0 Ta
0 Tq
0 0 Tl
0 Tc
0 Tw
(This is a sample label) Tx 
(\r) TX 
TO
[1 0 0 1 90.5 -576] 18 657 150 786
(KJ:BASIC:STEP & REPEAT program:Sample scan)`
%%IncludeFile:KJ:BASIC:STEP & REPEAT program:Sample scan
~
u
250 60 m
250 217 L
40 217 L
40 60 L
250 60 L
f
145 138.5 m
F
U
u
82 104.3665 m
93.7156 104.3665 103.2132 123.6784 103.2132 147.5 c
103.2132 171.3216 93.7156 190.6335 82 190.6335 c
70.2844 190.6335 60.7868 171.3216 60.7868 147.5 c
60.7868 123.6784 70.2844 104.3665 82 104.3665 c
f
82 147.5 m
F
U
47 208 m
47 69 l
F
%%PageTrailer
gsave annotatepage grestore showpage
%%BeginDocument:
%%____________________________________________[ STEP   ]
 162.5784  0 translate       % image :  1 / 2 
%%______________________________________________________
%%EndDocument
.
. stuff omitted for the sake of brevity
.
%%BeginDocument:
%%____________________________________________[ STEP   ]
 162.5784  0 translate       % image :  2 / 3 
%%______________________________________________________
%%EndDocument
%%BeginDocument:
%%____________________________________________[ REPEAT ]
-487.735199999   90  translate % move up
%%______________________________________________________
%%EndDocument
%%Trailer
Adobe_IllustratorA_AI3 /terminate get exec
Adobe_typography_AI3 /terminate get exec
Adobe_customcolor /terminate get exec
Adobe_cshow /terminate get exec
Adobe_cmykcolor /terminate get exec
Adobe_packedarray /terminate get exec
%%EOF

Thanks for any ideas or suggestions.

Ken Jenkins as a guest of Bruce Edwards
edwards@andy.bgsu.edu