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

Run formula over hundreds of prices in PDF

Community Beginner ,
May 01, 2019 May 01, 2019

Copy link to clipboard

Copied

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.

TOPICS
Acrobat SDK and JavaScript

Views

805

Translate

Translate

Report

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
LEGEND ,
May 01, 2019 May 01, 2019

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 Beginner ,
May 01, 2019 May 01, 2019

Copy link to clipboard

Copied

Thanks George - appreciate the response.

Votes

Translate

Translate

Report

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
Advocate ,
May 01, 2019 May 01, 2019

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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 Beginner ,
May 02, 2019 May 02, 2019

Copy link to clipboard

Copied

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!

Votes

Translate

Translate

Report

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 ,
May 02, 2019 May 02, 2019

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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
Advocate ,
May 04, 2019 May 04, 2019

Copy link to clipboard

Copied

LATEST

This does require some understanding of how PDF lays out pages, and (of course) of Acrobat JavaScript.

Explaining it in detail would be beyond the scope of this forum, but could be done in a direct conversation. If interested in either learning how to do it, or have it delivered to you, feel free to contact me in private.

Votes

Translate

Translate

Report

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