Skip to main content
Participant
September 23, 2018
Answered

Add filename to a formfield and activate js-script when opening the pdf.

  • September 23, 2018
  • 2 replies
  • 3724 views

Hi there,

I 'm adding the pdf's filename to a form field or textfield, using a js-script on the field.

When I save the pdf with another name, or I change the name of the file, and I open the pdf the filename that's being filled in in the textfield is the former name.

So I have to type something in the field to activate the js-script.

How can I make the script active when the pdf is being opened?

Thanks for any suggestions,

regards,

Wim

This topic has been closed for replies.
Correct answer try67

Instead of placing the code under the field's calculation event move it to be a doc-level script. You just need to change it from this:

event.value = this.documentFileName;

To this:

this.getField("Name of field").value = this.documentFileName;

2 replies

WimWAuthor
Participant
September 23, 2018

I already found out in the boards.

I'm adding a downloadlink for Acrobat Reader, and instruction for browsers.

Thanx.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 23, 2018

Instead of placing the code under the field's calculation event move it to be a doc-level script. You just need to change it from this:

event.value = this.documentFileName;

To this:

this.getField("Name of field").value = this.documentFileName;

WimWAuthor
Participant
September 23, 2018

Tanks try67, that worked like a charm.

I still have a problem with the highlight color in browsers. I want it to be transparant.

app.runtimeHighlight = false;

The highlight-script works in a Acrobat Pro, Acrobat reader and Safari, but it stays blue in Chrome.

I'll also post this in a new thread.

Enjoy your day.

W.

try67
Community Expert
Community Expert
September 23, 2018

Don't bother. There's nothing we can offer you in regards to this issue. You need to ask the Chrome developers about it. It has nothing to do with Adobe.