Using JavaScript to temporarily change the opacity/transparency of a named OCG

Running Acrobat XI Pro on Windows 7

Hi folks,

Is it possible to temporarily change the opacity/transparency of a named OCG (layer) using JS?

I would like to attach this function to a button so that when clicked it would make an image/map semi-transparent so that it can be seen in context with an underlying image/map. I guess I'm looking for a similar function to a watermark.

If it is possible could you give me a hint on where in the JavaScript reference I should start looking - I've had no luck in there so far.

Thanks in advance for any feedback you can provide.


Stephen Phillips


3 Answers

If such a function would exist, it would be in the OCG class: http://livedocs.adobe.com/acrobat_sdk/11/Acrobat11_HTMLHelp/JS_API_AcroJS.89.922.html

But, as you can see, there is no functionality to modify the transparency of an OCG. So, with just JavaScript you are out of luck. This can very likely be done in a plug-in (even though I would have to research how to do this exactly).

Karl Heinz Kremer
PDF Acrobatics Without a Net
PDF Software Development, Training and More...
http://www.khkonsulting.com


Karl Heinz Kremer   

http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf (page 193)

A transparent color space indicates a complete absence of color and allows those portions of the document underlying the current field to show through.

what about trying a color conversion?

in this wake, you can save two versions of the layer: jpg and png; use png with the right color space when transparency is needed...

I have never done it so I can't guarantee it will work

what do others think about it?


Ricardo Falegnami   

How are you designing the form? If you create it in InDesign its easy enough to add an element with tranparency, group it with any other elements you want to display and make it a button (such as your map) then use Show/Hide button to make it do what you want and set it to 'hide until triggered' if its a popup.

As far as doing it in acrobat, I'd roll with Ricardo's suggestion, create an image then use "Import as layer" in the layers panel options. Even if the image doesn't have transparency it looks like you can set it when you import.


Dan Williams   


Please specify a reason: