Skip to main content
Participant
May 6, 2025
Question

ASCII file data export by JavaScript in signed PDFs

  • May 6, 2025
  • 3 replies
  • 726 views
Hello,
I would like to export data from a signed Adobe PDF-File (formular with values) to an ASCII file with a JavaScript triggered by a button in den PDF-file.
 
e.g. Javascript:
var DataWrite = "Data XYZ...";
var doc = this.createDataObject({cName: "Test_Export_Data.txt", cValue: DataWrite});
this.exportDataObject({cName: "Test_Export_Data.txt", nLaunch:0});
 
This code works fine without a signed document.
 
With a signed document (fields are write protected) following error occurs:
"NotAllowedError: Sicherheitseinstellungen verhindern den Zugriff auf diese Eigenschaft oder Methode.
Doc.createDataObject:4:Field..."
 
I have also tried the TrustedFunction but this don't solve the problem.
var DataWrite = "Data XYZ...";
var DataExport = app.trustedFunction(function(DataWrite)
{
app.beginPriv();
this.createDataObject({cName: "Test_Export_Data.txt", cValue: DataWrite});
this.exportDataObject({cName: "Test_Export_Data.txt", nLaunch:0});
app.endPriv();
});
DataExport(DataWrite);
 
Attachment: signed  document properties
 
Maybe someone can help me to solve the problem.

3 replies

Thom Parker
Community Expert
Community Expert
May 6, 2025

In addition to the suggestion by Try67, if necessary, a more complicated data workflow can be created using a folder level automation script to, for example, collect the data from the signed document into a custom format, then export it as a data object from a non-signed PDF.  The action doesn't have to happen in the original PDF. 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
May 8, 2025

Thank you for your answer. That could be the only solution that works within Adobe. "folder level automation script" and working outside of the original signed PDF could be the keywords to get on

Thom Parker
Community Expert
Community Expert
May 8, 2025

For the external document,  There are two ways to go. 

1. Create a special document for this purpose and place it in a known location.  This method is helpful if the doc has more to it than just being a tool for exporting the data. For example, if it's kept as a record of the action. 

2. Create a temp PDF on the fly using the "app.newDoc()" function.   Use this is the PDF can be thrown away after it's used. 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
try67
Community Expert
Community Expert
May 6, 2025

You can't create a new data object, since that would be modifying the signed file, but you can export the data directly with the exportAsText command.

Or you can output it to the Console window (or even a dialog object) and have the user copy it from there to a text file.

Participant
May 8, 2025

"create.DataObject" allows to create a free txt file with own specific format e.g. new field names etc. .

"ExportAsText" works with signed documents but haven't the variance in format the txt contents. I must import this data in an other system. I would like to avoid a new converting of data between adobe and the destination system and I prefer a simple workflow.

Bernd Alheit
Community Expert
Community Expert
May 6, 2025

You can't change a signed document.

Participant
May 8, 2025

I won't change the signed document. I would like to export the data in a new file. I have in den formular 2 signatures. The first signature locks only a few fields. This is already too much and causes the error.

try67
Community Expert
Community Expert
May 8, 2025

You are changing it by creating a new data object, which is not allowed.

You were presented with at least 2 alternatives on how to do it properly.