How to Show Different Product Prices in a PDF Catalog with JavaScript
Question details
The user needs to dynamically update price fields across a large PDF catalog containing over 1,500 products using interactive buttons to toggle between three different price tiers.

- Product
- Device & OS
- not provided
- Scenario
- Managing a multi-tier pricing PDF catalog and wanting to display specific pricing based on a user's selection.
- Observed behavior
- The user wants to click a button (e.g., "Show Price 2") and have the document automatically populate every corresponding product price field throughout the entire PDF.
Ensure you have access to a PDF editor that supports advanced JavaScript execution and form field management. For massive documents, prepare a small sample of your catalog to test the script before applying it to all 1,500 products.
Create a Custom JavaScript with Embedded Price Lists
Attach a tab-delimited data file to your PDF and use a custom script to map and populate text fields when a tier button is clicked.
This method requires creating consistent form fields for each product and utilizing an embedded data source. Since iterating through over 1,500 products is highly resource-intensive, mapping the exact catalog numbers to the form field names ensures the script accurately targets the right elements without causing logic errors.
Add a text field for the price next to each product. Name each field using the unique catalog number (e.g., 'Price_1001') to ensure accurate mapping.
Export your three price tiers from your spreadsheet into a tab-delimited text file. Attach this text file directly to your PDF document using the attachments panel.
Use the form tools to place interactive buttons labeled for each pricing tier (e.g., 'Show Tier 1', 'Show Tier 2') at the top or navigation area of your document.
Assign a 'Run a JavaScript' action to the mouse-up event of your buttons. Write a script that opens the attached tab-delimited file, extracts the specific price column, matches the catalog numbers to the PDF form field names, and sets the field values.
Edit and Manage PDF Forms Easily with WPS Office
While complex JavaScript parsing requires advanced programming environments, WPS PDF offers an intuitive, lightweight interface for creating interactive PDF forms, adding text fields, and inserting buttons. For large product catalogs, you can seamlessly manage your pricing data in WPS Spreadsheet and export a clean PDF for each tier.
- 1. Open your document in WPS PDF: Launch WPS Office and open your product catalog PDF document.
- 2. Access the Form tools: Navigate to the 'Form' tab on the top ribbon to reveal the interactive form controls.
- 3. Add and name text fields: Insert text fields next to your products. Double-click each field to rename them consistently according to your product IDs.
- 4. Customize properties: Adjust the field properties, appearance, and add basic actions to buttons to complete your interactive catalog.

Frequently Asked Questions
Can I use Excel to manage PDF catalog prices instead of JavaScript?
Yes. It is often much easier to maintain your product catalog and pricing tiers in a spreadsheet program like WPS Spreadsheet. You can create different columns for each price tier, filter the desired tier, and directly export a clean, static PDF for distribution, completely bypassing the need for complex PDF scripting.
Why does my PDF editor crash when I click the script button?
Processing over 1,500 fields simultaneously requires significant memory. If your custom JavaScript iterates through every single field in real-time without optimization, it may cause the application to freeze or crash. Consider dividing the catalog into smaller sections or updating fields page-by-page.
Does the form field name matter when scripting PDF forms?
Absolutely. The JavaScript relies on exact, unique field names to map the correct price to the right product. Using the product's specific catalog number as the text field's name allows the script to accurately locate and populate the data.




