JavaScript Save File to Disk

clik search: JavaScript Save File to Disk


Get Answers to your Acrobat and Services Questions
Learning Center
Tutorials
Books, DVD s, Training
Community Blogs
Acrobat Answers
Ask Questions
Answer Questions
Browse Solutions
Find Experts
Exchange
Exchange
Gallery
Actions Exchange
Resources
Support
Training
AUC Newsletter
User Groups
Adobe Certified Experts
Members Area
These forums are now Read Only. Now there are two ways to ask questions. both staffed by experts.
Use your Adobe ID to access either of the following:
If you have a quick question,
please visit our Questions & Answers section. For more in-depts questions and discussions,
please visit us on the Adobe Forums.
Save a text file to local disk

JavaScript Save File to Disk

JavaScript Save File to Disk


JavaScript Save File to Disk

JavaScript Save File to Disk


Save a text file to local disk

Forum Index > JavaScript > Save a text file to local disk
2011-09-26 04:48:04
vishnuuppar
Registered: May 3 2011
Posts: 3 Hi All,

I am trying to save a text file to local disk and want to read write on it,

below is the code for DataObject

var myFunc = app. trustedFunction(function()
{
app. beginPriv();
var str = this. pageNum+1;
str += * +this. path;
this. createDataObject( links. txt ,str);
this. exportDataObject({cName: links. txt ,cDIPath: user,documents });
this. removeDataObject( links. txt );
rep. writeText(str);
rep. save( c Documents and Settings ahsan My Documents links. txt );
app. endPriv();
});

But I am getting error on this.

Please help me.

Thanks in Advance
My Product Information:
Acrobat Standard 8. 2. 6, Windows
Top
2011-09-26 10:07:41 #1
thomp

Registered: Feb 15 2006
Posts: 4411 If you lookup the entry in the Acrobat JavaScript Reference at for the doc. exportDataObject() you ll see these two notes:

Note: Beginning with Acrobat 6. 0, if the parameter cDIPath is non-null, a NotAllowedError (see Error object) exception is thrown and the method fails.

And on the cDIPath argumernt

Note: (Acrobat 6. 0) The use of this parameter is no longer supported and should not be used. See the security notes above.


So exporting a data object won t work any more:(

You ve got the right idea with the report object, but the code is out of place here. I don t see where this object is created and it cannot be saved directly to a text file. It can only be saved to PDF.

The Acrobat JavaScript environment is heavily sandboxed. There are very few ways to write directly to the user s local file system. But there are a couple of ways to write a text file to the user s file system. The easiest method is to use the doc. saveAs() function to convert a PDF into a text file.

So, use the report object to create a PDF with the text you want, then open the report to get the doc object and then save the doc object to text using the cConvID parameter.


Thom Parker
The source for PDF Scripting Info
pdfscripting. com
Very Important - How to Debug Your Script
Top 2011-09-29 02:43:52 #2
vishnuuppar
Registered: May 3 2011
Posts: 3 Thanks a lot Thom Parker.

I am able to save the text file to local by using Doc object saveAs with cConvID parameter.

JavaScript Save File to Disk

JavaScript Save File to Disk


Hazard Insurance Calculator Balboa Countrywide Insurance