Skip to main content
Participant
December 3, 2020
Question

How to "count" number of attachments to .PDF and return total to form field?

  • December 3, 2020
  • 1 reply
  • 1345 views

I want to attach files to a PDF document using a "attach files" button (script works fine—all is well on this end).

 

Once files are attached, I would like a total of files attached to show in a form field on the PDF itself. So if there are two files attached, then the field reads "2". If there is one, then the field reads "1".

 

Thank you in advance!

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
December 4, 2020

Are you attaching the files as comments or as data objects?

Participating Frequently
August 22, 2024

Hi, I have the same request 4 years later : )

Attachments are added via

this.importDataObject command.

Thank you in advance again!

try67
Community Expert
Community Expert
August 23, 2024

In that case you can use the dataObjects array to know how many attachments there are:

app.alert("There are " + (this.dataObjects==null ? 0 : this.dataObjects.length) + " attachments in this file.",3);