1 Reply Latest reply on Jan 8, 2012 7:20 PM by Kevin B Walsh

    Saving to HTML per Chapter in Book

    Kevin B Walsh

      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. 

        • 1. Re: Saving to HTML per Chapter in Book
          Kevin B Walsh Level 1

          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.