Thanks for coming to InDesignSecrets.com, the world's #1 resource for all things InDesign!

Exporting from InDesign to HTML5: Amazing Free Script

Oh, if I only had a dollar for each time someone asked me: How do I export my InDesign document as HTML, keeping the page geometry (how the page looks), animations, interactive features, and everything!

Well, you asked for it, you got it… and you’re gonna’ like it!

First, some background…

The Problem

InDesign offers a built-in export-to-HTML (using File > Export) but it only exports text and graphics — not the page geometry! So the result looks nothing like your designed page. It was designed for moving document assets to Dreamweaver or giving to a web developer to format.

As users clearly wanted a direct-to-HTML option, Adobe developed a couple of new export options. First, they built a Fixed Layout EPUB (FXL) export. Many people don’t realize that FXL EPUB is written entirely in HTML5. But you can actually crack open an epub file (it’s just a type of .zip file, actually) and find HTML and CSS files. However, EPUB files only work in dedicated EPUB readers, and not everyone has an EPUB reader that can handle FXL.

Then Adobe created a tool called Publish Online. This is a very cool CC service where InDesign users can very easily export an entire document to be hosted on Adobe servers. While I love Publish Online, it requires that you use Adobe’s servers. And, of course, because the HTML is off-limits, you can’t edit it or put it into your own site, or an app, or something like that.

Third Party Solutions

A few years ago, Justin Putney of Ajar Productions developed an InDesign plug-in called in5 which exports HTML5 from InDesign, with not just page geometry, but interactive elements, and far more. Even better, in5 provides a wide variety of additional features to your export, such as swipe navigation on mobile, and lets you easily move your exported HTML into a Web App or even a full app (using PhoneGap, Baker Framework, the Amazon Marketplace, etc.).

Another commercial HTML export tool is BakerExport from Kerntiff, which looks interesting but I believe is still in development.

Ken Jones of Circular Software has also developed some clever ways to post rich-media fixed-layout EPUBs on a web server and function inside a browser window. It takes some customization, but he showed me an example (including read-aloud text) at the recent InDesign Conference, and it was pretty darn amazing.

And now… a free script

Okay, here’s the kicker… last year, Keith Gilbert discovered an undocumented method for exporting HTML from InDesign CC with a script and wrote about it here. At the time, it was really more of an intriguing amusement, and we didn’t feel there was much you would want it for.

However, I was talking with Keith recently when I saw him at The InDesign Conference about HTML export, and he realized he could expand the script, and offer a few new add-on features that makes exporting HTML a viable method. He has now made that available, for free, for anyone to use.

Page Navigation

Here’s the problem: The normal methods for jumping from one page to the next don’t work when exporting HTML with this script. That is, the “Go to Page” buttons or hyperlinks that go to a text anchor or something like that… all of those interactive features break when you export as HTML. The reason is that when you export as HTML, each page of your InDesign document becomes a different HTML page.

For example, here’s a simple two-page InDesign file with interactive elements in it:

interactive indesign document

And here’s what you get when you export it as HTML with Keith’s script:

Htmlexport2

You can see that the first page of the document is exported with exactly the same as the InDesign document, but with an html extension. The second page has “-1” after the name, and so on. For those of you who are curious, here’s what’s inside the “resources” folder:

inside the resources folder

You’ll notice that there are several files here that you could customize if you want — especially the exported css file!

OK, back to the page navigation problem… the normal page navigation features (such as “go to next page” buttons) assume that the final document is a single file (e.g. a single PDF file). But here, you actually need to jump from one html document to another.

So in order to jump from one page to another, you need to create a hyperlink (in the Hyperlinks panel) to that particular page. There are two ways to do this. First, you can create text anchors on each page, and then build hyperlinks to them.

Or second, you can just make your own hyperlinks, which requires that you know what the page is going to be named. Keith has made this process easy for you by creating a second script called “Add page buttons.” When you run that, it creates blank frames on each page and assigns hyperlinks with the proper names. You don’t have to use this script, but it certainly helps. That said, remember that you’ll need to rename the hyperlinks (or re-run the script) if you ever change the name of the InDesign file (because, again, the HTML files are based on the name of the INDD file).

Where Do You Put It?

After exporting the HTML, you can publish it on your own server, put it in Dropbox, or whatever else you’d like to do with it. For example, here’s the above 2-page test file.

So this is incredible, but I want to be clear that this free script is nowhere near as powerful as one of the third-party tools, such as in5. There are also some critical limitations when using this script… for example, objects that bleed onto the pasteboard aren’t cropped off, so they’re fully visible in the exported HTML. It will also only work well with single-sided (non-facing) documents.

Download: Keith’s script is called “Export FXL HTML” and you can find it here. I strongly recommend you read the Read_me.pdf before running the script. Lots more important information in there!

If you need help installing scripts, see this article. After you’ve installed it, it’ll show up in the Scripts panel like this:

Htmlexport script

Remember that the script is distributed on an “as is” basis… that means neither Keith nor I guarantee it will work for you. Save your work before using it. That said, it has worked very well for me, with the limitations I’ve mentioned.

If you use it for your documents, share the URL below so we can check them out!

David Blatner

David Blatner

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at Lynda.com are among the most watched InDesign training in the world. You can find more about David at 63p.com.
David Blatner

Latest posts by David Blatner (see all)

  • - November 30, -0001
Tags
Related Articles
Comments

15 Comments on “Exporting from InDesign to HTML5: Amazing Free Script

  1. If you see the sample movie I posted in the article above, you’ll notice that the “victory boy” is animated to “fly in from bottom.” Note that this required some extra work because the script doesn’t clip/crop to the page boundaries (so you would normally be able to see the image outside the page frame before he slides in).

    The solution was to apply the animation, then cut the object to the clipboard and use Edit > Paste Into to place him inside a frame that is only on the page.

  2. This is brilliant. It gives me a viable solution for creating HTML5 banner ads out of InDesign rather than using Adobe Animate. I have to tweak a couple of lines in the HTML but other than that works a treat. Great work.

  3. hmm, I guess just typing in html is causing display problems. I’ll try again.

    I delete the line:

    Then add:

    var clickTag = “https://www.indesignsecrets.com”;

    • Simon, thanks for sharing your workflow, and describing how you are using the script. Interesting. Regarding the line that you are deleting each time in the html file, the line that is an incomplete call to a JavaScript file. I suspect that you don’t either deleted or didn’t install the “myCustomJS.js” file in the Assets folder alongside the script (see the script instructions if necessary). If that file isn’t present, the empty reference you are seeing will be generated in the HTML file. the “myCustomJS.js” file is empty, but can be populated with any custom JavaScript that you may need.

      • Keith,

        The myCustomJS.js file IS in the Assets folder, along with myCustomCSS.css and required.txt

        Simon.

  4. While these are all fantastic works of the authors above, Muse was borne from InDesign. Several InDesign developers birthed the application.

    When I first used it seriously 5 years ago, I created 11 different website designs in 30 days – all functional – before settling on what I wanted. Take your InDesign skills to Muse and let it rip. If it’s banner animation, try Hype.

  5. Somehow it doesn’t show up in my scripts panel in CC2017. Only when I put it in the Startup scripts folder but that give an error.

    • Don’t bother, I got it sorted. Script has to be put in ~user/Library/Preferences/Adobe InDesign/Version 12.0/en_US/Scripts/Script Panel
      For CC17.

Leave a Reply

Your email address will not be published. Required fields are marked *