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

Acrobat Reader DC Javascript funktioniert nicht

New Here ,
May 31, 2019 May 31, 2019

Copy link to clipboard

Copied

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

Views

4.2K

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

Copy link to clipboard

Copied

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"));

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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;

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

Copy link to clipboard

Copied

Thank you.
I've removed it 😃

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

Copy link to clipboard

Copied

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.

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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…

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

Copy link to clipboard

Copied

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

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

Copy link to clipboard

Copied

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…

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

Copy link to clipboard

Copied

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 ^^

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

Copy link to clipboard

Copied

Can you share your file?

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

Copy link to clipboard

Copied

Sure, here is the link

https://filehorst.de/d/cGnjezhF

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

Copy link to clipboard

Copied

It does for me...

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

Copy link to clipboard

Copied

not for me ^^

guess i have to live with it

but thx for your help

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

Copy link to clipboard

Copied

It works in Acrobat Reader DC.

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

Copy link to clipboard

Copied

that's an odd thing.
but thanks for help

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

Copy link to clipboard

Copied

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?)

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

Copy link to clipboard

Copied

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();

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

Copy link to clipboard

Copied

This will work in Acrobat Reader:

Adobe Document Cloud

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

Copy link to clipboard

Copied

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

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