Skip to main content
Participant
February 7, 2025
Question

Table of Content - PDF Portfolio

  • February 7, 2025
  • 1 reply
  • 296 views

Is there a way to create a Table of Content from the file name and description in a pdf portfolio.  This seems like a very useful file management tool, but it is missing some very basic functions that seem like easy fixes.

1 reply

S_S
Community Manager
Community Manager
March 11, 2025

Hi @dallas_1382,

 

Hope you are doing well. Thanks for writing in!

 

In case you are still looking for a solution, you can try the below script:

 

 

if (!this.metadata || this.dataObjects.length === 0) {
    app.alert("This script only works in a PDF Portfolio.");
} else {
    var toc = [];
    var doc = this;
    var count = doc.dataObjects.length;

    for (var i = 0; i < count; i++) {
        toc.push((i + 1) + ". " + doc.dataObjects[i].name);
    }

    var newPageIndex = doc.insertPages({ nPage: 0, cPath: "/AppData/Acrobat/en_US/Blank.pdf" });

    doc.addAnnot({
        page: newPageIndex,
        type: "Text",
        rect: [50, 700, 550, 750],
        contents: "Table of Contents\n\n" + toc.join("\n"),
        author: "Acrobat Script"
    });

    app.alert("Table of Contents created on the first page!");
}

 

Note: You cannot extract file descriptions, because Acrobat JavaScript cannot read metadata of Portfolio files directly.

 

Hope this helps.


Regards,
Souvik.