Copy link to clipboard
Copied
I am currently working on an interactive ebook......I want to add a click button to
the bottom of each page that will change colour from blue to green if it is clicked on..
I am using publisher to create the book and then saving it as PDF.
Copy link to clipboard
Copied
For future questions about scripts in PDF files you should really use this forum: JavaScript
Regarding your question: Do you want it to change only once, or back and forth with each click?
If only once then set the fill color as blue and then apply the following JavaScript code as the MouseUp event of the button:
event.target.fillColor = color.green;
If you want it to change back and forth, use this code:
event.target.fillColor = (color.equal(color.blue, event.target.fillColor)) ? color.green : color.blue;
Copy link to clipboard
Copied
Thank you try67
sorry about the wrong forum but I am totally new to this kind of thing.......
the script you have provided, which software can that be used in? I am using publisher for my project
and then converting it to PDF.
again thank you for help and I am sorry for my simple questions.
Stephen
Copy link to clipboard
Copied
The script I provided can be applied using Adobe Acrobat.
On Tue, 27 Nov 2018 at 11:26, stephenc22263337 <forums_noreply@adobe.com>
Copy link to clipboard
Copied
try67
many thanks as that has worked well for me once I downloaded Acrobat..
Thank you for your help, I hope you dont mind but I have one more question.
Can I use javascript to select certain words and then have them appear on another page?
regards
Stephen
Copy link to clipboard
Copied
That is much more complicated. What do you mean by "certain words"? What do you mean by "select"? Where, and how, should they "appear"?
Copy link to clipboard
Copied
so has your aware I am working on an ebook...
I wanted the user to be able to select the page heading example ( Hitlers war bunker) and then have that appear on an Itinerary/visit list page at the end of the ebook?
Copy link to clipboard
Copied
You can't do it with just any piece of text on the page. It's possible to add a button next to specific items that will copy them over when that button is clicked, though.
Copy link to clipboard
Copied
oh ok well thats sounds like a good plan... so I can simply add a button next to the text and then they click that button and the text will be added to another page... I like that..
so how do I do that please?
Copy link to clipboard
Copied
As the Mouse Up script of the button, enter something like this:
this.getField("Summary").value += "\r" + "Some text";
Set the "Summary" field as multiline to add each new piece of text in a new line, of course.
Copy link to clipboard
Copied
Hi there,
This worked perfectly for a form I was creating - the feature to change it back and forth. But for some reason, when I try to set it to yellow it won't change back? Is there a reason why it won't work on yellow?
Also, if I want to set it to a very specific color, is there a way to use color codes for this?
Copy link to clipboard
Copied
It's working fine for me:
event.target.fillColor = (color.equal(color.yellow, event.target.fillColor)) ? color.blue : color.yellow;
To specify a specific color you need to use the Color object, which is a simple array with the color name space and the values.
For example:
["RBG", 1, 0, 0]
is the same as color.red
Note that the values are between 0 and 1, not 0 and 255 like in most places, so you have to adjust them accordingly.
Copy link to clipboard
Copied
That is odd. I am doing exactly that and for whatever reason it turns it yellow but on this specific color won't turn it back. I am changing it to transparent. I did this with both green and red and works perfectly; so not sure why.
I will try to find the RBG codes for the colors I am looking for then.
In the meantime, I did come across one more thing. On the ones I do have working, I would like it to trigger another button and or text box to turn to the same color if clicked. For instance, if they click the selection and the button turns green on page 5, I want it to trigger another button and/or text box on page 20 to also turn green. Is this possible?
Copy link to clipboard
Copied
- It might have to do with the fact that color.yellow is a CMYK color and the rest are RGB... Although the equal method should convert them before comparing, according to the documentation. Maybe try it with a custom RGB yellow color.
- Sure, that's possible. You can do it like this, for example:
var newColor = (color.equal(color.red, event.target.fillColor)) ? color.blue : color.red;
event.target.fillColor = newColor;
this.getField("Name of other field").fillColor = newColor;
Copy link to clipboard
Copied
Ok I will try the code - I did attempt to use codes previously but will play around with it some and see if I was missing something.
The example you sent works great! The only difference is I need the "trigger" button to also carry the action. So they are actually mimicking each other.
Copy link to clipboard
Copied
The code above will do that...
Copy link to clipboard
Copied
Hmmmm...so that's also not working that way. I think it might be two reasons. (1) The platform I am in, Bluebeam, might have slightly different scripts and I will just have to do some more trial and error. (2) I have an update I'm running to see if that is the reason.
What is just so odd is it is working on some colors but not others - so the inconsistency is throwing me off. Will see if the update helps.
Copy link to clipboard
Copied
Ah, if you're not opening the file in an Adobe application then that is very likely the reason for these issues.
I'm afraid I can't help you with that.
Copy link to clipboard
Copied
Ok I will see if I can find an expert within the platform I am working. It's just super strange that it works for some colors and not others.
Copy link to clipboard
Copied
Hi try67,
I would like to change a no fill button to an orange button upon clicking the mouse.
Since I'm planning to use specific colours, I tried this code:
event.target.fillColor = (color.equal(color.["RGB",1,1,1], event.target.fillColor)) ? color.["RGB",1,0.6,0.3] : color.["RGB",1,1,1];
I replaced the colours with the RGB codes (not sure if I'm doing it correctly...) but I got this message:
SyntaxError: missing name after . operator 1: at line 2
Not sure what I should do...
Would really appreciate any help, thank you so much!
Copy link to clipboard
Copied
Your RGB values have to adhere to what the script expects, which is a value between 0 and 1. If your values are in Hex then you need to convert them to decimals, and then divide by 255.. If they are already integers between 0 and 255 then you just need to divide them by 255.
Copy link to clipboard
Copied
Hi try67,
Thank you for replying!
I've changed the RGB values to a value between 0 and 1 as seen in the code.
event.target.fillColor = (color.equal(color.["RGB",1,1,1], event.target.fillColor)) ? color.["RGB",1,0.6,0.3] : color.["RGB",1,1,1];
but the Syntax error message still appears...
Is my overall code wrong?
Sorry about it, I'm new to these, thanks for helping!
Copy link to clipboard
Copied
Change all instances of:
color.["RGB",1,1,1]
To just:
["RGB",1,1,1]
Copy link to clipboard
Copied
Oh, I see!!!
Thanks for your help!! it works now!
Copy link to clipboard
Copied
Hey Try67,
Is there a way to cycle between three different colors (red, yellow, green, then repeat) with a code as simple as this?