Using PGE to dynamically control the background color of a page

313 views
Skip to first unread message

Brooks

unread,
Dec 16, 2013, 1:08:54 PM12/16/13
to xmpie...@googlegroups.com
I'm attempting to dynamically change the background color of a page using PGE. The idea is that I can place a PGE eps file as the background image on a page. The eps file is very simple, containing only postscript which draws a box with a solid fill. I'd like to change this color of this fill based on the value of an ador, but i'm not sure how to set the value of "setcmykcolor" to the value of an ador. I have almost no knowledge of postscript so any help would be great. My PGE eps is attached. I'm fairly sure that this: "RecipientData /BGColor setcmykcolor" is the part that isn't correct. Thanks in advance!


XMPiePGE_BGColor.eps

Igor

unread,
Dec 16, 2013, 1:46:46 PM12/16/13
to xmpie...@googlegroups.com
First you need to know how to write a postscript , not my strongest one.
Second I assume you do know how to do that but I have a question does the portion of the static setcmykcolor works ? if it does then i see that your BGColor data is not looks like the one in the static . 
Igor.

Brooks

unread,
Dec 16, 2013, 2:43:31 PM12/16/13
to xmpie...@googlegroups.com
Yes, the static setcmykcolor works... and the value of the ador "BGColor" is in fact formatted correctly, i just think the way i'm trying to set the value of setcmykcolor to the value of the BGColor ador is what's incorrect.

Igor

unread,
Dec 16, 2013, 2:58:13 PM12/16/13
to xmpie...@googlegroups.com
you need better understand technote as well  Post Script , that is actually you may find not that simple .
in any case in the touchtone  first you see how they fetch data fro dictionary : OMRMarkData /TotalPages get stringBuffer cvs show 
so for ADOR data that will be something like (if we just print the value of the ADOR) 
OMRMarkData /RecipientData get (BGColor)  get stringBuffer cvs show

but in your case you not even fetching data RecipientData /BGColor setcmykcolor

if you want to learn about postscript I'd recommend download Blue Book from Adobe you can find link on    http://en.wikipedia.org/wiki/PostScript

So first try to print your data on the screen / that way you know for sure you can fetch it , later learn PostScript.
Igor.

Eyal Arie

unread,
Dec 16, 2013, 4:25:11 PM12/16/13
to xmpie...@googlegroups.com
Attached is a revised version of your PGE that should work.
I fixed two problems:
1. You need to use the "get" operator if you want to actualy use the value of the ADOR.
2. The ADOR value is recieved as a string and not as a set of real numbers. I added a small PS function I called str2reals that takes the string and converts it to a sequence of real numbers.
I did not actually run this PGE but I believe the PS is correct.

And forgive me for pointing out the obvious, but if you only have a small number of colors, you can use style ADOR instead of a PGE. So I can assume that you need to be ready for just any CMYK combination...


Regards,

Eyal


--
You received this message because you are subscribed to the Google Groups "XMPie Interest Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xmpie-users...@googlegroups.com.
To post to this group, send email to xmpie...@googlegroups.com.
Visit this group at http://groups.google.com/group/xmpie-users.
For more options, visit https://groups.google.com/groups/opt_out.

XMPiePGE_BGColor_WithConversion.eps

Igor

unread,
Dec 16, 2013, 5:01:10 PM12/16/13
to xmpie...@googlegroups.com
Eyal is a PostScript guru ,so I'm glad he is watching the forum.
Still advise to read some books on PostScript.
In any case things can be achieved differently for example you can construct  string that is PostScript and evaluate it like in JavaScript .
you can fetch data from ADOR concatenate with another string (  setcmykcolor) and use cvx exec

or even make a decision in uPlan if you want cmyk or RGB and pass final value to PGE  , like if you uPlan will eventually generates 0.37 0.63 0.9 0.87 setcmykcolor at the same time if you decide in uPlan go RGB your code will not change just make sure pass different postscript string

your postscript 

/stringBuffer 33 string def
newpath
OMRMarkData /RecipientData get (BGColor)  get stringBuffer cvs cvx exec
0 0 moveto
0 100 lineto
100 100 lineto
100 0 lineto
0 0 lineto fill

Brooks

unread,
Dec 16, 2013, 5:27:43 PM12/16/13
to xmpie...@googlegroups.com
Hi Eyal,

Thank you for your response. Within my uPlan there there is a Javascript function that parses a hexadecimal value from data (which is defined via a UI much further upstream) and converts to CMYK values, and passes to the BGColor ador as a string the 4 values separated by spaces as my thought was I would be able to directly insert these into the postsript without needing to do any type of conversion but apparently that's not the case.

I tested using the PGE that you updated by uDirect/uProduce still will not output anything so suspect there is still something wrong with the PGE. What format of string is your str2reals function expecting for the CMYK values?


On Monday, December 16, 2013 4:25:11 PM UTC-5, ~EA wrote:

Igor

unread,
Dec 16, 2013, 6:01:55 PM12/16/13
to xmpie...@googlegroups.com
Brooks,
did you tried my example ? it will work if your data out of uPlan will looks like 0.37 0.63 0.9 0.87 setcmykcolor

if you want to keep your data like 0.37 0.63 0.9 0.87 in my approach you need contact to it setcmykcolor 
so I added function concatstrings (that i found on the web) that concat 2 strings and then I evaluate expression same  method.
so what it does it fetch data from ADOR puts into string buffer concatinate with literal in my case space and particular set cmyk color then vonverts it to string and eventually executes this string 
OMRMarkData /RecipientData get (BGColor)  get stringBuffer ( setcmykcolor) concatstrings cvs  cvx exec



%!PS-Adobe-3.1 EPSF-3.0
%%Title: Demo
%%BoundingBox: -256 -73 237 340
%%PGERequiredADORs:
%%+Credit
%%+BGColor
%%Page: 1 1
% check if OMR data is available
/concatstrings % (a) (b) -> (ab)  
   { exch dup length    
     2 index length add string    
     dup dup 4 2 roll copy length
     4 -1 roll putinterval
   } bind def  

/OMRMarkData where not
{
% data is unavailable, draw a default drawing.
0.5 setgray
0 0 300 200 rectfill
0 setgray
2 90 moveto
/TimesNewRomanPSMT findfont 40 scalefont setfont
(OMR Unavailable) show
}
{
pop
% data is available, draw OMR using OMRMarkData.
/stringBuffer 33 string def
newpath
%OMRMarkData /RecipientData get (BGColor)  get stringBuffer cvs cvx exec
OMRMarkData /RecipientData get (BGColor)  get stringBuffer ( setcmykcolor) concatstrings cvs  cvx exec
0 0 moveto
0 100 lineto
100 100 lineto
100 0 lineto
0 0 lineto fill
}
ifelse
%%Trailer
%%Pages: 1
%%DocumentNeededResources: font TimesNewRomanPSMT
%%DocumentSuppliedResources:
%%EOF

tyrone...@bigpond.com

unread,
Dec 16, 2013, 6:04:08 PM12/16/13
to xmpie...@googlegroups.com

why don't you just create a Object style in indesign add the fill colour, name the object the same as the data. Then just create a style adore and add your logic. then draw your box in indesign and assign the style adore to the box in indesign. You could also write a style++ adore if you need to apply more than just one parameter. 
 


Igor

unread,
Dec 16, 2013, 6:17:22 PM12/16/13
to xmpie...@googlegroups.com
correction this should do it (do not forget concatstrings fucntion)

OMRMarkData /RecipientData get (BGColor)  get ( setcmykcolor) concatstrings cvx exec

Brooks

unread,
Dec 16, 2013, 7:35:23 PM12/16/13
to xmpie...@googlegroups.com
Hi Igor,

I did get yours to work. Through testing i realized that you can not pass a value for any of the CMYK values with more than 7 decimal places, so i've altered the code that's sending these values to the BGColor ador to only send up to 7 decimal places and now it's working as desire. 

Thank you guys (Igor & Eyal) for your help with this one!

Igor

unread,
Dec 17, 2013, 9:57:36 AM12/17/13
to xmpie...@googlegroups.com
I told you that your input is off :-) , in any case my postscript skills are very limited , had to open a book that i recommended you and remind myself. 
Please next time place all info in the thread , like what you tried to do , technote ... so people will understand how PGE works.

PGE is a very powerful toll if you know how to write postscript . PGE not only gets ADOR values but also page number page total.  you can use it to produce for example barcode that is changing per page for document with dynamic number of pages.  it can be used to drow some unique graph ..... 

Igor.

Brooks

unread,
Dec 19, 2013, 2:29:51 PM12/19/13
to xmpie...@googlegroups.com
You're the man Igor.

Bob Hopfner

unread,
Dec 20, 2013, 11:57:04 AM12/20/13
to xmpie...@googlegroups.com
I can't find the PGE Technote. I'd like to check that out but I don't see it on the 1to1 website.

thanks,
Bob

Igor

unread,
Dec 26, 2013, 9:39:20 AM12/26/13
to xmpie...@googlegroups.com
See attahced
Technote-0010-Using Programmable Graphic Elements.pdf
Reply all
Reply to author
Forward
0 new messages