# Disable buttons on PDF Viewer toolbar

**URL:** <https://forum.inductiveautomation.com/t/disable-buttons-on-pdf-viewer-toolbar/57350>\
**Category:** Ignition\
**Tags:** ignition81, vision\
**Created:** [March 18, 2022, 5:40am UTC](https://forum.inductiveautomation.com/t/disable-buttons-on-pdf-viewer-toolbar/57350 "2022-03-18T05:40:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![R\_S](https://avatars.discourse-cdn.com/v4/letter/r/a88e57/32.png) [@R\_S](https://forum.inductiveautomation.com/u/R_S)\
**Post date:** [March 18, 2022, 5:40am UTC](https://forum.inductiveautomation.com/t/disable-buttons-on-pdf-viewer-toolbar/57350/1 "2022-03-18T05:40:25Z")

</div>

Does anyone know if it’s possible to disable individual buttons from working on the PDF Viewer toolbar in the Vision client? I would like to disable the print and fullscreen buttons. Further this, is it possible to hide the disabled buttons?

 ![pdf_viewer_toolbar](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/e/aeaf19f5351bdfa9b44af6ee77ff36cb728b5d3b.jpeg)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 18, 2022, 2:51pm UTC](https://forum.inductiveautomation.com/t/disable-buttons-on-pdf-viewer-toolbar/57350/2 "2022-03-18T14:51:57Z")

</div>

Theoretically, something like this (in a `propertyChange` script) might do it:

```auto
if event.propertyName == "componentRunning":
	from org.icepdf.ri.util import PropertiesManager
	props = PropertiesManager.getInstance()
	props.setBoolean(PropertiesManager.PROPERTY_SHOW_UTILITY_PRINT, False)

```

Available keys are documented here:  
[http://res.icesoft.org/docs/icepdf/latest/viewer/org/icepdf/ri/util/PropertiesManager.html](http://res.icesoft.org/docs/icepdf/latest/viewer/org/icepdf/ri/util/PropertiesManager.html)

---

<div class="post-metadata">

**Author:** ![R\_S](https://avatars.discourse-cdn.com/v4/letter/r/a88e57/32.png) [@R\_S](https://forum.inductiveautomation.com/u/R_S)\
**Post date:** [March 21, 2022, 12:23am UTC](https://forum.inductiveautomation.com/t/disable-buttons-on-pdf-viewer-toolbar/57350/3 "2022-03-21T00:23:27Z")

</div>

Yes that worked, it wasn’t at first but that’s because I didn’t realise that you had to have Designer running in ‘preview mode’ and then you have to reload the window before the PDF Viewer is refreshed.

I managed to get hide a few components with:

```auto
if event.propertyName == "componentRunning":
	from org.icepdf.ri.util import PropertiesManager
	props = PropertiesManager.getInstance()
	props.setBoolean(PropertiesManager.PROPERTY_SHOW_TOOLBAR_UTILITY, False)
	props.setBoolean(PropertiesManager.PROPERTY_SHOW_UTILITY_SEARCH, False)
	props.setBoolean(PropertiesManager.PROPERTY_SHOW_UTILITY_PRINT, False)

```

Result is below, I went through the link you sent me but couldn’t seem to figure out how to remove the ‘Full Screen’ and ‘Show/Hide Form Highlighting’ buttons, I’ve marked them in the image below if anyone else has better luck?

 ![icepdf_modified_example](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/3/f3d2748a8598e1b7b4e9c44d786dba1211348054.jpeg)

---

<div class="post-metadata">

**Author:** ![Michael\_Knudsen](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@Michael\_Knudsen](https://forum.inductiveautomation.com/u/Michael_Knudsen)\
**Post date:** [March 31, 2024, 1:31pm UTC](https://forum.inductiveautomation.com/t/disable-buttons-on-pdf-viewer-toolbar/57350/4 "2024-03-31T13:31:34Z")

</div>

Hi, I'm trying to do this for disabling the "Save As" button which doesn't seem to function in the first place.

Where do we put that scripting code in? I've tried scripting on the window, using EventHandlers/vision/visionWindowOpened and just get an error:

Traceback (most recent call last):  
File "event:visionWindowOpened", line 1, in   
AttributeError: '[com.inductiveautomation.factorypmi.application.com](http://com.inductiveautomation.factorypmi.application.com)' object has no attribute 'propertyName'

Would this code be different for Ignition 8.1.35?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 31, 2024, 1:34pm UTC](https://forum.inductiveautomation.com/t/disable-buttons-on-pdf-viewer-toolbar/57350/5 "2024-03-31T13:34:50Z")

</div>

That code example needs to be in the propertyChange event script on the viewer itself. (Only a propertyChange event gets a propertyName field in its event object.)

---

<div class="post-metadata">

**Author:** ![Michael\_Knudsen](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@Michael\_Knudsen](https://forum.inductiveautomation.com/u/Michael_Knudsen)\
**Post date:** [March 31, 2024, 1:54pm UTC](https://forum.inductiveautomation.com/t/disable-buttons-on-pdf-viewer-toolbar/57350/6 "2024-03-31T13:54:30Z")

</div>

> [@R\_S](#):
>
> ```auto
> if event.propertyName == "componentRunning":
> from org.icepdf.ri.util import PropertiesManager
> props = PropertiesManager.getInstance()
> props.setBoolean(PropertiesManager.PROPERTY_SHOW_TOOLBAR_UTILITY, False)
> props.setBoolean(PropertiesManager.PROPERTY_SHOW_UTILITY_SEARCH, False)
> 
> ```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/5/25da507951414fae61af57a48b8d9c8a7bc38cff.png)

Thanks for the quick response.  
I've tried that now, and it seems to replicate the same bug unforunately.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 31, 2024, 3:29pm UTC](https://forum.inductiveautomation.com/t/disable-buttons-on-pdf-viewer-toolbar/57350/7 "2024-03-31T15:29:38Z")

</div>

My PDF viewer toolbar doesn't seem to have a "Save As" button. Which one is it?

---

<div class="post-metadata">

**Author:** ![Michael\_Knudsen](https://avatars.discourse-cdn.com/v4/letter/m/8c91f0/32.png) [@Michael\_Knudsen](https://forum.inductiveautomation.com/u/Michael_Knudsen)\
**Post date:** [March 31, 2024, 3:47pm UTC](https://forum.inductiveautomation.com/t/disable-buttons-on-pdf-viewer-toolbar/57350/8 "2024-03-31T15:47:59Z")

</div>

This one:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/b/2b591965273b34a7f7bdb7af2bb47b18e84c027d.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [March 31, 2024, 4:04pm UTC](https://forum.inductiveautomation.com/t/disable-buttons-on-pdf-viewer-toolbar/57350/9 "2024-03-31T16:04:36Z")

</div>

Interesting; mine doesn't have that.

In any case, I would go about it like this:

Throw a test button in the window, and write a script to recursively find the JButtons, looking for a way to uniquely identify the "Save Button." The JButton's `toolTipText` property would probably work.

**Example:**

```auto
def listViewerButtons(viewer):
	for component in viewer.components:
		if 'JButton' in component. __class__. __name__ :
			print component.toolTipText
		listViewerButtons(component)
viewer = event.source.parent.getComponent('PDF Viewer')
listViewerButtons(viewer)

```

When I run this on my PDF viewer, this is the output:

```auto
Print Document
Search Document
First Page
Previous Page
Next Page
Last Page
Zoom Out
Zoom In
Full Screen
Rotate Right
Rotate Left
Search markup annotations
Clear search results

```

In yours, I imagine that there will be a tool tip that says something like: "Save As"

If so, modify the recursive script to find it specifically:

```auto
# Recursive Script to hide JButtons based on toolTipText
def ButtonHider(component, toolTipText):

	# Cycle through all of the sub components of a given component
	for subComponent in component.components:

		# If there is a JButton with the given tool tip text, hide it
		if 'JButton' in subComponent. __class__. __name__ and subComponent.toolTipText == toolTipText:
			subComponent.visible = False			
		ButtonHider(subComponent, toolTipText)
		
# Get the PDF Viewer Component
viewer = event.source.parent.getComponent('PDF Viewer')

# Call the button hider script with the tool tip text of the button to hide
ButtonHider(viewer, "Save As")

```

This version could be placed generically in a library script and called from your `componentRunning` `propertyChange` event to hide any button in the viewer, and if needed in the future, it could be used to hide buttons as needed in any other component in the project.

@Michael_Knudsen , @R_S  
**Edit:** Corrected an error in the code example that was actually hiding the parent container of the button instead of the button itself.
