Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How can I set opacity and mirror flip an image uploaded to a button using JavaScript?

Explorer ,
Aug 07, 2021 Aug 07, 2021

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.

 

TOPICS
How to , JavaScript , PDF forms
669
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 07, 2021 Aug 07, 2021

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 09, 2021 Aug 09, 2021

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 09, 2021 Aug 09, 2021
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines