Skip to main content
Inspiring
January 7, 2016
Answered

Only one file when save framemaker book as html

  • January 7, 2016
  • 2 replies
  • 1585 views

FM 12 all patched up, Windows 8.1.

I have a book with about 30 FMs. When I Save book as HTML, I end up with one HTM file. I want the same number of HTM files as FMs. What am I missing.

Note, I expect each FM to produce an HTM, but that doesn't happen. I have the reference page HTML table set to create a new page on Heading1, and I use Heading1 as the first heading in each FM.

Thoughts?

Sean

This topic has been closed for replies.
Correct answer frameexpert

I found that and one for XHTML output. It's better, but no luck. I now get a log file, history file, ini file, and prj file, and the message says thex html file was created. But no xhtml file is actually created.


Hi Sean,

Here is a script that will save each document in the active book as an .htm file. To use it, copy it to an empty text file and save it with a .jsx extension. Then open your book and choose File > Script > Run and choose the script. Please let me know if you have any questions or comments.

-Rick

#target framemaker

main ();

function main () {

   

    var book;

   

    book = app.ActiveBook;

    if (book.ObjectValid () === 1) {

        processBook (book);

    }

    else {

        alert ("There is no active book.", "www.frameexpert.com");

    }

}

function saveAsHtml (doc) {   

   

    var params, returnParams, saveName, i;

   

    saveName = doc.Name.replace (/\.[^\.]+$/, ".htm");

    params = GetSaveDefaultParams ();

    returnParams = new PropVals ();

    i = GetPropIndex (params, Constants.FS_FileType);

    params.propVal.ival = Constants.FV_SaveFmtFilter;

    i = GetPropIndex (params, Constants.FS_SaveFileTypeHint);

    params.propVal.sval = "0001ADBEHTML ";

    doc.Save (saveName, params, returnParams);

}

function processBook (book) {

    var bookComp = 0, doc = 0;

   

    // Loop through all of the components in the book.

    bookComp = book.FirstComponentInBook;

    while (bookComp.ObjectValid ()) {

        // Get the document returned in a JavaScript object.

        doc = getDocument (bookComp.Name);

        if (doc) {

            book.StatusLine = "Processing " + File(bookComp.Name).displayName;

            // Call the function to process the document.

            saveAsHtml (doc);

            // If the document was opened by the script, close it.

            if (doc.openedByScript === true) {

                doc.Close (true);

            }

        }

        bookComp = bookComp.NextBookComponentInDFSOrder;

    }

    // Reset the book status line.

    book.StatusLine = "";

}

function getDocument (filename) {

   

    // See if the document is already open.

    var doc = docIsOpen (filename);

    if (doc) {

        return doc;

    } else {

        // The document is not already open, so open it.

        return openDocOrBook (filename, undefined, false);

    }

}

function docIsOpen (filename) {

   

    // Make a File object from the file name.

    var file = File (filename);

    // Uppercase the filename for easy comparison.

    var name = file.fullName.toUpperCase ();

    // Loop through the open documents in the session.

    var doc = app.FirstOpenDoc;

    while (doc.ObjectValid () === 1) {

        // Compare the document’s name with the one we are looking for.

        if (File (doc.Name).fullName.toUpperCase () === name) {

            // The document we are looking for is open.

            doc.openedByScript = false;

            return doc;

        }

        doc = doc.NextOpenDocInSession;

    }

}

function openDocOrBook (filename, structuredApplication, visible) {

   

    var i = 0, docOrBook = 0;

    // Get default property list for opening documents.

    var openProps = GetOpenDefaultParams ();

    // Get a property list to return any error messages.

    var retParm = new PropVals ();

    // Set specific open property values to open the document.

    i=GetPropIndex (openProps,Constants.FS_AlertUserAboutFailure);

    openProps.propVal.ival=false;

    i=GetPropIndex (openProps,Constants.FS_MakeVisible);

    openProps.propVal.ival=visible;

    i=GetPropIndex (openProps,Constants.FS_FileIsOldVersion);

    openProps.propVal.ival=Constants.FV_DoOK;

    i=GetPropIndex (openProps,Constants.FS_FileIsInUse);

    openProps.propVal.ival=Constants.FV_ResetLockAndContinue;

    i=GetPropIndex (openProps,Constants.FS_FontChangedMetric);

    openProps.propVal.ival=Constants.FV_DoOK;

    i=GetPropIndex (openProps,Constants.FS_FontNotFoundInCatalog);

    openProps.propVal.ival=Constants.FV_DoOK;

    i=GetPropIndex (openProps,Constants.FS_FontNotFoundInDoc);

    openProps.propVal.ival=Constants.FV_DoOK;

    i=GetPropIndex (openProps,Constants.FS_RefFileNotFound);

    openProps.propVal.ival=Constants.FV_AllowAllRefFilesUnFindable;

    if (structuredApplication !== undefined) {

        i=GetPropIndex (openProps,Constants.FS_StructuredOpenApplication);

        openProps.propVal.sval=structuredApplication;

    }

    // Attempt to open the document.

    docOrBook = Open (filename,openProps,retParm);

    if (docOrBook.ObjectValid () === 1) {

        // Add a property to the document or book, indicating that the script opened it.

        docOrBook.openedByScript = true;

    }

    else {

        // If the document can't be open, print the errors to the Console.

        PrintOpenStatus (retParm);

    }

    return docOrBook; // Return the document  or book object.

}

2 replies

Legend
January 7, 2016

I was thinking the same – as you have FM12, why do you go this old route anyway and don't just use the publish pod?

Seanb_usAuthor
Inspiring
January 7, 2016

That is unfortunate.

I don't use the publish options because I need DHTML with non of the accouterments of the other help "systems." I don't need and can't use extra directory structure, JS files, etc. I just need HTML files, graphics, and one CSS. These basic HTML files are used by manufacturing equipment with screen and browser restrictions.

RoboHelp is even worse and adds even more baggage. I have found ePublisher does exactly what I need, but it's 750/year more than my budget.

So, I figured setting new page to Y would give me a new page. Silly me. Thanks for the  help though!!

Cheers,

Sean

Legend
January 8, 2016

Speculatively, after considering a WebHelp set output from DITA by another engine … one pass through the output with a text editor could remove all the js headers (which you don't need) and the graphics paths to give you a flat file structure. Much would depend on how much other cruft was left in, of course. Speculatively …

Jeff_Coatsworth
Community Expert
Community Expert
January 7, 2016

Think you need to publish the FM book as WebHelp & set the pagination to whatever splits you want to see topics created for