Skip to main content
Inspiring
September 27, 2023
Answered

Bar charts in PDF Form?

  • September 27, 2023
  • 3 replies
  • 2779 views

Hi,

 

Is there a way I can populate simple vertical bar charts from form fields? Maybe using Python or the usual JavaScript?

 

If anybody has achieved this result in PDF forms, please do guide me.

 

Thank you.

Correct answer JR Boulay

See these great samples files that uses JavaScript.

I'm not the author so I cannot provide their passwords.

 

3 replies

JR Boulay
Community Expert
Community Expert
September 27, 2023

"These files are great!! Clasics from back in the day. But they are also password restricted, so the scripts are not easily accessible.  Do you have an open version of the files?"

Yes, but if I distribute unlocked files that don't belong to me, I fall foul of French law.

These files were offered for free download by the company that created them, and can still be found on the Internet archive.
But you, me and everyone else know very well how to get round the PDF 'restrictions'.

Enjoy!

😉

 

Acrobate du PDF, InDesigner et Photoshopographe
bebarth
Community Expert
Community Expert
October 5, 2023

Hi JR,
Is it illegal to give the url of a website which allows that online?

@+

try67
Community Expert
Community Expert
September 27, 2023

Yes, it is, using a script (written in JavaScript). Here's a (paid-for) tool I've developed that does something similar. It converts a percentage text field into a "progress bar", which is essentially a horizontal bar chart:

https://www.try67.com/tool/acrobat-convert-percentage-fields-to-a-progress-bar

It can be adjusted to work as a vertical bar too, of course.

If you're interested in hiring a professional to create it for you, feel free to contact me privately by clicking my user-name and then on "Send a Message".

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
September 27, 2023

See these great samples files that uses JavaScript.

I'm not the author so I cannot provide their passwords.

 

Acrobate du PDF, InDesigner et Photoshopographe
Thom Parker
Community Expert
Community Expert
September 27, 2023

Hey @JR Boulay  These files are great!! Clasics from back in the day 😉 But they are also password restricted, so the scripts are not easily accessible.  Do you have an open version of the files?

 

However, the methodology used in these files is relatively simple. The "bars" on the graph are button fields.  The scripts change the size of the button to set the different bar heights.  To create such an implementation you need to understand PDF page coordinates. 

Read this:

https://www.pdfscripting.com/public/PDF-Page-Coordinates.cfm

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often