Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ASCII file data export by JavaScript in signed PDFs

Community Beginner ,
May 06, 2025 May 06, 2025
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.
TOPICS
JavaScript , PDF
192
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2025 May 06, 2025

You can't change a signed document.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 07, 2025 May 07, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 07, 2025 May 07, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2025 May 06, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 07, 2025 May 07, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2025 May 06, 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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 08, 2025 May 08, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2025 May 08, 2025
LATEST

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines