Skip to main content
Participant
March 12, 2020
Answered

Is it possible to manipulate the PDF Bookmarks setup via ExtendScript

  • March 12, 2020
  • 1 reply
  • 642 views

Hi,

I am using Adobe FrameMaker 12 unstructured.

I have an ExtendScript that updates the book with regards to numbers and handles some conditional contents. And as a last step it saves the document as a PDF file.

In the FrameMaker 12 application when you select the menu item File|Save As PDF you get the PDF Setup for Selected Files dialogue. In the Bookmarks tab section, you can manipulate which Paragraphs you want to include in PDF generation.

Is it possible to manipulate this PDF Bookmarks setup via ExtendScript ?

And if so you have any code snippets i can get inspired by?

Thank you for the help

    This topic has been closed for replies.
    Correct answer frameexpert

    The bookmarks setup is actually a property of each PgfFmt (paragraph format) in the document. The property is called AcrobatLevel and it is an integer determining the bookmark level for paragraphs of the paragraph format. If it is set to 0, the paragraphs for that format are not included as bookmarks.

     

    Note that for a book, I think the critical document for setting these would be the first component in the book. So make sure that the first component in the book contains all of your relevant paragraph formats, even if you are not using them in the first component.

    1 reply

    frameexpert
    Community Expert
    frameexpertCommunity ExpertCorrect answer
    Community Expert
    March 13, 2020

    The bookmarks setup is actually a property of each PgfFmt (paragraph format) in the document. The property is called AcrobatLevel and it is an integer determining the bookmark level for paragraphs of the paragraph format. If it is set to 0, the paragraphs for that format are not included as bookmarks.

     

    Note that for a book, I think the critical document for setting these would be the first component in the book. So make sure that the first component in the book contains all of your relevant paragraph formats, even if you are not using them in the first component.

    www.frameexpert.com
    AlexDHIAuthor
    Participant
    March 13, 2020

    Thank you for your reply @frameexpert,

     

    With your explanation and with the help of Save PDF with Bookmarks i got it to work as I wanted.

    We have a CHP paragraf format that is not included in the PDF Bookmarks by default when we create PDF document. I now ensure that in a functions that closes all open files in the script.

    Function is here to inspire others

    function CloseAll()
    {
        doc=app.FirstOpenDoc
        while(doc.id !=0)
        {
            var params = GetSaveDefaultParams();
            var returnParamsp = new PropVals();
    
            doc2=doc.NextOpenDocInSession;
            
            // Ensure CHP is included in the PDF Bookmarks
            var pgfFmt = doc.GetNamedPgfFmt ("CHP");
            if(pgfFmt.ObjectValid() == true) {
               pgfFmt.AcrobatLevel = 1;
               doc.PDFBookmark = true;
            } else {
                FmLogFile.writeln("Could not get CHP format");
            }
            
            doc.Save( doc.Name, params, returnParamsp);
            doc.Close(Constants.FF_CLOSE_MODIFIED);
            doc = doc2;   
       }
    
        book=app.FirstOpenBook
        while(book.id !=0)
        {
            var params = GetSaveDefaultParams();
            var returnParamsp = new PropVals();
    
            book2=book.NextOpenBookInSession;
            book.Save( book.Name, params, returnParamsp);
            book.Close(Constants.FF_CLOSE_MODIFIED);
            book=book2
        }
    }