How can I set opacity and mirror flip an image uploaded to a button using JavaScript?
Copy link to clipboard
Copied
I've been searching the JavaScript for Acrobat API Reference and so far, all I could find was setting the opacity on a watermark. The "watermark" image is placed on an OCG (layer), and I haven't found a way to use this as the source of the button icon.
Setting the opacity on a button only affects its .fillColor and not the icon image.
I haven't found a way to mirror flip the image either.
Is there any workaround I can use? Would I be able to achieve this by making the image an attachment, setting the attachment as an icon, and then loading into the button? (It would be great if there was a less "hacky" way to do this...)
Also, I can't use Live Cycle - I need to be able to run this code from Adobe Reader.
Copy link to clipboard
Copied
There are no built-in commands to do it. In theory, if you read the image as an Icon Stream you might be able to achieve it, but it will require quite complex image processing algorithms. I would recommend you do it elsewhere, not in the PDF file.
Copy link to clipboard
Copied
Hi, @try67! I looked into the docs and I'm not sure I'd be able to achieve it with Icon Stream, which can be used to add an icon to a tool bar button via:
app.addToolButton
I want to add an image (icon) to a button in a form field via:
.buttonImportIcon
This is why I need to do it in the PDF file and not elsewhere. I want the user to be able to upload their desired image.
Also, while I would be able to set the opacity for an Icon Stream, how would I accomplish a horizontal mirror-image flip?
Copy link to clipboard
Copied
You can use buttonSetIcon for that. As to the specific algorithm of doing these operations you will need to conduct your own research, or hire a professional. As I said, this is not a trivial task, but I do believe it's doable.

