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

Invalid File Specification Object

Community Beginner ,
Apr 10, 2018 Apr 10, 2018

I am attempting to export the meta-data about the files contained in a PDF portfolio. I am using the code below which I copied from this link.

// code follows

var d = this.dataObjects;

var csv = '';

    if (d) {

    cfl = this.collection.fields.length;

    tx_cols = new Array();

    tx_names = new Array();

    for (i = 0; i < cfl; i++) {

      tx_cols.push(this.collection.fields.text);

      tx_names.push(this.collection.fields.name);

    }

        csv = tx_cols.join() + "\r\n";

        for (var i = 0; i < d.length; i++) {

      tx_data = new Array();

      for (var r = 0; r < cfl; r++) {

        tx_data.push("\"" + d.getFieldValue(tx_names) + "\"");

//     tx_data.push(d.getFieldValue(tx_names));                    .ast replaced this line w above

      }

      csv += tx_data.join() + "\r\n";

    }

    this.createDataObject({cName:"EmailData.csv", cValue:csv,cMIMEType:'text/csv'});

    this.exportDataObject("EmailData.csv");

    this.removeDataObject("EmailData.csv");

    }

// end of code

I am able to execute it but I receive this error:

RaiseError: Invalid file specification object.

Data.getFieldValue:31:Console undefined:Exec

===> Invalid file specification object.

undefined

I haven't worked with JavaScript previously so I will be looking at the Adobe docs but, since this it time critical, I was hoping not to have to work thru everything from the beginning. Does anyone have any suggestions where to begin? I am using Acrobat Pro DC.

Thank you,

TOPICS
Acrobat SDK and JavaScript , Windows
4.9K
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

correct answers 1 Correct answer

Community Expert , Apr 11, 2018 Apr 11, 2018

There is an error in the code. The open documents are not being closed.

this line:

oDoc.closedoc

Needs to be this:

oDoc.closeDoc(true);

Translate
Community Expert ,
Apr 10, 2018 Apr 10, 2018

The data object is not the document object for the embedded file. so of course it cannot be used to call getField. To get the document object you have to open it with the "doc.openDataObject()" function.

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 ,
Apr 11, 2018 Apr 11, 2018

Thanks for your reply. I have modified the code as below. It appears to be creating a Doc object from the embedded document but I get this error when I run the script:

RaiseError: Cos document table full.

Doc.openDataObject:30:Console undefined:Exec

===> Cos document table full.

undefined

I found several articles where the problem was reported but not a clear resolution. Do you have any suggestions?

// code follows

var d = this.dataObjects;

var csv = '';

    if (d) {

    cfl = this.collection.fields.length;

  

//    app.alert("collection field lenght is " + cfl)

    tx_cols = new Array();

    tx_names = new Array();

    for (i = 0; i < cfl; i++) {

      tx_cols.push(this.collection.fields.text);

      tx_names.push(this.collection.fields.name);

    }

        csv = tx_cols.join() + "\r\n";

        for (var i = 0; i < d.length; i++) {

          tx_data = new Array();

          var oDoc = this.openDataObject(d.name);

    

          for (var r = 0; r < cfl; r++) {

              

//            tx_data.push("\"" + oDoc.getFieldValue(name:tx_names) + "\"");

//            tx_data.push(d.getFieldValue(tx_names));                    .ast replaced this line w above

            }

          oDoc.closedoc

          csv += tx_data.join() + "\r\n";

        }

//  this.createDataObject({cName:"EmailData.csv", cValue:csv,cMIMEType:'text/csv'});

//  this.exportDataObject("EmailData.csv");

//  this.removeDataObject("EmailData.csv");

    }

// end of code

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 ,
Apr 11, 2018 Apr 11, 2018

Do you know at what point the error occurs?  Is it on the first embedded file opened? or somewhere down the line?  Is the Portfolio very large? Are there a lot of other files open? 

The message seems to indicate that the "document table" has run out of memory, meaning there is too much going on. Of course it may be that just one bad thing is going on and the reported error doesn't represent the actual error condition. For example, are all the embedded files PDFs? Are there any issues with the embedded PDFs?

Try simplifying the code to a loop that just opens and closes the embedded files, see if you get the same error.

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 ,
Apr 11, 2018 Apr 11, 2018

It takes a moment for the error to occur so it looks like it is occurring somewhere down the line. The portfolio contains about 750 PDF documents. The are copies of email and are mostly 2 or 3 pages long but there could be attachments as well. I haven't encountered any issues opening any of the embedded PDFs or attachments but I haven't attempted to every one.

My system shows 6 GB of free memory and the RAM usage doesn't change when I run the script.

I'll look at simplifying the code as you suggested and see if that changes anything. I'll also look at logging each document as it is opened so I know how far along it gets before the error.

Thank you for your reply.

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 ,
Apr 11, 2018 Apr 11, 2018

I have modified the code so so that it just opens and closes the embedded document and outputs information to a report so I can determine how far it gets in the process. The script completes if I code it to open and close the first 200 or so embedded documents but it starts failing as I approach 220 embedded documents.

I have hard coded different starting points in the embedded documents and achieved similar results so I don't believe it is a single document that is causing the error.

If I don't open the embedded document, I can execute the loop for the count of the embedded documents without error.

Is there a statement that needs to be executed after an embedded document is closed to release resources consumed when when the document is opened?

Here is my current test code:

var d = this.dataObjects;

var rep = new Report();

    if (d) {

        cfl = this.collection.fields.length;

        tx_cols = new Array();

        tx_names = new Array();

        for (i = 0; i < cfl; i++) {

            tx_cols.push(this.collection.fields.text);

           

            rep.writeText("i = " + i + " fields.text = " + this.collection.fields.text);    //

            tx_names.push(this.collection.fields.name);

           

            rep.writeText("i = " + i + " fields.name = " + this.collection.fields.name);    //

        }   

        csv = tx_cols.join() + "\r\n";

        rep.writeText("d.length is " + d.length);

       

//        for (var i = 0; i < d.length; i++) {

        for (var i = 200; i < 400; i++) {           

//            tx_data = new Array();

            var oDoc = this.openDataObject(d.name);

            rep.writeText("i is " + i + " Embedded File name is " + oDoc.name);

           

            oDoc.closedoc

         

//            for (var r = 0; r < cfl; r++) {

               

//              tx_data.push("\"" + oDoc.getFieldValue(name:tx_names) + "\"");

//              tx_data.push(d.getFieldValue(tx_names));                    .ast replaced this line w above

//            }

//        csv += tx_data.join() + "\r\n";

       

        }

       

        rep.writeText("Embedded Doc loop is complete");

    }

       

    var docRep = rep.open("This is a test");

   

//    rep.writeText("Summary of files within the PDF portfolio: " + this.documentFileName + "\n");

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 ,
Apr 11, 2018 Apr 11, 2018

There is an error in the code. The open documents are not being closed.

this line:

oDoc.closedoc

Needs to be this:

oDoc.closeDoc(true);

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 ,
Apr 11, 2018 Apr 11, 2018

I changed the line as you stated above and I receive this error:

TypeError: this.GetDataObject is not a function

34:Console:Exec

undefined

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 ,
Apr 12, 2018 Apr 12, 2018

Ok, so what's on line 34?  And why is "i" in the loop incrementing from 200 to 400? Are there really 400 file attachments?

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 Expert ,
Apr 12, 2018 Apr 12, 2018

JS is case-sensitive. There's no method called GetDataObject. It's getDataObject.

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 ,
Apr 12, 2018 Apr 12, 2018

In the posted code there is no "GetDataObject", hence my question about the current state of the code.

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 ,
Apr 12, 2018 Apr 12, 2018

At this point, the replies posted in this thread have provided answers to my original questions so I don't need a reply. I'll start a new thread if I have additional questions. Thank you for your assistance.

For future reference, here are replies to your questions.

Ok, so what's on line 34?  And why is "i" in the loop incrementing from 200 to 400? Are there really 400 file attachments?

There are approximately 750 documents in the portfolio. The 200 to 400 counter was part of troubleshooting to open a different set of documents. I also tested 400 to 600. My thought was that a specific document may have been causing the error. This was a way to open a different set of documents to reduce the possibility that a single document was causing the issue.

In the posted code there is no "GetDataObject", hence my question about the current state of the code.

I apologize; I inadvertently copied the response from a different JavaScript console. It wasn't part of the original code.

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 ,
Apr 12, 2018 Apr 12, 2018

Thank you for that gem of information.

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 ,
Apr 13, 2018 Apr 13, 2018

The data object is not the document object for the embedded file. so of course it cannot be used to call getField. To get the document object you have to open it with the "doc.openDataObject()" function.

doesn't d in the line      tx_data.push("\"" + d.getFieldValue(tx_names) + "\"");

reference the embedded 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 Expert ,
Apr 15, 2018 Apr 15, 2018
LATEST

It references an object that describes the embedded object. i.e. the DataObject. Here's the entry for it in the Acrobat JavaScript Reference.

Acrobat DC SDK Documentation

To get the document object the embedded file has to be opened.

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