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

How to save a document created by method "new Report ()"?

oald
Registered: Oct 12 2011
Posts: 17
Answered

I want to create a new report by method "new Report ()", write some text then save it to C drive, follow are my codes:
   
trustedNewDoc = app.trustedFunction( function ()
{
var rep = new Report();
rep.size = 1.6;
rep.color = color.blue;
rep.writeText("Today is Oct 15th, 2011.");
rep.open("Today");
rep.save("/c/temp/Date of Today.pdf");
})
trustedNewDoc();
   
When I run the codes in JavaScript Debugger, the new document "Today.pdf" is created successfully, but the "save" method fails, here is an error message:
 
GeneralError: Operation failed.
Report.save:8:Console undefined:Exec
 
Could you help to see what the cause is? Your help is really appreciated!

My Product Information:
Acrobat Pro 8.1.6, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
When calling the open() method of the Report object, the report itself is closed and the method returns a Document object, which you can save to a variable and then use like any other Document object.

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

oald
Registered: Oct 12 2011
Posts: 17
Hi try67,

Thanks for your detailed explanation, I have corrected my codes as following, and it works, your help is very appreciated!

trustedNewDoc = app.trustedFunction( function ()
{
var rep = new Report();
rep.size = 1.6;
rep.color = color.blue;
rep.writeText("Today is Oct 15th, 2011.");
var newreport = rep.open("Today");
newreport.saveAs("/c/temp/Date of Today.pdf");
})
trustedNewDoc();