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

Acrobat Reader DC Javascript funktioniert nicht

New Here ,
May 31, 2019 May 31, 2019

Hallo!
Bräuchte bitte Hilfe bei einem Javascript
Habe ein Formular mit "Adobe Acrobat Pro DC" erstellt und ein Feld eingefügt in welchem beim Öffnen immer das aktuelle Datum stehen soll.
Das habe ich über Javascript-Anweisungen für Dokumente gemacht.
Der Code ist :

function UpdateDate(cFormat) {

return util.printd(cFormat, new Date());

return true;

} this.getField('Datum').value = UpdateDate('dd.mm.yyyy');

this.getField('Datum').defaultValue = UpdateDate('dd.mm.yyyy');

Im Acrobat Pro funktioniert alles super.
Aber auf meinem PC wo ich Acrobat Reader installiert habe aktualisiert sich das Datum nicht.
Habe schon die Javascript und Sicherheitseinstellungen geändert (Was meistens die Ursache in der Google Suche) aber auch das hat nichts gebracht.
Überseh ich da etwas oder geht Javascript in Reader DC gar nicht?
Bin für jede Hilfe dankbar

Danke

Liebe Grüße

TOPICS
Acrobat SDK and JavaScript , Windows
4.8K
Translate
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 31, 2019 May 31, 2019

Das sollte auch im Reader funktionieren (und hat bei mir auch funktioniert). Eine einfache Methode, um zu sehen, ob ein Stück Code auch ausgefuehrt wird ist, eine Nachricht in einem Dialog anzuzeigen. Wenn die folgende Zeile am Ende des Scripts angehängt wird sollte es klar sein, ob das Programm ausgeführt wird oder nicht:

app.alert("Datum gesetzt: " + UpdateDate("dd.mm.yyyy"));

Translate
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
New Here ,
Jun 01, 2019 Jun 01, 2019

Danke für die schnelle Antwort!

Super Idee, habe das eben gemacht
Auf dem Laptop wo die PDF ausgeführt werden soll passiert gar nichts

Habe aber extra nochmal geschaut, Javascript ist in den Einstellungen aktiviert, nur globale Sicherheit ist deaktiviert

Translate
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 31, 2019 May 31, 2019

There's no reason this code shouldn't work in Reader.

However, you should remove this line from the function, as it does nothing:

return true;

Translate
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
New Here ,
Jun 01, 2019 Jun 01, 2019

Thank you.
I've removed it 😃

Translate
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 31, 2019 May 31, 2019

Wann genau wird die Funktion aufgerufen? In einem Document Level-Script, oder wo sonst?

Wenn als Document Level-Script, ist es möglich, dass sie aufgerufen wird, bevor das Dokument ausreichend geladen worden ist.

Versuche (wenn nicht schon gemacht), die Funktion im Seite öffnen-Event aufzurufen.

For the monoglots:

When exactly is the function called? In a document-level script, or where else?

If it is a document-level script, it is possible that it is called before the document has been sufficiently loaded.

Try (if not already done) to call the function i the Page Open event.

Translate
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 31, 2019 May 31, 2019

[The fact someone doesn't speak German doesn't mean they're a monoglot... I speak 4 languages quite fluently, just not that one]

Translate
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 ,
Jun 01, 2019 Jun 01, 2019

Yeah, blast from the past, where I was in social media (way before that term existed), where the absolute majority of the users were USAns…

Watch out for the next incarnation of that text…

Translate
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
New Here ,
Jun 01, 2019 Jun 01, 2019

Ja, habe die Anweisung für Dokumente verwendet.
Da kenn ich mich zu wenig aus, wo kann ich das denn bitte machen?

Translate
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 ,
Jun 01, 2019 Jun 01, 2019

Als Document Level-Script nur die Funktion definieren (also "function blabla() {…… }", ohne diese aufzurufen.

Im Seite Öffnen-Event (in der rechten Spalte die Thumbnails anzeigen, betreffende Seite wählen und im Kontextmenu "Seiteneigenschaften" wählen. Im daraufhin erscheinenden Dialog den Aktionen-Reiter wählen und dort JavaScript ausführen. Dieses Script enthält dann den Aufruf der Funktion (also "blabla()" )).

Bei einseitigen Formularen reicht das schon aus. Bei mehrseitigen Formularen muss noch verhindert werden, dass die Funktion bei jedem Öffnen der Seite wieder ausgeführt wird. Das geht dann so:

a) im Document Level Script ausserhalb einer Funktions-Definition eine Variable definieren und initialisieren (also "var loaded = 0 ;")

b) im Seiten Öffnen-Script den Funktionsaufruf von der Variablen abhängig machen (also:

if (loaded < 1) {

blabla() ;

loaded++ ;

}

Und das wärs auch schon…

And now in "lingua franca":

In the document-level script only define the function (thus "function blabla() { …… }", without actually calling it.

In the Page Open event (display the Thumbnails in the right hand panel, select the according page and then select "Page Properties" via context menu. In the dialog popping up, select the Actions tab and there run a JavaScript. This script will contain the function call (thus "blabla() ;" )).

With single-page forms, this is it. With multipage forms, we have to prevent the function being called each time we open that page. This goes like this:

a) In the document-level script, define and initialize a variable outside of a function definition (thus "var loaded = 0 ;")

b) in the PageOpen script make the function call depending on the variable (thus:

if (loaded < 1) {

blabla() ;

loaded++ ;

}

And that would do it…

Translate
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
New Here ,
Jun 01, 2019 Jun 01, 2019

Hab ich gemacht, also im Document-Level die Funktionen

function UpdateDate(cFormat) {

return util.printd(cFormat, new Date());

}

function SetDate() {

this.getField('Datum').value = UpdateDate('dd.mm.yyyy');

this.getField('Datum').defaultValue = UpdateDate('dd.mm.yyyy');

app.alert("Datum gesetzt: " + UpdateDate("dd.mm.yyyy")); 

};

erstellt und in der Seiteneigenschaft die beiden Funktionen mit

UpdateDate();

SetDate();

aufgerufen.
Das PDF wird normal geöffnet, aber das Script wieder nicht ausgeführt.
Ist Gott sei Dank nur 1 Seite ^^

Translate
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 ,
Jun 01, 2019 Jun 01, 2019

Can you share your file?

Translate
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
New Here ,
Jun 01, 2019 Jun 01, 2019

Sure, here is the link

https://filehorst.de/d/cGnjezhF

Translate
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 ,
Jun 01, 2019 Jun 01, 2019

It does for me...

Translate
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
New Here ,
Jun 01, 2019 Jun 01, 2019

not for me ^^

guess i have to live with it

but thx for your help

Translate
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 ,
Jun 01, 2019 Jun 01, 2019

It works in Acrobat Reader DC.

Translate
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
New Here ,
Jun 01, 2019 Jun 01, 2019

that's an odd thing.
but thanks for help

Translate
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 ,
Jun 01, 2019 Jun 01, 2019

Ein Punkt ist, dass UpdateDate() ein Argument verlangt, und dieses im Beispiel fehlt. (oder ist das nur eine Vereinfachung für den Kommentar hier im Forum)?

___________

One issue is that UpdateDate() needs an argument, which is missing in the example. (or is that just a simplification for the comment here in the forum?)

Translate
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 ,
Jun 02, 2019 Jun 02, 2019
LATEST

Parameters are optional in JS. You can call a function with or without them and it will work. Try this code:

function say(msg) {

    if (msg==null) app.alert("Hi!");

    else app.alert(msg);

}

say("Welcome!");

say();

Translate
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 ,
Jun 01, 2019 Jun 01, 2019

This will work in Acrobat Reader:

Adobe Document Cloud

Translate
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
New Here ,
Jun 01, 2019 Jun 01, 2019

Thank you, but it doesn't work either.
The document opens but Javascript not.
=(

Translate
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