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

Batch Processing instead of Forms, Manage form data, export

goslinc
Registered: Sep 25 2007
Posts: 114
Answered

I'll try to clearly explain. I created a form in LCD. User comes it and returns it to us as a pdf (instead of xml directly so that the user using reader can save a completed copy for their records).

So, hundreds of the pdf documents are coming in, and we have to open each individually and do the forms, manage form data, export as xml so that we can then take each xml document in import it into a access database.

This is working perfectly, however, is there a way that I can do some batch processing instead of opening each pdf. When I tried, it saves as xml, but not with my tags I get if I do the forms, manage form data method.

Help???

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, you can use a batch script to export data form a LiveCycle form. Here's one script that will do just that.
// Create Path from form pathvar aPath = this.path.split("/");var cFormName = aPath.pop();var aDataName = cFormName.split(".");aDataName.pop();aDataName.push("xml");var cDataName = aDataName.join(".");aPath.push(cDataName);var cDataPath = aPath.join("/"); // Export datathis.xfa.host.exportData(cDataPath,false);

You'll want to set the batch squence to "Not Save Changes" and you also might want to modify the path creation to include a subfolder for the exported data.


Batch processing is nice, but it provides a somewhat narrow form of Automation. If you are dealing with a high volumn of forms you should consider writing either a server script, where the users would submit the form, or at least writing a VB script for driving the current process, from exporting data from the form to importing it into the DB.

One simple method would be to create a special version of your form where the fields are bound to the DB. Import the exported user data into the DB connected form, where it can be written directly into the DB.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

goslinc
Registered: Sep 25 2007
Posts: 114
Thanks, Still not sure why I'm not getting it via the batch processing in the same format as the Forms, Manage form data way:

Form, Manage form Data Produces This (small excerpt):

<?xml version="1.0" encoding="UTF-8" ?>
-
-
2010-05-27
DouglasBatch Processing Produces this:

<?xml version="1.0" encoding="UTF-8" ?>
-
-
-
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
-
-
-
2009-10-01T07:55:51-04:00
2008-12-29T11:43:07-05:00
2009-10-01T07:55:51-04:00
Adobe LiveCycle Designer 8.0-
uuid:25361648-522c-44cb-8e6c-c762acc31ae5
uuid:86c1f128-4677-4674-ac6d-db375b161477-
xml-
Adobe LiveCycle Designer 8.0<?xpacket end="w"?>
<?xpacket end='r'?>
-
-
-
-
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
This output is produced when the PDF file is saved as XML. It doesn't have anything to do with exporting data.

Did you read my post and try the batch script? It does exactly what you want.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

goslinc
Registered: Sep 25 2007
Posts: 114
I did read your post. I used it exactly as written in what I created as a new sequence under batch processing. I also set the output option to "Not save changes". Was I to change the code you provided me? As you can tell, I am no programmer. Sorry.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
the code works as is. It writes the form data to an XML file with the same name and in the same folder as the processed files.

What was the output from this sequence?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

goslinc
Registered: Sep 25 2007
Posts: 114
I did not receive any output after running it. In the "Select Output Source" is where I indicated "Don't save Changes". My input source still is retaining my original pdf documents, no xml.
goslinc
Registered: Sep 25 2007
Posts: 114
Alright one typo noticed....correct it. Now when I run the sequence the script pops open.
goslinc
Registered: Sep 25 2007
Posts: 114
Sorry for all the emails. When the script editor opened up I clicked ok and it processed, but one. Then I had to click okay each time to work through each file. I must have missed something small. Why does it stop during the batch for me to click on OK?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Because you have it set for "interactive mode". There's a box next to the command in the sequence editor. You must have clicked on it. It should be showing 3 small dots. Click on it again to remove the dots.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

goslinc
Registered: Sep 25 2007
Posts: 114
Mr. Parker I cannot thank you enough!
krm240
Registered: Apr 17 2009
Posts: 95
Hi Thomp
I am trying to have a Btn to export XML, but can not get it to work.
using LC ES2
I copied your code into a click event
When I try it, I get the following error.

this.path has no properties
2:XFA:Main[0]:TaxPage[0]:Wrapper[0]:zBtnLockForm[1]:click

Can you point me in the right direction to fix this?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The script I posted up there in one of the first posts is for a batch script. In that context "this" is a pointer to the document object. In an XFA button script "this" is a pointer to the button object. To get the script to work in an XFA form script replace "this" with "event.target".

But there is another issue. Exporting data is a privileged operation. It cannot be done from within a document context. If you want to export data you'll need to write a batch or automation script.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

krm240
Registered: Apr 17 2009
Posts: 95
You mention that
" Exporting data is a privileged operation. "

I have a trusted function that works that does a saveas
Would this same method work for exporting xml data to a specific file location?

Also, can you please explain more about batch and automation scripts.
Looking for articles where I can learn about these.
Sorry still working on my first form so a newbie!
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, that's exactly what you need. Same concept. The trusted function creates a privileged context.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

krm240
Registered: Apr 17 2009
Posts: 95
Must be doing something silly
Any assistance would be appreciated - using LC ES2
Objective: Export xml to specified folder with specified file name
Issue: Errors and not sure what I need to send for the oDoc parameter in the trusted function

Calling function with the following:
myExportXML2(event.target, FPath, FName);

Trusted function Code:
var myExportXML2 = app.trustedFunction(function(oDoc,cPath,cName)
{
app.beginPriv();
// Ensure path has trailing "/"
cPath = cPath.replace(/([^/])$/, "$1/");

// some debugging statements
console.println('oDoc: ' + oDoc); // object for debuggingg
console.println('cPath:' + cPath); // path for debugging
console.println('cName: ' + cName); // new file name for debugging
console.println('Full path name: ' + (cPath + cName)); // debugging
try{
oDoc.exportData(cPath + cName,0);
}
catch(e)
{
app.alert("Error During Save223");
}
app.endPriv();
});

My error messages from the cosole:
oDoc: [object Doc]
cPath:/n/pmc/forms/
cName: Test.xml
Full path name: /n/pmc/forms/Test.xml

oDoc.exportData is not a function
83:XFA:Main[0]:Admin[0]:Details[0]:DataExport[0]:Button1[2]:click
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
"oDoc" is the document object. The "exportData()" fucntion is a member of the "host" model, not the document object. So, oDoc.xfa.host.exportData().

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

krm240
Registered: Apr 17 2009
Posts: 95
So just to confirm:
I need to send the following to the trusted function
var oDoc = event.target
FPath and FName (both are calculated from other fields)
To do this, the click event button looks like this
myExportXML2(oDoc, FPath, FName);

and then the trusted function will execute the following:
app.trustedFunction(function(oDoc,cPath,cName)
oDoc.xfa.host.exportData(cPath + cName,0);

Also another question:
If one makes a change in the trusted function, do you need to reboot?
Just restarting Adobe pro and LC does not seem to refresh these functions...

Asking as I still seem to have a problem.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Looks like your code is on track

Acrobat loads folder level script when it starts up. So you only have to close an reopen Acrobat. You probably have Acrobat running in the background, check the task manager and kill it the hard way if it's hanging around.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

krm240
Registered: Apr 17 2009
Posts: 95
Something is still not right

This is my console log
oDoc: [object Doc]
cPath:/n/pmc/forms/
cName: Test.xml
Full path name: /n/pmc/forms/Test.xml


This is the trusted function
var myExportXML2 = app.trustedFunction(function(oDoc,cPath,cName)
{
app.beginPriv();
// Ensure path has trailing "/"
cPath = cPath.replace(/([^/])$/, "$1/");

// some debugging statements
console.println('oDoc: ' + oDoc); // object for debugging
console.println('cPath:' + cPath); // path for debugging
console.println('cName: ' + cName); // new file name for debugging
console.println('Full path name: ' + (cPath + cName)); // debugging
try{
oDoc.xfa.host.exportData(cPath + cName,0);
}
catch(e)
{
app.alert("Error During Save223");
}
app.endPriv();
});

When I run the trusted function, the
app.alert("Error During Save223"); pops up.

Any suggestions??
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Try running this code from the console window:

this.xfa.host.exportData("/n/pmc/forms/Test.xml",0);

You should also display the exception message in the alert.

app.alert("Error During Save: " + e);

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

krm240
Registered: Apr 17 2009
Posts: 95
In the console I get

this.xfa.host.exportData("/n/pmc/forms/Test.xml",0);

NotAllowedError: Security settings prevent access to this property or method.
Doc.exportXFAData:-1:Console undefined:Exec

undefined
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Does the path exist? Try saving to a local folder like "/c/temp/test.xml"

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script