Skip to main content
Participant
May 2, 2019
Question

Run formula over hundreds of prices in PDF

  • May 2, 2019
  • 2 replies
  • 1139 views

Hi all,

I have a 40-page PDF price list from a supplier which contains hundreds of prices of various products. We'd like to run a formula over every single listed price and replace our supplier's "buy" price with our "sell" price so we can forward the document to our customers. The price list includes formatting, images and colours etc which we want to retain so exporting to Excel, Word etc isn't an option.

I'd like know if it's possible to create a script that can replace every single "buying" price in the document (all are prefixed with $) with our "selling" price.

Our simple calcuation involves multiplying the price by X and rounding to a ceiling of $10.

Thanks in advance for your help.

This topic has been closed for replies.

2 replies

Legend
May 2, 2019

Some years ago, I had a similar task (with a few additional quirks, such as different pricing factors and different currencies).

In that case, I first ran an analysing JavaScript over the document, locating and reading out prices. At the same location, it placed a form field, and set the underlying price as its default value. Then, a second script ran through the fields and calculated the price to display. Finally, a copy of the document got flattened.

This was pretty straightforward.

TB83Author
Participant
May 2, 2019

Thanks Maxwyss, that sounds basically identical to what we need to do!

Any idea about how I might go about doing that? I'm a bit of newbie to this unfortunately!

try67
Community Expert
Community Expert
May 2, 2019

I've also developed a script that does essentially that. The issue with doing it is that the script can't know the font style, font color or background color (the font size can be figured out, more of less) of the text being used in the document. You can hard-code it, of course, but if it's not always the same in the entire document you will have to go back and manually adjust it later on, so it doesn't look out of place.

Inspiring
May 2, 2019

JavaScript in Acrobat doesn't allow you to replace text on a page. The best you can do it add some type of annotation (form field, text comment, etc.) on top of existing text. JavaScript can search through a document for certain text and give you the coordinates on the page, which you can use when adding an annotation with JavaScript. Once you're done adding annotations, you can use JavaScript to flatten the pages, which converts the annotation text to regular page contents. So it's possible in a way, but getting precise placement of the new text could be tricky. It might be a good idea to redact the original prices so a user won't be able to discover them. You can do this via JavaScript using redaction annotations. This all assumes that the document doesn't have security restrictions that would prevent it, and you may also need permission from the supplier to alter their document.

TB83Author
Participant
May 2, 2019

Thanks George - appreciate the response.