ASCII file data export by JavaScript in signed PDFs
Copy link to clipboard
Copied
"NotAllowedError: Sicherheitseinstellungen verhindern den Zugriff auf diese Eigenschaft oder Methode.
Doc.createDataObject:4:Field..."
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);
Copy link to clipboard
Copied
You can't change a signed document.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
"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.
Copy link to clipboard
Copied
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.
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Use the Acrobat JavaScript Reference early and often

