Javascript myDoc.info.author not working  SOLVED

Forum for the PDF-XChange Editor - Free and Licensed Versions

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Paul - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

User avatar
yogi108
User
Posts: 76
Joined: Thu Mar 09, 2017 9:13 am

Javascript myDoc.info.author not working

Post by yogi108 »

Hi there,

Just realized, that the line in my Javascript - it worked perfectly - rises an error:
Mozilla JavaScript Engine is initialized (vJavaScript-C 17.0.4esrpre)
App:Init:169: TypeError: Invalid argument type.
.:169:App:Init
My sourcecode is:
myDoc.info.author = "xxxx";

Was there a change regarding "author" ?
Following works:
myDoc.info.title = titel;
myDoc.info.subject = "Subject";

PDF X Change Editor Vers.7, 328.2

Any hints?

Regards
Fritz
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm

Re: Javascript myDoc.info.author not working

Post by Will - Tracker Supp »

Hi Frtiz,

Thanks for the post - Can you please post the whole script that you're running?

Thanks,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
User avatar
yogi108
User
Posts: 76
Joined: Thu Mar 09, 2017 9:13 am

Re: Javascript myDoc.info.author not working

Post by yogi108 »

Will - Tracker Supp wrote: Sun Mar 31, 2019 7:33 pm Hi Frtiz,

Thanks for the post - Can you please post the whole script that you're running?

Thanks,

If it helps, here we go:

function getPages(){

var bFileOpen = false;
var d = app.activeDocs;
var myDoc;
if (d.length>0)
{
// app.alert("Geöffnete Doks!");
for (var i = 0; i < d.length; i++)
{
if (d.documentFileName == "PDF-Druckversionfertig Copy.pdf")
{
d.bringToFront();
bFileOpen=true;
myDoc=d;
break;
}
}

}
if (bFileOpen==false)
{
// app.alert("Kein Dok geöffnet!");
// return;
try {
myDoc = app.openDoc({
cPath: "/g/test/PDF-Druckversionfertig Copy.pdf"
});
} catch (e)
{
myDoc=null;
};
if (myDoc==null)
{
bFileOpen=false;
pfad = app.getPath("app","root")+"/";

try {
myDoc = app.openDoc({
cPath: pfad + "PDF-Druckversionfertig Copy.pdf"
});
} catch (e)
{
myDoc=null;
};

if (myDoc==null)
{
bFileOpen=false;
} else bFileOpen=true;

} else bFileOpen=true;
}

if (bFileOpen==true)
{
// app.alert("OK!");
} else
{
app.alert("PDF-Druckversionfertig nicht vorhanden!");
return;
}


var aParams = [
{cName: "Seiten extrahieren", cReturn: "", bEnabled:false},
{cName: "-"},
{cName: "Test1", cReturn: "24,26,Test1"},
{cName: "Test2", cReturn: "31,31,Test2"}
];

// Apply the function app.popUpMenuEx to the app object, with an array
// of parameters aParams
var cChoice = app.popUpMenuEx.apply( app, aParams );
if ( cChoice != null )
{
// app.alert(cChoice);
var aPage = cChoice.split(",");
var cStart = --aPage[0]; // first element
var cEnd = --aPage[1]; // Second element
var cFile = aPage[2]; // third element

myDoc1=myDoc.extractPages({
nStart: cStart,
nEnd: cEnd
});
stamp2date(myDoc1,cFile);

} else return;
}


function stamp2date(myDoc, cTitel)
{
var inch = 72;
var cm = 72/2.54; // 1 inch = 2,54 cm
var number = 1;


var box=app.alert("Lesezeichen löschen?",2,2,"Lesezeichen löschen");

if(box==4){
myDoc.bookmarkRoot.remove();
}
else if(box==false){
app.alert("Nicht gelöscht!");
}


var annots = myDoc.getAnnots({
nPage:0
});
if (annots!=null)
{
for (var i = 0; i < annots.length; i++)
{
annots.destroy();
}
}

titel=cTitel;
if (titel==null) titel = "PDF überarbeitet";

var aRect = myDoc.getPageBox( {nPage: 0} );
aRect[0] += 0.5*cm;// from upper left corner of page
aRect[2] = aRect[0]+ 7*cm; // Make it 2 inch wide
aRect[1] -= 0.3*cm;
aRect[3] = aRect[1] - 0.6*cm; // and .5 inch high

var f = myDoc.addField("p."+ number, "text", 0, aRect );

f.textSize = 9;
f.textColor = color.blue;
f.strokeColor = color.white;
f.fontWeight = 800;
// f.textFont = font.HelvBI; //font.Helv
f.bold = true;
// f.textFont = "LucidaGrande-Bold";
f.value = "Gespeichert am: " + util.printd("dd.mm.yyyy HH:MM:ss",new Date());
f.readonly = false;

myDoc.flattenPages(0,0); // Seite 0 Felder einbetten

// here it crashes, it worked before! I think 2 updates ago it worked.
myDoc.info.author = "Author";
// error

myDoc.info.title = titel;
myDoc.info.subject = "PDF Deutsch";
// Add a copyright notice. This is a custom metadata entry
myDoc.info.Copyright = "Copyright\xA9 XXXXXX";

// this.addWatermarkFromText("Arbeitskopie", 0, font.Helv, 24, color.red);
myDoc.addWatermarkFromText({
cText: "Arbeitskopie deutsch",
nTextAlign: app.constants.align.center,
nHorizAlign: app.constants.align.center,
nVertAlign: app.constants.align.center,
nHorizValue: 0, nVertValue: 0, bPercentage: true,
nRotation: 45, nFontSize: 48, nOpacity: 0.12, nStart: 0, nScale: -1
});

var d = util.printd("yyyymmdd-HHMM",new Date());
myDoc.saveAs("/g/Test/" + titel + "_" + d + ".pdf");

}
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm

Re: Javascript myDoc.info.author not working  SOLVED

Post by Will - Tracker Supp »

Hi Frtiz,

Thanks for that - I've tested here and it appears to be working for me, with the Version 8 internal pre-release that I'm using. Version 8 is set to be released within the next week or so, provided our internal tests don't turn up any major issues.

Thanks,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
User avatar
yogi108
User
Posts: 76
Joined: Thu Mar 09, 2017 9:13 am

Re: Javascript myDoc.info.author not working

Post by yogi108 »

Will - Tracker Supp wrote: Mon Apr 01, 2019 2:58 pm Hi Frtiz,

Thanks for that - I've tested here and it appears to be working for me, with the Version 8 internal pre-release that I'm using. Version 8 is set to be released within the next week or so, provided our internal tests don't turn up any major issues.

Thanks,
I´`'m looking forward to test the version 8,
Regards,
Fritz
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga
User avatar
Daniel - PDF-XChange
Site Admin
Posts: 12151
Joined: Wed Jan 03, 2018 6:52 pm

Re: Javascript myDoc.info.author not working

Post by Daniel - PDF-XChange »

:D
Dan McIntyre - Support Technician
PDF-XChange Co. LTD

+++++++++++++++++++++++++++++++++++
Our Web site domain and email address has changed as of 26/10/2023.
https://www.pdf-xchange.com
Support@pdf-xchange.com
User avatar
yogi108
User
Posts: 76
Joined: Thu Mar 09, 2017 9:13 am

Re: Javascript myDoc.info.author not working

Post by yogi108 »

Will - Tracker Supp wrote: Mon Apr 01, 2019 2:58 pm Hi Frtiz,

Thanks for that - I've tested here and it appears to be working for me, with the Version 8 internal pre-release that I'm using. Version 8 is set to be released within the next week or so, provided our internal tests don't turn up any major issues.

Thanks,
Hi Will,

Today I tested the new version 8 and it works again,

Regards,
Fritz
"You cannot know the meaning of your life until you are connected to the power that created you.”
Shri Mataji Nirmala Devi, founder of Sahaja Yoga
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19924
Joined: Mon Jan 12, 2009 8:07 am

Re: Javascript myDoc.info.author not working

Post by Stefan - PDF-XChange »

Glad to hear that Yogi!

Regards,
Stefan