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

Saving to HTML per Chapter in Book

New Here ,
Jan 08, 2012 Jan 08, 2012

Copy link to clipboard

Copied

Hello,

I have thre questions, but they are related. 

  1. How does one save per-chapter PDFs?
  2. How does one save to HTML?
  3. How does one save per-chapter HTML?

For some things, I have found example code. 

I have found examples showing how to open all the files in a book. 

var openedBook = app.ActiveBook

function openBookFiles(openedBook)

{

    var bookChapter=openedBook.FirstComponentInBook

    var chapterId = bookChapter.id

    while(chapterId)

    {  

        var chapterName = bookChapter.Name

        chapterId = openFile(chapterName)

        bookChapter = bookChapter.NextComponentInBook

        chapterId = bookChapter.id;

     }

}

That part works fine. 

I found an example for saving the whole book to PDF:

function savePdf(openedBook,pdfName)

{   

    var params = GetSaveDefaultParams()

    var returnParamsp =new PropVals()

    var ft = GetPropIndex(params, Constants.FS_FileType)

    params[ft].propVal.ival =Constants.FV_SaveFmtPdf

    openedBook.Save(pdfName, params, returnParamsp);

    return

}

That works fine too.

I tried to modify the above to save to a single HTML file.

function saveHTM(openedBook,htmName)

{   

    var params = GetSaveDefaultParams()

    var returnParamsp =new PropVals()

    var ft = GetPropIndex(params, Constants.FS_FileType)

    params[ft].propVal.ival =Constants.FV_SaveFmtFilter

    var params = GetSaveDefaultParams()

    var fth= GetPropIndex(params, Constants.FS_SaveFileTypeHint )

    params[fth].propVal.ival ="0001ADBEHTML"

    openedBook.Save(htmName, params, returnParamsp)

    return

}

The above does not work at all.

I would like to make the above work.

I would also like to save per-chapter PDFs and per-chapter HTML files.

However, I have not been able to figure out how to save per-chapter anything. 

TOPICS
Scripting

Views

824

Translate

Translate

Report

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
New Here ,
Jan 08, 2012 Jan 08, 2012

Copy link to clipboard

Copied

LATEST

Hello,

I figured out how to get a per-chapter object to save and print to PDF files.

I needed to use app.ActiveDoc after I opened a file. 

function openBookFiles(openedBook)

{

    var bookChapter=openedBook.FirstComponentInBook

    var chapterId = bookChapter.id

    while(chapterId)

    {  

        var chapterName = bookChapter.Name

        chapterId = openFile(chapterName)

        openedChapter= app.ActiveDoc

        var params = GetSaveDefaultParams()

        var returnParamsp =new PropVals()

        var ft  = GetPropIndex(params, Constants.FS_FileType)

        params[ft ].propVal.ival =Constants.FV_SaveFmtPdf

        openedChapter.Save(openedChapter.Name + ".pdf", params, returnParamsp);

        bookChapter = bookChapter.NextComponentInBook

        chapterId = bookChapter.id;

     }

}

Are there problems with this?

I still cannot save to HTML. 

Votes

Translate

Translate

Report

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