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

Adobe Acrobat Pro create PDF from web page javascript events not working

New Here ,
Sep 20, 2023 Sep 20, 2023

I created a web page where sections of the page show/hides upon the value coming from select box. The HTML works fine when run in a browser, but it doesn't works when I create a PDF out of this html page using Adobe Acrobat Pro. The Javascript seems working looks it doesn't capture the events. Here is my code. Appreciate your help with this.

<html>
	<head>
		<title>Example</title>
	</head>
	<body>
		<h1>Example</h1>
		<br/>
		<div id="section01_1">
			<select id="selector01">
				<option value="NA">Show a section</option>
				<option value="A">A</option>
				<option value="B">B</option>
				<option value="C">C</option>
			</select>
		</div>
		<br/>
		<br/>
		<div id="section01_2">
Enter Name:			<input type="text"
			       id="fname"/>
		</div>
		<br/>
		<br/>
		<div id="section01">
		This is my section one
		</div>
				<div id="section02">
		This is my section two
		</div>
				<div id="section03">
		This is my section three
		</div>
				<div id="section04">
		This is always visible
		</div>
	</body>
	<script language="JavaScript">

		const el = document.getElementById('selector01');
		const box01 = document.getElementById('section01');
		const box02 = document.getElementById('section02');
		const box03 = document.getElementById('section03');

		box01.style.visibility = 'hidden';
		box02.style.visibility = 'hidden';
		box03.style.visibility = 'hidden';

		el.addEventListener('change', function handleChange(event) {
		if (event.target.value === 'A') {
		box01.style.visibility = 'visible';
		} else {
		box01.style.visibility = 'hidden';
		}
		if (event.target.value === 'B') {
		box02.style.visibility = 'visible';
		} else {
		box02.style.visibility = 'hidden';
		}
		if (event.target.value === 'C') {
		box03.style.visibility = 'visible';
		} else {
		box03.style.visibility = 'hidden';
		}
		});
	</script>
</html>

 

TOPICS
JavaScript , PDF
469
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 ,
Sep 20, 2023 Sep 20, 2023

You can't use browser JavaScript in PDF documents.

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
New Here ,
Sep 21, 2023 Sep 21, 2023
LATEST

OK. is following possible? As I mentioned, I am writing HTML page and expect it be transformed as is into PDF via Acrobat DC, its an interactive web page i.e. show hide of sections.

1. When I see it in Acrobat Pro, the DIV elements are completely missing, wondering which HTML element can be substituted as a container component that Acrobat/PDF understands so I can write script accordingly in Acrobat.

2. Can I write script in HTML page itself that Acrobat understand? If so how?

 

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