These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

log file

chaida
Registered: Sep 9 2008
Posts: 34
Answered

Hi,

I would like to know if it's possible to create a log or write in a txt file from acrobat with javascript?

If there is something else than the Report objet.

Thank you
chaida

EricFan
Registered: Sep 1 2008
Posts: 13
I have interest to know this too.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Check out the various methods related to Data Objects in the Acrobat JavaScript reference.

George
maxwyss
Registered: Jul 25 2006
Posts: 255
In addition to George's suggestion of the Data Object (which is the recommended approach in many cases), you might also look at the Report object.

Hope this can help.

Max Wyss.
EricFan
Registered: Sep 1 2008
Posts: 13
Hi George, maxwyss:

I find Data Object in JS reference. But it is not what I need.

I use "Batch Processing" to batch process dozens of PDF files and need to write log entries into one file.

Seems either Report object or Data object ad hoc to each individual PDF file. That means I have to create each log for each file processed.

Eric
maxwyss
Registered: Jul 25 2006
Posts: 255
This is something slightly different . However -- note that I have not tested it -- a report should work, if you define it on a "global" level, meaning that you would work with a script you execute from the console, or an Application-level script. There you initialize the Report object you are going to use in the batch process, and in another command you finalize it.The Data object is tied to a document, however.

Hope this can help.

Max.
chaida
Registered: Sep 9 2008
Posts: 34
I'm trying to use the report Object, however I got a security error:
NotAllowedError: Security settings prevent access to this property or method.


here is my code who is in the Level-folder User

// JavaScript Document
var saveReport = app.trustPropagatorFunction( function(){
app.beginPriv();
var rep = new Report();
rep.size = 1.2;
rep.color = color.blue;
rep.writeText("Testing");
rep.save("/c/myreport.pdf")

app.endPriv();
});

myTrustedSpecialTaskFunc = app.trustedFunction(function()
{
// Privileged and/or non-privileged code above
app.beginPriv();
saveReport();
app.endPriv();
// Privileged and/or non-privileged code below
});

I create a toolbutton that will create and save the report.
app.addToolButton({
cName: "btnTest",
cTooltext:"Test",
cExec: "myTrustedSpecialTaskFunc()"})


What am I doing wrong or what more can I do for the security setting.
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Is that the complete error text? It should tell you more than that.

George
try67
Expert
Registered: Oct 30 2008
Posts: 2398
You can try the following:
In an application-level script define a global (empty) string, for example:
global.myGlobalString="";

In your batch sequence you can now add new pieces of text to this variable, for example:
global.myGlobalString+="\nProcessing file: "+this.path;

At the end of the script you can go to the console and print out the log... It's not fully automatic, but it's pretty darn close. (Actually, I thought of a way to do it fully automatic, but it's not very efficient...)

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

chaida
Registered: Sep 9 2008
Posts: 34
George_Johnson wrote:
Is that the complete error text? It should tell you more than that.George
Here is the error text:

NotAllowedError: Security settings prevent access to this property or method.
Report.save:8:App btnTest:Exec
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
It may have to do with the path you've chosen. JavaScript will not let you write to certain locations, so try a more reasonable location.

George
chaida
Registered: Sep 9 2008
Posts: 34
You were right, it was all about the location of the file. I save it in the user application level folder and it works ! :)

Thank you again
chaida

George_Johnson wrote:
It may have to do with the path you've chosen. JavaScript will not let you write to certain locations, so try a more reasonable location.George