Hiding the Toolbar in Our JavaScript PDF Viewer

By modifying the ViewState, you can easily control when the toolbar should be shown or hidden by using the showToolbar property.

By updating this property using the instance.setViewState(), the toolbar will be shown when the property is set to true and hidden when set to false.

The following example toggles the showToolbar property between both states, so it will show it if it’s hidden, and hide it if it’s visible:

instance.setViewState(viewState => viewState.set("showToolbar", !viewState.showToolbar));