Add Image to Postscript
I need to add an image to my existing postscript. If an condition is satisfied, it need to print the new image (below code i got it when i converted it from jpg to ps) instead of the old image (designed using simple ps commands).
When i include the complete set of code, it prints FINE on a separate page.But i need to have the new logo in place of old logo based on a condition. To print this on a conditional basis, i need to move this withing the /NLOGO {.....} bind def and call the logo like below. But it fails (Error Message at the bottom). Please let me know where to NLOGO {.....} bind def definition.
code snippet from main
gsave
newpath
SA 00 get (R) eq
{ /Scalefactor .25 def
0 45 translate
Scalefactor Scalefactor scale
OLOGO } if
SA 00 get (M) eq
{ /Scalefactor .20 def
10 30 translate
Scalefactor Scalefactor scale
NLOGO } if
New Image
/languagelevel where
{ pop languagelevel } { 1 } ifelse
3 lt { /Helvetica findfont 12 scalefont setfont 50 500 moveto
(This print job requires a PostScript Language Level 3 printer.) show
showpage quit } if
/q { gsave } bind def
/Q { grestore } bind def
/cm { 6 array astore concat } bind def
/w { setlinewidth } bind def
/J { setlinecap } bind def
/j { setlinejoin } bind def
/M { setmiterlimit } bind def
/d { setdash } bind def
/m { moveto } bind def
/l { lineto } bind def
/c { curveto } bind def
/h { closepath } bind def
/re { exch dup neg 3 1 roll 5 3 roll moveto 0 rlineto
0 exch rlineto 0 rlineto closepath } bind def
/S { stroke } bind def
/f { fill } bind def
/f* { eofill } bind def
/n { newpath } bind def
/W { clip } bind def
/W* { eoclip } bind def
/BT { } bind def
/ET { } bind def
/BDC { mark 3 1 roll /BDC pdfmark } bind def
/EMC { mark /EMC pdfmark } bind def
/cairo_store_point { /cairo_point_y exch def /cairo_point_x exch def } def
/Tj { show currentpoint cairo_store_point } bind def
/TJ {
{
dup
type /stringtype eq
{ show } { -0.001 mul 0 cairo_font_matrix dtransform rmoveto } ifelse
} forall
currentpoint cairo_store_point
} bind def
/cairo_selectfont { cairo_font_matrix aload pop pop pop 0 0 6 array astore
cairo_font exch selectfont cairo_point_x cairo_point_y moveto } bind def
/Tf { pop /cairo_font exch def /cairo_font_matrix where
{ pop cairo_selectfont } if } bind def
/Td { matrix translate cairo_font_matrix matrix concatmatrix dup
/cairo_font_matrix exch def dup 4 get exch 5 get cairo_store_point
/cairo_font where { pop cairo_selectfont } if } bind def
/Tm { 2 copy 8 2 roll 6 array astore /cairo_font_matrix exch def
cairo_store_point /cairo_font where { pop cairo_selectfont } if } bind def
/g { setgray } bind def
/rg { setrgbcolor } bind def
/d1 { setcachedevice } bind def
/cairo_data_source {
CairoDataIndex CairoData length lt
{ CairoData CairoDataIndex get /CairoDataIndex CairoDataIndex 1 add def }
{ () } ifelse
} def
/cairo_flush_ascii85_file
{ cairo_ascii85_file status { cairo_ascii85_file flushfile } if } def
/cairo_image { image cairo_flush_ascii85_file } def
/cairo_imagemask { imagemask cairo_flush_ascii85_file } def
/cairo_set_page_size {
% Change paper size, but only if different from previous paper size otherwise
% duplex fails. PLRM specifies a tolerance of 5 pts when matching paper size
% so we use the same when checking if the size changes.
/setpagedevice where {
pop currentpagedevice
/PageSize known {
2 copy
currentpagedevice /PageSize get aload pop
exch 4 1 roll
sub abs 5 gt
3 1 roll
sub abs 5 gt
or
} {
true
} ifelse
{
2 array astore
2 dict begin
/PageSize exch def
/ImagingBBox null def
currentdict end
setpagedevice
} {
pop pop
} ifelse
} {
pop
} ifelse
} def
%%EndProlog
%%BeginSetup
%%EndSetup
%%Page: 1 1
q 0 0 135 32 rectclip
1 0 0 -1 0 32 cm q
Q q
q
0 0 135 32 re W n
[ 134.240005 0 0 -31.040001 0 31.040001 ] concat
/cairo_ascii85_file currentfile /ASCII85Decode filter def
/DeviceRGB setcolorspace
<<
/ImageType 1
/Width 2226
/Height 296
/Interpolate true
/BitsPerComponent 8
/Decode [ 0 1 0 1 0 1 ]
/DataSource cairo_ascii85_file /FlateDecode filter
/ImageMatrix [ 2226 0 0 -296 0 296 ]
>>
%}
cairo_image
Gb"-V^MY=9j6lrX"(-ZA]n*]s8(NEYJ-[`XL^+MFEeog=*$EPc(Kj:^#Tlfr&D@[*-ZB-_(
...
...
Az0T2fB%YmDSQ<R]%z!!(2'T?f\g!rr<$!!'6M+s?pdJ6BMen^-/?~>
Q
Q Q
showpage
%%Trailer
Error Received
Error: /syntaxerror in -file-
Operand stack:
NLOGO
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostri
val-- --nostringval-- false 1 %stopped_push 1 3 %oparray_pop 1 3 %oparray_pop 1 3 %oparray_pop .runexe
--nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval--
Dictionary stack:
--dict:1049/1123(ro)(G)-- --dict:0/20(G)-- --dict:151/200(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 23334
