This is a conversation carried over from this thread: http://forums.adobe.com/thread/900119?tstart=0.
I am printing a postscript logo image on a certificate that is generated by a C program. When I call the image in the code, the image will print on a separate page, rather than embed within the certificate. I've removed the showpage command from the end of the image code, but that just prevented the image from being printed altogether. I believe what I need is a PostScript command or a string of commands that will print the image without sending a page eject command to the printer.
Does anyone know how this might be accomplished?
One method you could use to overcome unknown or unanticipated showpage calls in EPS or other PostScript files that you may insert into your PostScript file is to "disable" showpage before the file you want to insert and then "enable" showpage afterwards so that all enabled showpage commands are issued by your PostScript file only:
%%begin by storing a copy of the showpage procedure (this can be done once in your beginproc section, or everytime you insert a file.)
/showpage {1 pop} def % this replaces showpage with a procedure that does nothing to the graphics state %% your EPS or other PostScript compatible graphics file should be inserted here %% any occurance of showpage in this file will only do what you have redefined it to do - so it/they will be ignored, practically speaking.
/*showpage /showpage load def % this stores the actual procedure as currently defined in showpage
%%
%%
%% End of your EPS or other PostScript compatible graphics file
/showpage /*showpage load def % this reloads the original definition of showpage as it was when you stored it in *showpage
%% Your PostScript code continues at this point - it is up to you if and when the showpage is called to image the current page
No luck using your code verbatim, but I want to make sure I understand what the new def is doing. The "pop" command is essentially ignoring the topmost item in the stack, yes? So essentially your redefinition is simply saying ignore showpage whenever it occurs in the code (at least until the original def of showpage is restored). Is this correct?
If so, then this is essentially the same as removing showpage altogether from the code, and that hasn't worked in the past. While I definitely do not want a new page generated, I definitely need the logo to print.
"No luck..." doesn't tell me what output you got, so could you explain what output you got?
Did you place a showpage command in your code after the inserted logo file?
What coding did you use to place the logo file within the bounds of your current page?
"Is this correct?" - Yes you understand what the the redefinition of showpage is supposed to accomplish.
Can you provide the logo file for troubleshooting?
The result was the certificate without the logo. Here's the logo image code (less the actual image information):
Yes, there is a showpage command after the logo image information.
I've tweaked the code via the scale and translate commands such that he logo appears in the lower right corner of the printed page.
%!PS-Adobe-3.0
%%Creator: cairo 1.8.8 (http://cairographics.org)
%%CreationDate: Fri Sep 09 14:07:37 2011
%%Pages: 1
%%BoundingBox: 0 0 183 90
%%DocumentData: Clean7Bit
%%LanguageLevel: 2
%%EndComments
%%BeginProlog
/languagelevel where
{ pop languagelevel } { 1 } ifelse
2 lt { /Helvetica findfont 12 scalefont setfont 50 500 moveto
(This print job requires a PostScript Language Level 2 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
/B { fill stroke } bind def
/B* { eofill stroke } bind def
/n { newpath } bind def
/W { clip } bind def
/W* { eoclip } bind def
/BT { } bind def
/ET { } bind def
/pdfmark where { pop globaldict /?pdfmark /exec load put }
{ globaldict begin /?pdfmark /pop load def /pdfmark
/cleartomark load def end } ifelse
/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
440 50 translate
0.4 0.4 scale
%%EndProlog
%%Page: 1 1
%%BeginPageSetup
%%PageBoundingBox: 0 0 183 90
%%EndPageSetup
q
Q q
-187.645 439.654 m 424.355 439.654 l 424.355 -352.346 l -187.645
-352.346 l -187.645 439.654 l h
-187.645 439.654 m W n
q 0 0 183 90 rectclip
[ 1 0 0 1 0 -0.252296 ] concat
q
0 0 183 90 rectclip
Q q
0.941176 0.301961 0.262745 rg
.
<image info removed>
.
Q
Q
Q q
Q
showpage
%%Trailer
%%EOF
I have included a section of your file with some additional code I wrote and comments that I think will be helpful.
%%Page: 1 1
%%BeginPageSetup
%%PageBoundingBox: 0 0 183 90
%%EndPageSetup
q
Q q
-187.645 439.654 m 424.355 439.654 l 424.355 -352.346 l -187.645
-352.346 l -187.645 439.654 l h
-187.645 439.654 m W n
q 0 0 183 90 rectclip
[ 1 0 0 1 0 -0.252296 ] concat
q
0 0 183 90 rectclip
Q q
0.941176 0.301961 0.262745 rg
% The storage of showpage into *showpage belongs here or above.
/*showpage /showpage load def
% The redefinition of showpage belongs here.
/showpage {1 pop} def
% This demonstrates where the current origin (x=0, y=0) on the page is.
% Not that directly before the %%EndProlog comment line above scales the graphics state to 40%.
/Helvetica findfont 12 scalefont setfont 0 0 moveto ( LOGO origin is here) show
% the following code draws lines in 5 degree increments to show what parts of the page are within the current clipping path.
0 0 moveto gsave 2.5 2.5 scale .25 setlinewidth 0 setgray 72 {5 rotate gsave 800 0 lineto stroke grestore} repeat grestore
% I suspect your logo file is outside of the current clipping path and that is why it doesn't appear on the page.
/showpage /*showpage load def
Q
Q
Q q
Q
showpage
%%Trailer
%%EOF
I inserted the code tweak verbatim, but the logo continues to print on a separate page from the certificate. However, the logo itself now has a sun ray pattern eminating from the lower left-hand corner of the logo, the logo has changed color to red, and the bounding box clips off a portion of the logo itself.
Note that I not only included the defines you provided (those command lines after your %%comments), but also the changed coordinate values (boxed in by the Q and q's) as you posted them. If I do not include those coordinate changes, the logo still prints out on a separate page with the sun ray pattern, but the logo color remains intact and the bounding box does not cut off the logo.
If you have any other suggestions, I'm all ears.
(and thanks for your help so far)
- Bry
I'll send you a private message shortly.
As an aside, I've taken a new route to try and get this logo to print. I've now converted the .ps logo to a .pdf and am trying to integrate it that way. If you just happen to have experience with that, let me know. It might allow us to bypass wading through code...
North America
Europe, Middle East and Africa
Asia Pacific