karla123
Goto Top

Warum funktioniert das JavaScript nicht

Liebes Forum,

eine Frage, warum wird das folgende Script innerhalb vom Acrobat in den Dokumenteinstellung unter dem Punkt "Zusätzlichen Metadaten" nicht ausgeführt? Einträge in die Dokumenteneigenschaften wie z.B. Titel, Verfasser etc. funktionieren damit.

Das Script:
function CopyrightStatusSetzen(){
var EingabemdCopyrightStatus = app.response({
cQuestion: "Geben Sie die CopyrightStatus ein:",
cCopyrightStatus: "CopyrightStatus eingeben",
cDefault: "1975"});
if(EingabemdCopyrightStatus == null){
}
else
this.info.CopyrightStatus = EingabemdCopyrightStatus;
this.layout = "MultiplePage";
// this.layout = "SinglePage";
}
app.addToolButton({
cName: "SetCopyrightStatus",
cLabel: "CopyrightStatus setzen",
cTooltext: "CopyrightStatus setzen",
cEnable: true,
cExec: "CopyrightStatusSetzen()"});

könnte mir vielleicht jemand helfen??

Im Vorfeld schon einmal vielen Dank und einen lieben Gruß

Content-Key: 482539

Url: https://administrator.de/contentid/482539

Printed on: April 25, 2024 at 07:04 o'clock

Member: Bitboy
Bitboy Aug 07, 2019 updated at 13:04:33 (UTC)
Goto Top
Hi,

kenne mich zwar mit beidem nicht wirklich aus aber fehlt hinter dem else nicht eine {

btw statt ein "leeres if statement" könntest du doch auch die bedingung umdrehen und brauchst kein else:

if(EingabemdCopyrightStatus != null){
this.info.CopyrightStatus = EingabemdCopyrightStatus;
this.layout = "MultiplePage";  
// this.layout = "SinglePage"; 
} 

Grüße
Member: karla123
karla123 Aug 08, 2019 at 06:54:22 (UTC)
Goto Top
Lieber Bitboy,

leider hat das nichts gebracht! Gibt es vielleicht einen anderen Weg??

Trotzdem vielen Dank und LG
Member: Bitboy
Bitboy Aug 08, 2019 at 09:49:16 (UTC)
Goto Top
Ist zwar uralt die Seite https://acrobatusers.com/tutorials/print/auto_insert_metadata aber da steht als Beispiel:
this.info.copyright
statt
this.info.CopyrightStatus
Member: karla123
karla123 Aug 08, 2019 at 12:44:20 (UTC)
Goto Top
Lieber Bitboy,

leider funktioniert dieses Script nicht unter Acrobat DC! Gibt es vielleicht doch noch einen anderen Weg??

Trotzdem vielen Dank und LG
Member: karla123
karla123 Aug 09, 2019 at 08:39:07 (UTC)
Goto Top
Member: karla123
karla123 Aug 09, 2019 at 08:49:12 (UTC)
Goto Top
Mitglied: 140447
140447 Aug 09, 2019 updated at 09:54:30 (UTC)
Goto Top
Warum funktioniert das JavaScript nicht
Weil das total veraltet ist, die CopyrightInfo muss als XML in die Metadaten gesetzt werden.

In die Doku schauen hilft ungemein, da steht wie man das Copyright jetzt richtig setzen muss:
https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/js_api_ref ...
var CopyrightStatus = "True";  
var CopyrightNotice = "Copyright(C) 2006, BlaBlub Corp."  
var CopyrightInfoURL = "http://www.domain.tld"  


var meta = this.metadata;
var myXMPData = new XML(meta);
myx = new Namespace("adobe:ns:meta/");  
myrdf = new Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#");  
mypdf = new Namespace("http://ns.adobe.com/pdf/1.3/");  
myxap = new Namespace("http://ns.adobe.com/xap/1.0/");  
mydc = new Namespace("http://purl.org/dc/elements/1.1/");  
myxapRights = new Namespace("http://ns.adobe.com/xap/1.0/rights/");  
var p = myXMPData.myrdf::RDF.myrdf::Description;
/*
We test whether this element has a value already, if no, we assign it a
value, otherwise we assign it another value.
*/
if (p.mydc::rights.myrdf::Alt.myrdf::li.toString() == "") {  
p += <rdf:Description rdf:about=""  
xmlns:dc="http://purl.org/dc/elements/1.1/"  
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">  
<dc:rights>
<rdf:Alt>
<rdf:li xml:lang="x-default">  
{CopyrightNotice}
</rdf:li>
</rdf:Alt>
</dc:rights>
</rdf:Description>
} else
p.mydc::rights.myrdf::Alt.myrdf::li = CopyrightNotice;
/*
Some elements are converted into attributes, so we need to first test
whether the xapRights:Marked attribute is present, if not, we add it in as an
element; otherwise, if the attribute is present, we update the attribute.
Acrobat changes certain elements into attributes; the xapRights:Marked and
xapRights:WebStatement are two such examples, but dc:rights above is one
that is not changed into an attribute.
*/
if (p.@myxapRights::Marked.toString() == "" ) {  
p += <rdf:Description rdf:about=""  
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"  
xmlns:xapRights="http://ns.adobe.com/xap/1.0/rights/">  
<xapRights:Marked>{CopyrightStatus}</xapRights:Marked>
<xapRights:WebStatement> {CopyrightInfoURL} </xapRights:WebStatement>
</rdf:Description>
} else {
p.@myxapRights::Marked = CopyrightStatus;
p.@myxapRights::WebStatement = CopyrightInfoURL;
}
// Convert myXMPData into a string
myNewXMPStr=myXMPData.toXMLString();
// and assign it to the document metadata
this.metadata = myNewXMPStr;

p.s. Fragen mit verständlichem Text stellen hilft ebenfalls, dann muss man nicht das Web mit solch überflüssigen Threads überschwemmen.
Member: karla123
karla123 Aug 09, 2019 at 12:34:56 (UTC)
Goto Top
Hallo routerboard,

vielen Dank für das Script und den Hinweis auf die Doku!

Ist es denn möglich mittels eines ToolButtons manuelle Einträge zu tätigen? Also z.B. ich möchte den Copyright Eintrag in einer "Maske" eingeben und dieser wird dann in das Feld eingetragen?

Ich hoffe das ist verständlich ausgedrückt??

Liebe Grüße
Mitglied: 140447
Solution 140447 Aug 09, 2019 at 12:42:19 (UTC)
Goto Top
Joa, les das PDF dann weist du wie.