How to Show or Hide Embedded Video in a PDF Using JavaScript
Question details
The user wants to know how to control the visibility or playback of an embedded video in a PDF using JavaScript.

- Product
- Device & OS
- not provided
- Scenario
- Adding interactive controls to a PDF document to either hide/show the video annotation box or play/stop the media playback via JavaScript.
- Observed behavior
- The user needs to differentiate between starting/stopping playback and hiding/showing the video annotation, keeping in mind that support varies across video formats and PDF viewers.
Ensure your target audience will open the document in a dedicated desktop PDF reader (like WPS PDF or Adobe Acrobat), as most web browser PDF viewers do not support advanced multimedia JavaScript execution.
Use PDF JavaScript to Control Video Annotations
Identify whether you need to control media playback or the visibility of the annotation box itself, then apply the appropriate JavaScript methods to an interactive button.
Hiding and showing a video annotation in a PDF is technically different from starting and stopping the video's playback. The methods available depend heavily on the video format, the version of the PDF creation software, and the specific PDF viewer being used.
Decide whether you want to completely hide the video player area from the page (annotation visibility) or simply pause/stop the video content while leaving the player visible.
Open your PDF editor's form tools and insert a 'Button' field on the page. This button will act as the trigger for your video controls.
Right-click the button, access its Properties, and go to the Actions tab. Add a 'Run a JavaScript' action. Use standard PDF JavaScript methods (such as accessing the annotation via `getAnnots` and toggling the `hidden` property) to show or hide the video box.
Save the PDF and open it in a robust desktop PDF application. Click the button to test the functionality, as browser-based PDF viewers often block or ignore embedded-video JavaScript.

Manage Interactive PDFs with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to manage rich media, format interactive documents, and handle advanced PDF properties with ease. It is a lightweight, fully compatible solution for your daily document tasks.
- 1. Open WPS PDF: Launch WPS Office and click on the PDF tab from the main dashboard.
- 2. Load your document: Click 'Open' and select your PDF file containing the interactive multimedia elements.
- 3. Edit and interact: Navigate to the 'Edit' tab to modify page elements or use the viewing tools to interact with embedded media seamlessly.
- 4. Save your changes: Once your edits are complete, save the document to preserve all formatting and interactive properties.

Frequently Asked Questions
Why isn't my PDF JavaScript video control working in Google Chrome?
Most built-in browser PDF viewers, including Chrome and Edge, only support basic PDF rendering. They generally disable or do not support advanced PDF JavaScript execution and multimedia annotations for security and performance reasons. Users must open the file in a desktop application.
What is the difference between hiding a video and stopping playback in a PDF?
Hiding a video changes the visibility of the multimedia annotation box, making the player completely invisible on the page. Stopping playback leaves the video player box visible to the user but pauses or halts the media being played.
Which video formats are best for embedding in PDFs?
MP4 is generally the most universally supported and recommended format for embedding into modern PDFs. It ensures smoother playback and better compatibility across different desktop PDF reader applications.




