4 Replies Latest reply on Jan 18, 2010 11:56 AM by Jeremy bowmangraphics-DQuh1B

    Making a book out of a document for epub export

    Jeremy bowmangraphics-DQuh1B Level 3

      My fellow scripters,


      I'm about to write a script that will turn a single story in a single document into an indb book with separate chapters "snipped" wherever a paragraph style "Chapter Title" occurs. The idea is to automate to some degree the process of making epub files.


      I'm relatively new to scripting, so this will take quite a lot of my time -- although it will be a valuable learning experience.


      However, if there happens to be such a script already available -- for free, mind -- written by one of the many brilliant scripters on this forum, I'll leave the valuable learning experience for another day, with immense gratitude.



        • 1. Re: Making a book out of a document for epub export
          [Jongware] Most Valuable Participant

          I don't think anything like this has been done before. Congrats for finding a new workflow! But it seems you're going to have to invent everything by yourself.

          Fortunately, your concept can be broken down into simple steps, each one standing on its own. From top of head, something like:


          1. Dividing a story up into several discrete parts, each one starting with a chapter title.

          2. Creating a new document with all the correct settings.

          3. Copying text into this new document, adding pages where needed.

          4. Gathering the new documents into a Book.

          5. Exporting result of (4) to an Ebook.


          For (1) there are a few different options. Perhaps a simple findText, looking for just the chapter style, is all you need. You can use the storyOffsets of the chapter styles to divide the story up in chunks.


          (2) depends on how easy or complicated you want the script to be. By far easiest way is manually creating a template document, with all its size, styles, swatches, and master pages. All that's needed is then to open the template (ID will open a copy of the file by default). Advantage is that you can change the template and run the script again -- hey! presto, an entirely new layout for the same book.

          Another way would be to have the script doing all that's needed -- a lot of repetitive code, and you will literally have to think of everything (especially don't rely on default settings, as the user might have changed these) --, but it has the advantage you don't need any external documents. Disadvantage is, you have to change the code if you want another document layout, or provide an interface for "most commonly changed items".


          A while ago I proposed a JS snippet for (3) -- it's not as hard as it sounds (although an Autoflow feature when pasting text would have been useful). Should be in this forum somewhere.


          (4) is mindboggling easy -- just a line of two, three. The Book object has all necessary functions.


          (5) ... no idea at all. Never created an ebook.

          1 person found this helpful
          • 2. Re: Making a book out of a document for epub export
            Harbs. Level 6

            For step 1, you can use this: http://in-tools.com/plugin.php?p=20




            Innovations in Automation

            1 person found this helpful
            • 3. Re: Making a book out of a document for epub export
              Jeremy bowmangraphics-DQuh1B Level 3

              Thanks Jongware and Harbs -- help gratefully received!


              I've written smaller scripts that do stuff close enough to the steps that will eventually appear in the single script I want, so I'm not expecting any completely insurmountable difficulties. Your comments and links are a great help -- thanks again.


              I'm delighted to think that no one has yet written a single script that does exactly what I want, as it makes me feel like a bit of a pioneer. Hopefully it will work out more like Shackleton than Scott of the Antarctic! I'll let you know if I need a rescue party!

              • 4. Re: Making a book out of a document for epub export
                Jeremy bowmangraphics-DQuh1B Level 3

                Update from near the South Pole...


                The script need loads of polishing, but it is basically doing what I want it to do. As seems to happen with me a lot, one of the main problems is getting the right syntax for InDesign to recognize paths and file names. I'm don't know why this seems to be easier in Windows than on a Mac.


                I agree with Jongware's idea about using a template, and I'll probably do that eventually, but for now the best idea seems to me to be to save successive copies of the original document in a special folder, then remove all text before and after the chapter in question, then remove empty pages. That way, the styles come in as they are, which is all that matters for eventual export to epub format.


                Thanks again for the help!