PDF Editing Issues

How to Show Different Product Prices in a PDF Catalog with JavaScript

Adam DavisAdam Davis Nov 5, 2026 868 views

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.

How to Show Different Product Prices in a PDF Catalog Using JavaScript
Product
PDF
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.
Before you start

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.

Solution 1Recommended

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.

1
Create matching form fields

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.

2
Attach the price list data

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.

3
Insert price toggle buttons

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.

4
Apply custom JavaScript

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.

Performance Tip: Because executing a script across 1,500 form fields can cause the application to freeze, test your script on a small 10-item subset first to verify the logic and data mapping.
Manage PDFs Efficiently

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. 1. Open your document in WPS PDF: Launch WPS Office and open your product catalog PDF document.
  2. 2. Access the Form tools: Navigate to the 'Form' tab on the top ribbon to reveal the interactive form controls.
  3. 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. 4. Customize properties: Adjust the field properties, appearance, and add basic actions to buttons to complete your interactive catalog.
Create, edit, and fill PDF form fields intuitively without heavy software.Fully compatible with standard PDF formats and Microsoft Office files.Easily manage massive datasets in WPS Spreadsheet before exporting to PDF.Lightweight application that runs smoothly even with large, multi-page documents.
microsoft office alternative - wps office

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.