Skip to main content
Jeremy_bowmangraphics-DQuh1B
Inspiring
January 16, 2010
Question

Making a book out of a document for epub export

  • January 16, 2010
  • 2 replies
  • 910 views

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.

Thanks!

This topic has been closed for replies.

2 replies

Harbs.
Legend
January 16, 2010

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

Harbs

http://www.in-tools.com

Innovations in Automation

Jongware
Community Expert
Community Expert
January 16, 2010

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.

Jeremy_bowmangraphics-DQuh1B
Inspiring
January 16, 2010

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!